teeny_kernels/lib.rs
1/*
2 * Copyright (c) 2026 Teenygrad.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! CPU/GPU kernel implementations of [teenygrad](https://teenygrad.org)'s `nn` layers
18//! ([`nn`] — including a Flash Attention 2 forward/backward implementation, [`math`] ops, and
19//! [`graph`] lowering), written against the `teeny-triton` DSL and compiled via `teeny-compiler`.
20//!
21//! The `cuda` feature (on by default) enables the `teeny-cuda` backend, which requires the CUDA
22//! toolkit to build — see its crate README. Running/compiling kernels additionally needs the
23//! custom `teenyc` compiler at runtime; see `teeny-compiler`'s README.
24
25// `#[kernel]`-annotated functions naturally take many parameters (pointers, strides, dims,
26// block-size const-generics) matching the CUDA/Triton kernel calling convention -- inherent to
27// the domain, not something to refactor away. `Dag<Box<dyn ExecutableOp>>`-style return types
28// (graph::lower) are similarly intentional, not accidental complexity.
29#![allow(clippy::too_many_arguments, clippy::type_complexity)]
30
31pub mod errors;
32pub mod graph;
33pub mod math;
34pub mod nn;