pub trait ModelSource {
// Required methods
fn config(&self) -> &ModelConfig;
fn config_mut(&mut self) -> &mut ModelConfig;
fn architecture(&self) -> Architecture;
fn load_tensor(&self, name: &str) -> ModelResult<Tensor>;
fn try_load_tensor(&self, name: &str) -> Option<Tensor>;
}Expand description
Trait for model weight sources (GGUF, ONNX, SafeTensors).
Implementors provide tensor loading and config access. The shared model assembly functions use this trait to load weights from any supported format.
Required Methods§
Sourcefn config(&self) -> &ModelConfig
fn config(&self) -> &ModelConfig
Get parsed model configuration.
Sourcefn config_mut(&mut self) -> &mut ModelConfig
fn config_mut(&mut self) -> &mut ModelConfig
Get mutable reference to model configuration.
Sourcefn architecture(&self) -> Architecture
fn architecture(&self) -> Architecture
Get detected architecture.
Sourcefn load_tensor(&self, name: &str) -> ModelResult<Tensor>
fn load_tensor(&self, name: &str) -> ModelResult<Tensor>
Load a tensor by internal name (e.g., “blk.0.attn_q.weight”).
Sourcefn try_load_tensor(&self, name: &str) -> Option<Tensor>
fn try_load_tensor(&self, name: &str) -> Option<Tensor>
Try to load a tensor (None if not found).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".