pub struct ModelWeights {
pub tensors: HashMap<String, Tensor>,
pub metadata: WeightMetadata,
pub gguf_config: Option<GGUFModelConfig>,
pub gguf_tokenizer: Option<GGUFTokenizer>,
pub quantized_tensors: HashMap<String, Arc<QMatMul>>,
}Expand description
Model weights container
Fields§
§tensors: HashMap<String, Tensor>Tensor weights by name (F32 dequantized, for compatibility)
metadata: WeightMetadataMetadata
gguf_config: Option<GGUFModelConfig>GGUF-specific config (populated when loading from GGUF)
gguf_tokenizer: Option<GGUFTokenizer>GGUF tokenizer data (populated when loading from GGUF)
quantized_tensors: HashMap<String, Arc<QMatMul>>Quantized weights (QMatMul) for efficient inference
Implementations§
Source§impl ModelWeights
impl ModelWeights
Sourcepub fn new(tensors: HashMap<String, Tensor>, metadata: WeightMetadata) -> Self
pub fn new(tensors: HashMap<String, Tensor>, metadata: WeightMetadata) -> Self
Create new model weights
Sourcepub fn with_gguf_config(
tensors: HashMap<String, Tensor>,
metadata: WeightMetadata,
gguf_config: GGUFModelConfig,
) -> Self
pub fn with_gguf_config( tensors: HashMap<String, Tensor>, metadata: WeightMetadata, gguf_config: GGUFModelConfig, ) -> Self
Create new model weights with GGUF config
Sourcepub fn with_gguf_config_and_tokenizer(
tensors: HashMap<String, Tensor>,
metadata: WeightMetadata,
gguf_config: GGUFModelConfig,
gguf_tokenizer: Option<GGUFTokenizer>,
) -> Self
pub fn with_gguf_config_and_tokenizer( tensors: HashMap<String, Tensor>, metadata: WeightMetadata, gguf_config: GGUFModelConfig, gguf_tokenizer: Option<GGUFTokenizer>, ) -> Self
Create new model weights with GGUF config and tokenizer
Sourcepub fn with_quantized(
tensors: HashMap<String, Tensor>,
metadata: WeightMetadata,
gguf_config: GGUFModelConfig,
gguf_tokenizer: Option<GGUFTokenizer>,
quantized_tensors: HashMap<String, Arc<QMatMul>>,
) -> Self
pub fn with_quantized( tensors: HashMap<String, Tensor>, metadata: WeightMetadata, gguf_config: GGUFModelConfig, gguf_tokenizer: Option<GGUFTokenizer>, quantized_tensors: HashMap<String, Arc<QMatMul>>, ) -> Self
Create new model weights with GGUF config, tokenizer, and quantized tensors
Sourcepub fn get_quantized(&self, name: &str) -> Option<Arc<QMatMul>>
pub fn get_quantized(&self, name: &str) -> Option<Arc<QMatMul>>
Get quantized tensor (QMatMul) by name
Sourcepub fn has_quantized(&self, name: &str) -> bool
pub fn has_quantized(&self, name: &str) -> bool
Check if a tensor has a quantized version
Sourcepub fn tensor_names(&self) -> Vec<&String>
pub fn tensor_names(&self) -> Vec<&String>
Get all tensor names
Trait Implementations§
Source§impl Clone for ModelWeights
impl Clone for ModelWeights
Source§fn clone(&self) -> ModelWeights
fn clone(&self) -> ModelWeights
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ModelWeights
impl !UnwindSafe for ModelWeights
impl Freeze for ModelWeights
impl Send for ModelWeights
impl Sync for ModelWeights
impl Unpin for ModelWeights
impl UnsafeUnpin for ModelWeights
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more