pub struct Tensor {
pub name: String,
pub dims: Vec<usize>,
pub dtype: DType,
pub ggml_type: u32,
pub n_elements: usize,
pub byte_len: usize,
pub relative_offset: usize,
pub absolute_offset: usize,
}Expand description
A single tensor’s directory entry: name, shape, dtype, and offsets.
This is a metadata-only descriptor — it owns no weight data. Use
GgufLayout::tensor_bytes
to obtain the raw payload.
Fields§
§name: StringFull tensor name as stored in the GGUF directory.
dims: Vec<usize>Shape dimensions (GGML innermost-first order).
dtype: DTypeParsed dtype enum.
ggml_type: u32Raw ggml_type code (preserved for round-tripping).
n_elements: usizeTotal number of elements (product of dims).
byte_len: usizeTotal byte length of the tensor payload.
relative_offset: usizeOffset relative to the tensor data region start.
absolute_offset: usizeAbsolute byte offset within the file buffer.
Implementations§
Source§impl Tensor
impl Tensor
Sourcepub fn read_f32_values(&self, bytes: &[u8]) -> Result<Vec<f32>>
pub fn read_f32_values(&self, bytes: &[u8]) -> Result<Vec<f32>>
Read the raw tensor bytes as little-endian f32 values.
Only valid for DType::F32 tensors; returns an error otherwise.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Tensor
impl Freeze for Tensor
impl Move for Tensor
impl RefUnwindSafe for Tensor
impl Send for Tensorwhere
RawVecInner: Send,
impl Sync for Tensorwhere
RawVecInner: Sync,
impl Unpin for Tensor
impl UnsafeUnpin for Tensorwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<usize>: UnsafeUnpin,
impl UnwindSafe for Tensorwhere
RawVecInner: UnwindSafe,
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