Skip to main content

DType

Enum DType 

Source
pub enum DType {
Show 18 variants U8, I8, U32, I16, I32, I64, BF16, F16, F32, F64, F8E4M3, F8E5M2, F6E2M3, F6E3M2, F4, F8E8M0, F8E6M2, Bool,
}
Expand description

The different types of elements allowed in tensors.

Variants§

§

U8

Unsigned 8-bit integer.

§

I8

Signed 8-bit integer. Added 2026-05-19 for int8 GEMM (W8A8 inference) support — baracuda’s gemm_s8_* family accepts i8 operands and mma.sync .s8.s8.s32 instructions.

§

U32

Unsigned 32-bit integer.

§

I16

Signed 16-bit integer.

§

I32

Signed 32-bit integer.

§

I64

Signed 64-bit integer.

§

BF16

Brain floating-point using half precision (16 bits).

§

F16

Floating-point using half precision (16 bits).

§

F32

Floating-point using single precision (32 bits).

§

F64

Floating-point using double precision (64 bits).

§

F8E4M3

8-bit floating point, 4-bit exponent + 3-bit mantissa — specifically OCP finite E4M3FN: bias 7, max-finite ±448, no infinities, single NaN. This is the only E4M3 format Fuel represents, so the bare name is unambiguous today (enforced by reserved_token_tests::exactly_one_e4m3_family_dtype_or_revisit_gap_169).

The identity F8E4M3 == OCP E4M3FN is committed and tested at three independent sites: the structure-key path (fuel-dispatch telemetry::baracuda_provider::map_element_kind), the JIT seam (fuel-dispatch jit_adopt::fp8_maps_to_baracuda_ocp_element_kinds), and the external-contract parser (fuel-dispatch fkc::lower’s “F8E4M3FNUZ must not lower to F8E4M3” prefix rejection).

The name is deliberately NOT F8E4M3FN (GAP-169). A rename would touch ~110 sites across every backend, cascade through the cuda_dtype! / ctor! macros into CudaStorageSlice / PinnedBuffer, and break 3 fuel-metal-backend sites that cannot be compiled on the primary dev box — all for reader clarity only. The interop token is already f8e4m3fn on the sk4 path (token_kind), and this dtype’s own token stays f8e4m3 for the checked-in .fkc.md contracts that author it (see the RESERVED_DTYPE_TOKENS note below). Revisit only when a second E4M3-family variant (e.g. F8E4M3FNUZ) actually lands — the witness above fires then.

§

F8E5M2

8-bit floating point with 5-bit exponent and 2-bit mantissa — the OCP-standard FP8 pair’s other half.

E4M3 (above) carries more mantissa and is the forward-pass format; E5M2 trades mantissa for exponent range and is the gradient format. Shipping one without the other leaves FP8 training unrepresentable, and fuel-cuda-backend’s cast table already documents six baracuda cast pairs it skips for want of this variant. Distinct from F8E6M2, which is a non-OCP block-scale type.

§

F6E2M3

6-bit float with 2 exponent bits and 3 mantissa bits (MX6 format).

§

F6E3M2

6-bit float with 3 exponent bits and 2 mantissa bits (MX6 format).

§

F4

4-bit float (MX4 format).

§

F8E8M0

8-bit float with 8 exponent bits and 0 mantissa bits.

§

F8E6M2

Unsigned 8-bit block-scale: 6 exponent bits, 2 mantissa bits, no sign (0+6+2=8). A finer-granularity sibling of F8E8M0 — trades 2 exponent bits for 2 mantissa — so a scale type, not a signed value dtype. (The “8-bit float, 6 exp, 2 mant” framing it shipped with in e275538c was a misread: 1+6+2=9 doesn’t fit a signed byte.)

§

Bool

Boolean truth value, one byte per element (0 = false, 1 = true).

The output dtype of the element-wise comparisons (eq/ne/lt/le/gt/ge) — GAP-168(c) / CireSnave’s 2026-08-12 ruling that Fuel “uses Bool where possible and casts to U8 when necessary”. Storage width equals u8 (KISS-CLASSIFY bool: “1-byte truth value; storage width equals u8”), so a backend may store it in a U8 buffer — but it is a DISTINCT logical dtype: neither an integer nor a floating-point value (is_int and is_float are both false), so using a mask AS A NUMBER (multiply/sum/accumulate) is rejected at build time and extracting a number requires an explicit .cast(U8).

Implementations§

Source§

impl DType

Source

pub const ALL: &'static [DType]

Every DType variant, in declaration order.

Completeness is REMINDED, not compiler-derived (GAP-248). _all_variants_witness below is a wildcard-free match, so adding a DType fails to compile THERE — a variant cannot be added without being dragged to this file. But extending THIS list in the same edit is then convention: nothing ties ALL to the witness, so a variant added to the match yet forgotten here would still compile. A hand-written const (not a derived iterator) because the anchor is a compile-time tripwire — the residual gap is that it reminds rather than derives. Measured complete at head (ALL = witness = enum = 18). The enforced version is a single-source macro declaring the enum and ALL together; see GAP-248.

Source§

impl DType

Source

pub fn as_str(&self) -> &'static str

Returns the string representation of this dtype.

Source

pub fn size_in_bytes(&self) -> usize

Returns the size used by each element in bytes.

Returns 0 for sub-byte types (F6E2M3, F6E3M2, F4).

Source

pub fn is_int(&self) -> bool

Returns true if this is an integer type (U8, I8, U32, I16, I32, I64).

Source

pub fn is_float(&self) -> bool

Returns true if this is a floating-point type.

Trait Implementations§

Source§

impl Clone for DType

Source§

fn clone(&self) -> DType

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for DType

Source§

impl Debug for DType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DType

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<DType, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for DType

Source§

impl FromStr for DType

Source§

type Err = DTypeParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<DType, <DType as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for DType

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DType

Source§

fn eq(&self, other: &DType) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for DType

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for DType

Source§

impl TryFrom<Dtype> for DType

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(value: Dtype) -> Result<DType, Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for DType

§

impl RefUnwindSafe for DType

§

impl Send for DType

§

impl Sync for DType

§

impl Unpin for DType

§

impl UnsafeUnpin for DType

§

impl UnwindSafe for DType

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Boilerplate for T
where T: Copy + Send + Sync + Debug + PartialEq + 'static,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more