Skip to main content

GgmlType

Enum GgmlType 

Source
#[non_exhaustive]
pub enum GgmlType {
Show 29 variants F32, F16, Q4_0, Q4_1, Q5_0, Q5_1, Q8_0, Q8_1, Q2_K, Q3_K, Q4_K, Q5_K, Q6_K, Q8_K, IQ2_XXS, IQ2_XS, IQ3_XXS, IQ1_S, IQ4_NL, IQ3_S, IQ2_S, IQ4_XS, I8, I16, I32, I64, F64, IQ1_M, BF16,
}
Expand description

A GGUF tensor element type, identified by its ggml_type integer ID. Each variant maps 1:1 to a [prism::tensor::dtype] shape.

Variant spellings deliberately mirror the GGML ggml_type enum and the prism::tensor::dtype type names (Q4_0, IQ4_NL, …) rather than Rust camel case, so the mapping reads 1:1 against the authoritative source.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

F32

GGML_TYPE_F32 (ID 0) → [F32].

§

F16

GGML_TYPE_F16 (ID 1) → [F16].

§

Q4_0

GGML_TYPE_Q4_0 (ID 2) → [Q4_0].

§

Q4_1

GGML_TYPE_Q4_1 (ID 3) → [Q4_1].

§

Q5_0

GGML_TYPE_Q5_0 (ID 6) → [Q5_0].

§

Q5_1

GGML_TYPE_Q5_1 (ID 7) → [Q5_1].

§

Q8_0

GGML_TYPE_Q8_0 (ID 8) → [Q8_0].

§

Q8_1

GGML_TYPE_Q8_1 (ID 9) → [Q8_1].

§

Q2_K

GGML_TYPE_Q2_K (ID 10) → [Q2_K].

§

Q3_K

GGML_TYPE_Q3_K (ID 11) → [Q3_K].

§

Q4_K

GGML_TYPE_Q4_K (ID 12) → [Q4_K].

§

Q5_K

GGML_TYPE_Q5_K (ID 13) → [Q5_K].

§

Q6_K

GGML_TYPE_Q6_K (ID 14) → [Q6_K].

§

Q8_K

GGML_TYPE_Q8_K (ID 15) → [Q8_K].

§

IQ2_XXS

GGML_TYPE_IQ2_XXS (ID 16) → [IQ2_XXS].

§

IQ2_XS

GGML_TYPE_IQ2_XS (ID 17) → [IQ2_XS].

§

IQ3_XXS

GGML_TYPE_IQ3_XXS (ID 18) → [IQ3_XXS].

§

IQ1_S

GGML_TYPE_IQ1_S (ID 19) → [IQ1_S].

§

IQ4_NL

GGML_TYPE_IQ4_NL (ID 20) → [IQ4_NL].

§

IQ3_S

GGML_TYPE_IQ3_S (ID 21) → [IQ3_S].

§

IQ2_S

GGML_TYPE_IQ2_S (ID 22) → [IQ2_S].

§

IQ4_XS

GGML_TYPE_IQ4_XS (ID 23) → [IQ4_XS].

§

I8

GGML_TYPE_I8 (ID 24) → [I8].

§

I16

GGML_TYPE_I16 (ID 25) → [I16].

§

I32

GGML_TYPE_I32 (ID 26) → [I32].

§

I64

GGML_TYPE_I64 (ID 27) → [I64].

§

F64

GGML_TYPE_F64 (ID 28) → [F64].

§

IQ1_M

GGML_TYPE_IQ1_M (ID 29) → [IQ1_M].

§

BF16

GGML_TYPE_BF16 (ID 30) → [BF16].

Implementations§

Source§

impl GgmlType

Source

pub const fn from_u32(id: u32) -> Option<Self>

Map a raw ggml_type integer ID to a GgmlType.

Returns None for IDs outside the GGUF v3 tensor-type set — including the deprecated IDs 4 and 5.

Source

pub const fn id(self) -> u32

The canonical ggml_type integer ID for this dtype.

Source

pub const fn block_bytes(self) -> usize

Bytes per block, sourced from the [prism::tensor::dtype] shape.

Source

pub const fn block_elems(self) -> usize

Elements per block, sourced from the [prism::tensor::dtype] shape.

Source

pub const fn tensor_data_bytes(self, num_elements: u64) -> Option<u64>

The total byte count for a tensor of num_elements of this dtype: (num_elements / BLOCK_ELEMS) * BLOCK_BYTES. Returns None if num_elements is not a whole multiple of BLOCK_ELEMS (a malformed quantized tensor) or on overflow.

Trait Implementations§

Source§

impl Clone for GgmlType

Source§

fn clone(&self) -> GgmlType

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 GgmlType

Source§

impl Debug for GgmlType

Source§

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

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

impl Eq for GgmlType

Source§

impl PartialEq for GgmlType

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for GgmlType

Auto Trait Implementations§

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> 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<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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.