Skip to main content

Module weights

Module weights 

Source
Expand description

Weight-loading abstraction.

Native targets typically mmap a .safetensors file and read tensors via byte-offset slices into the mapping. WASM has no mmap; weights arrive as Vec<u8> from fetch() or Response.arrayBuffer(). Both paths produce the same shape: a name → byte-slice lookup.

WeightLoader is the contract. Concrete implementations live in in-tree model loaders (mmap-based) and here (BytesWeightLoader — works on every target including WASM).

Structs§

BytesWeightLoader
Owned in-memory weight loader. The simplest, most portable variant — works on every target including WASM.

Traits§

WeightLoader
A name-keyed view of weight tensor bytes.