Skip to main content

baracuda_kernels_types/
lib.rs

1//! # baracuda-kernels-types
2//!
3//! Shared type vocabulary for the baracuda ML kernel facade.
4//!
5//! This crate has no behavior of its own — it ships pure-data types that
6//! are common to every member of the kernel facade ecosystem:
7//!
8//! - The [`KernelDtype`] umbrella marker trait + the [`Element`] /
9//!   [`IntElement`] / [`FpElement`] / [`BinElement`] / [`BiasElement`]
10//!   trait hierarchy plus the [`ScalarType`] alpha/beta projection.
11//! - Wrapper types ([`S8`], [`U8`], [`S4`], [`U4`], [`Bin`],
12//!   [`F32Strict`], [`Fp8E4M3`], [`Fp8E5M2`]) that drive kernel
13//!   selection at the Rust type level.
14//! - Tag enums ([`ElementKind`], [`MathPrecision`], [`BiasElementKind`],
15//!   [`LayoutSku`], [`ArchSku`], [`EpilogueKind`], [`ActivationKind`]).
16//! - Borrowed device-buffer views ([`MatrixRef`], [`MatrixMut`],
17//!   [`VectorRef`]).
18//! - Plan-layer descriptors ([`PlanPreference`], [`PrecisionGuarantee`],
19//!   [`Workspace`]).
20//!
21//! # 1.0-freeze stability (Phase 28)
22//!
23//! Most op-family discriminant enums (`BinaryKind`, `UnaryKind`,
24//! `ReduceKind`, `ScanKind`, `SoftmaxKind`, `NormalizationKind`,
25//! `LossKind`, `LinalgKind`, `ConvKind`, `PoolKind`, `AttentionKind`,
26//! `IndexingKind`, `SegmentKind`, `EmbeddingKind`, `QuantizeKind`,
27//! `GgufBlockFormat`, `MoeKind`, `SortKind`, `ImageKind`, `FftKind`,
28//! `RandomKind`, `ShapeLayoutKind`, `BinaryCmpKind`, `TernaryKind`,
29//! `GatedActivationKind`, `ArgReduceKind`, `PadMode`) plus the category
30//! / backend tag enums (`OpCategory`, `BackendKind`) and the auxiliary
31//! index-dtype tag enums (`IndexElementKind`, `IndexOutputKind`) are
32//! marked `#[non_exhaustive]` as of Phase 28. Downstream `match` arms
33//! must include a `_ =>` catch-all to remain forward-compatible with
34//! new variants.
35//!
36//! The kernel-dispatch-keying enums `ElementKind`, `BiasElementKind`,
37//! `LayoutSku`, `ArchSku`, `EpilogueKind`, `ActivationKind`, and
38//! `Workspace<'a>` are **intentionally** left exhaustive — they're
39//! the keys per-arch / per-layout / per-epilogue / per-bias-dtype
40//! kernel dispatchers exhaustively match on, so adding a new variant
41//! is a deliberate workspace-wide event that ought to surface as a
42//! build break across every match site.
43//!
44//! The types here were previously defined in `baracuda-cutlass::types`;
45//! they were lifted out so that `baracuda-kernels` (the unified ML op
46//! facade) and any sibling wrapper crate (`baracuda-cublas`,
47//! `baracuda-cudnn`, …) can share one vocabulary instead of each
48//! re-declaring its own.
49//!
50//! The trait `Element` was previously named `CutlassElement`;
51//! `baracuda-cutlass` keeps the old name available as a re-export for
52//! back-compat. The semantics are unchanged.
53
54#![deny(missing_docs)]
55
56pub mod element;
57pub mod layout;
58pub mod matrix;
59pub mod ops;
60pub mod plan;
61pub mod sku;
62pub mod tensor;
63
64pub use element::{
65    BiasElement, BiasElementKind, Bin, BinElement, Bool, Complex32, Complex64, Element,
66    ElementKind, F32Strict, Fp8E4M3, Fp8E5M2, FpElement, IndexElement, IndexElementKind,
67    IndexOutputElement, IndexOutputKind, IntElement, KernelDtype, MathPrecision, S4, S8,
68    ScalarType, U4, U8,
69};
70pub use layout::{ActivationKind, ArchSku, EpilogueKind, LayoutSku};
71pub use matrix::{MatrixMut, MatrixRef, VectorRef};
72pub use ops::{
73    ArgReduceKind, AttentionKind, BinaryCmpKind, BinaryKind, ConvKind, CrossEntropyTargetKind,
74    EmbeddingKind, FftKind, FillMode, GatedActivationKind, GgufBlockFormat, ImageKind,
75    IndexingKind, LinalgKind, LossKind, LossReduction, MoeKind, NormalizationKind, PadMode,
76    PoolKind, QuantizeKind, RandomKind, ReduceKind, ReduceToOp, ScanKind, SegmentKind,
77    ShapeLayoutKind, SoftmaxKind, SortKind, TernaryKind, UnaryKind,
78};
79pub use plan::{PlanPreference, PrecisionGuarantee, Workspace};
80pub use sku::{BackendKind, KernelSku, OpCategory};
81pub use tensor::{contiguous_stride, strides_equal, TensorMut, TensorRef};