pub struct Weights { /* private fields */ }Expand description
Container for all loaded RWKV7 model weights.
Implementations§
Source§impl Weights
impl Weights
Sourcepub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn load<P: AsRef<Path>>(path: P) -> Result<Self>
Load weights from a safetensors file.
This function:
- Reads and parses the JSON header to extract tensor metadata
- Loads each tensor’s FP32 data into memory
- Returns a Weights container for efficient tensor lookup
Sourcepub fn get(&self, name: &str) -> Option<&WeightTensor>
pub fn get(&self, name: &str) -> Option<&WeightTensor>
Get a tensor by name, returning None if not found.
Sourcepub fn require(&self, name: &str) -> Result<&WeightTensor>
pub fn require(&self, name: &str) -> Result<&WeightTensor>
Get a tensor by name, or return an error if not found.
Sourcepub fn tensor_names(&self) -> impl Iterator<Item = &str>
pub fn tensor_names(&self) -> impl Iterator<Item = &str>
Iterate over all tensor names.
Sourcepub fn print_summary(&self)
pub fn print_summary(&self)
Print summary of all loaded tensors (for debugging).
Auto Trait Implementations§
impl Freeze for Weights
impl RefUnwindSafe for Weights
impl Send for Weights
impl Sync for Weights
impl Unpin for Weights
impl UnwindSafe for Weights
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> 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