Skip to main content

GgufLayoutMmap

Struct GgufLayoutMmap 

Source
pub struct GgufLayoutMmap {
    pub path: String,
    pub metadata: GgufMetadata,
    pub tensors: HashMap<String, Tensor>,
    pub alignment: usize,
    pub tensor_data_offset: usize,
    /* private fields */
}
Expand description

GGUF layout backed by a read-only file mapping instead of an owned Vec<u8>.

Header, KV metadata, and the tensor directory are identical to GgufLayout. Tensor payloads are borrowed from the mapping.

Fields§

§path: String

Path the checkpoint was mapped 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 the mapping where tensor payloads begin.

Implementations§

Source§

impl GgufLayoutMmap

Source

pub fn len(&self) -> usize

Length of the mapped file in bytes.

Source

pub fn is_empty(&self) -> bool

Whether the mapping is empty.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Borrowed view of the entire mapped file.

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 tensor_page_aligned_bytes<'a>( &'a self, tensor: &Tensor, ) -> Result<PageAlignedTensorBytes<'a>>

Page-aligned byte range covering tensor, suitable for a later CUDA host-register in another crate. Does not register anything here.

Source

pub fn directory_matches(&self, owned: &GgufLayout) -> bool

Compare directory metadata with an owned GgufLayout of the same file.

Checks alignment, tensor-data offset, architecture, and every tensor’s name, shape, dtype, packed length, and offsets. Does not compare payload bytes (callers that need that should use Self::tensor_bytes against GgufLayout::tensor_bytes).

Trait Implementations§

Source§

impl Debug for GgufLayoutMmap

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for GgufLayoutMmap

§

impl Freeze for GgufLayoutMmap

§

impl Move for GgufLayoutMmap

§

impl RefUnwindSafe for GgufLayoutMmap

§

impl Send for GgufLayoutMmap
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, MmapInner: Send,

§

impl Sync for GgufLayoutMmap
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, MmapInner: Sync,

§

impl Unpin for GgufLayoutMmap
where *const u8 is !null: Unpin, *mut c_void: Unpin,

§

impl UnsafeUnpin for GgufLayoutMmap

§

impl UnwindSafe for GgufLayoutMmap

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.