Skip to main content

GgufLayout

Struct GgufLayout 

Source
pub struct GgufLayout {
    pub path: String,
    pub metadata: GgufMetadata,
    pub tensors: HashMap<String, Tensor>,
    pub alignment: usize,
    pub tensor_data_offset: usize,
    pub bytes: Vec<u8>,
}
Expand description

Fully-parsed GGUF checkpoint layout.

Owns the raw file bytes (loaded into a Vec<u8> by load_gguf) and all derived tensor directory + metadata information. Callers use the Tensor handles + GgufLayout::tensor_bytes to obtain raw byte slices for each weight.

Fields§

§path: String

Path the checkpoint was loaded from (kept for error messages).

§metadata: GgufMetadata

Parsed KV metadata.

§tensors: HashMap<String, Tensor>

Name -> tensor directory entry.

§alignment: usize

Byte alignment specified by the file (default 32).

§tensor_data_offset: usize

Absolute byte offset within bytes where tensor payloads begin.

§bytes: Vec<u8>

Full file contents. Tensor payloads live at bytes[tensor.absolute_offset ..].

Implementations§

Source§

impl GgufLayout

Source

pub fn tensor_bytes<'a>(&'a self, tensor: &Tensor) -> Result<&'a [u8]>

Return a borrowed slice of the raw tensor payload bytes.

Source

pub fn tensor(&self, name: &str) -> Result<&Tensor>

Lookup a tensor by exact name.

Source

pub fn find_tensors_with_suffix<'a>(&'a self, suffix: &str) -> Vec<&'a Tensor>

Find all tensors whose name ends with the given suffix. Useful for locating per-block MoE tensors like ffn_gate_exps.weight.

Trait Implementations§

Source§

impl Debug for GgufLayout

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for GgufLayout

§

impl Freeze for GgufLayout

§

impl Move for GgufLayout

§

impl RefUnwindSafe for GgufLayout

§

impl Send for GgufLayout
where RawVecInner: Send, RawTable<(String, String)>: Send, RawTable<(String, u64)>: Send, RawTable<(String, i64)>: Send, RawTable<(String, f32)>: Send, RawTable<(String, f64)>: Send, RawTable<(String, Tensor)>: Send,

§

impl Sync for GgufLayout
where RawVecInner: Sync, RawTable<(String, String)>: Sync, RawTable<(String, u64)>: Sync, RawTable<(String, i64)>: Sync, RawTable<(String, f32)>: Sync, RawTable<(String, f64)>: Sync, RawTable<(String, Tensor)>: Sync,

§

impl Unpin for GgufLayout
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for GgufLayout

§

impl UnwindSafe for GgufLayout

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.