Skip to main content

Dtype

Trait Dtype 

Source
pub trait Dtype:
    Sealed
    + ConstrainedTypeShape
    + GroundedShape
    + for<'a> IntoBindingValue<'a>
    + Default
    + Copy
    + 'static {
    const NAME: &'static str;
    const BLOCK_BYTES: usize;
    const BLOCK_ELEMS: usize;
}
Expand description

Tensor element-type discipline.

A Dtype declares the canonical block layout of one tensor element (continuous types) or one quantization block (block-32 / block-256 quantized types). The trait is sealed per ADR-014; impls are confined to this module and reachable through TensorDtypeRegistry for container-format-realization enumeration per ADR-057.

Per ADR-017’s closure rule, two Dtype impls with identical BLOCK_BYTES content-address identically at the framework level. The Rust-type distinction is the application-level ergonomics surface (e.g., F16 vs BF16 are framework-equivalent 2-byte shapes but Rust-distinct dtypes carrying distinct floating-point interpretations at the container-format layer).

Required Associated Constants§

Source

const NAME: &'static str

Per-dtype name string (uppercase, GGML-convention spelling).

Source

const BLOCK_BYTES: usize

Bytes per block. For continuous element types this is the element byte count; for quantized types this is the block-bytes count (= the GGML block_q*_* sizeof).

Source

const BLOCK_ELEMS: usize

Elements per block. 1 for continuous types; 32 for legacy quantization; 256 for K-series quantization.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl Dtype for BF16

Source§

const NAME: &'static str = "BF16"

Source§

const BLOCK_BYTES: usize = F16_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for BOOL

Source§

const NAME: &'static str = "BOOL"

Source§

const BLOCK_BYTES: usize = BOOL_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for C64

Source§

const NAME: &'static str = "C64"

Source§

const BLOCK_BYTES: usize = C64_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for C128

Source§

const NAME: &'static str = "C128"

Source§

const BLOCK_BYTES: usize = C128_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F4_E2M1

Source§

const NAME: &'static str = "F4_E2M1"

Source§

const BLOCK_BYTES: usize = PACKED_NIBBLE_BYTES

Source§

const BLOCK_ELEMS: usize = PACKED_NIBBLE_ELEMS

Source§

impl Dtype for F8_E4M3

Source§

const NAME: &'static str = "F8_E4M3"

Source§

const BLOCK_BYTES: usize = F8_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F8_E4M3_FNUZ

Source§

const NAME: &'static str = "F8_E4M3_FNUZ"

Source§

const BLOCK_BYTES: usize = F8_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F8_E5M2

Source§

const NAME: &'static str = "F8_E5M2"

Source§

const BLOCK_BYTES: usize = F8_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F8_E5M2_FNUZ

Source§

const NAME: &'static str = "F8_E5M2_FNUZ"

Source§

const BLOCK_BYTES: usize = F8_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F16

Source§

const NAME: &'static str = "F16"

Source§

const BLOCK_BYTES: usize = F16_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F32

Source§

const NAME: &'static str = "F32"

Source§

const BLOCK_BYTES: usize = F32_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for F64

Source§

const NAME: &'static str = "F64"

Source§

const BLOCK_BYTES: usize = F64_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for I4

Source§

const NAME: &'static str = "I4"

Source§

const BLOCK_BYTES: usize = PACKED_NIBBLE_BYTES

Source§

const BLOCK_ELEMS: usize = PACKED_NIBBLE_ELEMS

Source§

impl Dtype for I8

Source§

const NAME: &'static str = "I8"

Source§

const BLOCK_BYTES: usize = INT8_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for I16

Source§

const NAME: &'static str = "I16"

Source§

const BLOCK_BYTES: usize = INT16_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for I32

Source§

const NAME: &'static str = "I32"

Source§

const BLOCK_BYTES: usize = INT32_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for I64

Source§

const NAME: &'static str = "I64"

Source§

const BLOCK_BYTES: usize = INT64_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for IQ1_M

Source§

const NAME: &'static str = "IQ1_M"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ1_S

Source§

const NAME: &'static str = "IQ1_S"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ2_S

Source§

const NAME: &'static str = "IQ2_S"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ2_XS

Source§

const NAME: &'static str = "IQ2_XS"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ2_XXS

Source§

const NAME: &'static str = "IQ2_XXS"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ3_S

Source§

const NAME: &'static str = "IQ3_S"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ3_XXS

Source§

const NAME: &'static str = "IQ3_XXS"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for IQ4_NL

Source§

const NAME: &'static str = "IQ4_NL"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK4_NL

Source§

impl Dtype for IQ4_XS

Source§

const NAME: &'static str = "IQ4_XS"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for Q2_K

Source§

const NAME: &'static str = "Q2_K"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for Q3_K

Source§

const NAME: &'static str = "Q3_K"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for Q4_0

Source§

const NAME: &'static str = "Q4_0"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK4_0

Source§

impl Dtype for Q4_1

Source§

const NAME: &'static str = "Q4_1"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK4_0

Source§

impl Dtype for Q4_K

Source§

const NAME: &'static str = "Q4_K"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for Q5_0

Source§

const NAME: &'static str = "Q5_0"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK5_0

Source§

impl Dtype for Q5_1

Source§

const NAME: &'static str = "Q5_1"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK5_0

Source§

impl Dtype for Q5_K

Source§

const NAME: &'static str = "Q5_K"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for Q6_K

Source§

const NAME: &'static str = "Q6_K"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for Q8_0

Source§

const NAME: &'static str = "Q8_0"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK8_0

Source§

impl Dtype for Q8_1

Source§

const NAME: &'static str = "Q8_1"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK8_0

Source§

impl Dtype for Q8_K

Source§

const NAME: &'static str = "Q8_K"

Source§

const BLOCK_BYTES: usize

Source§

const BLOCK_ELEMS: usize = QK_K

Source§

impl Dtype for U4

Source§

const NAME: &'static str = "U4"

Source§

const BLOCK_BYTES: usize = PACKED_NIBBLE_BYTES

Source§

const BLOCK_ELEMS: usize = PACKED_NIBBLE_ELEMS

Source§

impl Dtype for U8

Source§

const NAME: &'static str = "U8"

Source§

const BLOCK_BYTES: usize = INT8_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for U16

Source§

const NAME: &'static str = "U16"

Source§

const BLOCK_BYTES: usize = INT16_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for U32

Source§

const NAME: &'static str = "U32"

Source§

const BLOCK_BYTES: usize = INT32_BYTES

Source§

const BLOCK_ELEMS: usize = 1

Source§

impl Dtype for U64

Source§

const NAME: &'static str = "U64"

Source§

const BLOCK_BYTES: usize = INT64_BYTES

Source§

const BLOCK_ELEMS: usize = 1