Skip to main content

teeny_triton/
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//! The Triton-like kernel DSL for [teenygrad](https://teenygrad.org). Kernel functions are
18//! written against [`triton`]/[`triton_lang`]'s types and `#[kernel]`-annotated
19//! (`teeny_macros::kernel`); [`triton_lang::TRITON`] embeds the DSL source as a string constant
20//! (generated by `build.rs`), consumed by the custom `teenyc` compiler at kernel-compile time.
21//! See the crate README for the runtime `teenyc`/`TEENYC_PATH` setup this implies.
22
23// Kernel-DSL trait methods (e.g. `load`, `dot_scaled`) and combinator function-pointer types
24// mirror Triton's own many-parameter, tensor-of-function-pointer signatures -- inherent to the
25// domain, not something to refactor away.
26#![allow(clippy::too_many_arguments, clippy::type_complexity)]
27#![warn(missing_docs)]
28
29/// Error types.
30pub mod error;
31/// The `Triton` DSL trait and its supporting types.
32pub mod triton;
33/// The generated DSL source text, embedded as [`triton_lang::TRITON`].
34pub mod triton_lang;
35
36/// A compiled kernel's identity: its name, type signature, and generated source block.
37#[derive(Debug)]
38pub struct TritonKernel {
39    /// The kernel's name.
40    pub name: &'static str,
41    /// The kernel's type signature.
42    pub sig: &'static str,
43    /// The generated DSL source block for this kernel.
44    pub block_str: &'static str,
45}