Skip to main content

KernelDtype

Trait KernelDtype 

Source
pub trait KernelDtype:
    DeviceRepr
    + Sealed
    + Copy
    + 'static {
    const KIND: ElementKind;
}
Expand description

Umbrella marker trait for every dtype usable as a kernel input or output.

The bound captures the three minimum properties a kernel dtype needs: a fixed memory layout (DeviceRepr) so the host can ship bytes to the device verbatim, Copy + 'static so the type can flow through plan / args structs without an &mut self, and a runtime tag (ElementKind) for dispatch.

KernelDtype is wider than Element: it covers the sub-byte / FP8 / packed-bit newtypes (S4, U4, S8, U8, Fp8E4M3, Fp8E5M2, Bin) that have their own kernel families and don’t fit the <T: Element> plan shape. Every Element, IntElement, FpElement, and BinElement type also implements KernelDtype (the sibling traits all use it as a supertrait), so a function bounded by <T: KernelDtype> accepts any kernel-usable type.

Sealed because adding a new dtype requires a matching kernel instantiation in baracuda-kernels-sys.

§When to use

Prefer Element when you’re parameterizing a plan that lives in the elementwise / reduce / scan / norm / loss families — those plan shapes are written against <T: Element> and use the type Scalar projection. Reach for KernelDtype only when you genuinely want the union of every kernel dtype (sub-byte + FP8 + packed-bit included) — e.g. a generic dtype-size helper, telemetry function, or downstream wrapper.

Required Associated Constants§

Source

const KIND: ElementKind

Runtime tag for this dtype. Stable across the workspace — keyed by this same enum in crate::KernelSku::element.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl KernelDtype for bf16

Source§

const KIND: ElementKind = ElementKind::Bf16

Source§

impl KernelDtype for f16

Source§

const KIND: ElementKind = ElementKind::F16

Source§

impl KernelDtype for f32

Source§

const KIND: ElementKind = ElementKind::F32

Source§

impl KernelDtype for f64

Source§

const KIND: ElementKind = ElementKind::F64

Source§

impl KernelDtype for i32

Source§

const KIND: ElementKind = ElementKind::I32

Source§

impl KernelDtype for i64

Source§

const KIND: ElementKind = ElementKind::I64

Implementors§

Source§

impl KernelDtype for Bin

Source§

const KIND: ElementKind = ElementKind::Bin

Source§

impl KernelDtype for Bool

Source§

const KIND: ElementKind = ElementKind::Bool

Source§

impl KernelDtype for Complex32

Source§

const KIND: ElementKind = ElementKind::Complex32

Source§

impl KernelDtype for Complex64

Source§

const KIND: ElementKind = ElementKind::Complex64

Source§

impl KernelDtype for F32Strict

Source§

const KIND: ElementKind = ElementKind::F32Strict

Source§

impl KernelDtype for Fp8E4M3

Source§

const KIND: ElementKind = ElementKind::Fp8E4M3

Source§

impl KernelDtype for Fp8E5M2

Source§

const KIND: ElementKind = ElementKind::Fp8E5M2

Source§

impl KernelDtype for S4

Source§

const KIND: ElementKind = ElementKind::S4

Source§

impl KernelDtype for S8

Source§

const KIND: ElementKind = ElementKind::S8

Source§

impl KernelDtype for U4

Source§

const KIND: ElementKind = ElementKind::U4

Source§

impl KernelDtype for U8

Source§

const KIND: ElementKind = ElementKind::U8