INNER CODE UNIT · Rust
type_size
rustformers/llm · crates/ggml/src/lib.rs:381
pub fn type_size(t: Type) -> usize {
unsafe { sys::ggml_type_size(t.into()) }
}
/// [type_size]/[blck_size] as float.
pub fn type_sizef(x: Type) -> f64 {
(unsafe { sys::ggml_type_sizef(x.into()) }) as f64
}
/// The size of a block for `t`. Only relevant for quantized types.
pub fn blck_size(t: Type) -> usize {
i32_to_usize(unsafe { sys::ggml_blck_size(t.into()) })
}
fn usize_to_i32(val: usize) -> i32 {
i32::try_from(val).unwrap()
}