Skip to main content

WeightLoader

Trait WeightLoader 

Source
pub trait WeightLoader {
    // Required methods
    fn tensor_bytes(&self, name: &str) -> Option<&[u8]>;
    fn names(&self) -> Vec<String>;
}
Expand description

A name-keyed view of weight tensor bytes.

Implementations promise that the returned slice stays valid for the lifetime of &self. On native, this is the mmap region; on WASM, it is the in-memory Vec<u8> owned by the loader.

Required Methods§

Source

fn tensor_bytes(&self, name: &str) -> Option<&[u8]>

Return the raw bytes for the tensor named name, or None if not present. Bytes are in the source file’s storage order (typically row-major, dtype-native).

Source

fn names(&self) -> Vec<String>

All tensor names (for iteration / discovery). Order is implementation-defined but stable for a given loader instance.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§