pub struct TensorInfo {
pub name: String,
pub dtype: String,
pub shape: Vec<usize>,
pub data_offsets: (u64, u64),
}Expand description
Metadata for a single tensor from a .safetensors header.
This is hf-fetch-model’s own type — lightweight, no quantization logic. Consumers (e.g., anamnesis) map this into their own richer types.
Fields§
§name: StringTensor name (e.g., "model.layers.0.self_attn.q_proj.weight").
dtype: StringElement dtype string as it appears in the header (e.g., "F8_E4M3", "BF16").
shape: Vec<usize>Tensor shape (e.g., [7168, 7168]).
data_offsets: (u64, u64)Byte offset range [start, end) within the data section of the file.
Implementations§
Source§impl TensorInfo
impl TensorInfo
Sourcepub fn num_elements(&self) -> u64
pub fn num_elements(&self) -> u64
Total number of elements (product of shape dimensions).
Returns 1 for a scalar (empty shape).
Sourcepub fn dtype_bytes(&self) -> Option<usize>
pub fn dtype_bytes(&self) -> Option<usize>
Bytes per element for the tensor’s dtype, if recognized.
Returns None for unknown dtype strings. Recognized dtypes:
| Dtype string | Bytes | Notes |
|---|---|---|
"BOOL" | 1 | |
"U8", "I8" | 1 | |
"F8_E4M3", "F8_E5M2" | 1 | FP8 variants |
"U16", "I16", "F16", "BF16" | 2 | |
"U32", "I32", "F32" | 4 | |
"U64", "I64", "F64" | 8 |
Trait Implementations§
Source§impl Clone for TensorInfo
impl Clone for TensorInfo
Source§fn clone(&self) -> TensorInfo
fn clone(&self) -> TensorInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TensorInfo
impl Debug for TensorInfo
Auto Trait Implementations§
impl Freeze for TensorInfo
impl RefUnwindSafe for TensorInfo
impl Send for TensorInfo
impl Sync for TensorInfo
impl Unpin for TensorInfo
impl UnsafeUnpin for TensorInfo
impl UnwindSafe for TensorInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more