pub trait WeightSource: Send + Sync {
// Required methods
fn tensor_names(&self) -> Vec<String>;
fn load_tensor(&mut self, name: &str) -> ModelResult<Vec<f32>>;
fn contains(&self, name: &str) -> bool;
fn total_bytes_estimate(&self) -> u64;
}Expand description
A streaming/incremental source of model weight tensors.
Implementations must be Send + Sync so that they can be passed across
thread boundaries when used with multi-threaded inference runtimes.
The primary operations are:
tensor_names: enumerate all available tensor keys.load_tensor: load and dequantize one tensor toVec<f32>.contains: membership check without loading.total_bytes_estimate: rough file-size hint for progress reporting.
Required Methods§
Sourcefn tensor_names(&self) -> Vec<String>
fn tensor_names(&self) -> Vec<String>
Return the names of all tensors available in this source.
Sourcefn load_tensor(&mut self, name: &str) -> ModelResult<Vec<f32>>
fn load_tensor(&mut self, name: &str) -> ModelResult<Vec<f32>>
Load and dequantize the tensor identified by name, returning a flat Vec<f32>.
§Errors
Returns ModelError if the tensor is not found, the file cannot be read,
or dequantization fails.
Sourcefn contains(&self, name: &str) -> bool
fn contains(&self, name: &str) -> bool
Return true if the source contains a tensor with the given name.
Sourcefn total_bytes_estimate(&self) -> u64
fn total_bytes_estimate(&self) -> u64
Return a rough estimate of the total number of bytes occupied by all tensor data in the underlying file (used for progress reporting).