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: StringPath the checkpoint was mapped from (kept for error messages).
metadata: GgufMetadataParsed KV metadata.
tensors: HashMap<String, Tensor>Name -> tensor directory entry.
alignment: usizeByte alignment specified by the file (default 32).
tensor_data_offset: usizeAbsolute byte offset within the mapping where tensor payloads begin.
Implementations§
Source§impl GgufLayoutMmap
impl GgufLayoutMmap
Sourcepub fn tensor_bytes<'a>(&'a self, tensor: &Tensor) -> Result<&'a [u8]>
pub fn tensor_bytes<'a>(&'a self, tensor: &Tensor) -> Result<&'a [u8]>
Return a borrowed slice of the raw tensor payload bytes.
Sourcepub fn tensor_page_aligned_bytes<'a>(
&'a self,
tensor: &Tensor,
) -> Result<PageAlignedTensorBytes<'a>>
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.
Sourcepub fn directory_matches(&self, owned: &GgufLayout) -> bool
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).