pub struct LoraAdapter { /* private fields */ }Expand description
Manages multiple named LoraLayers that share a single LoraConfig.
Implementations§
Source§impl LoraAdapter
impl LoraAdapter
pub fn new(config: LoraConfig) -> Self
Sourcepub fn add_layer(
&mut self,
name: &str,
base_weight: Vec<Vec<f64>>,
) -> LoraResult<()>
pub fn add_layer( &mut self, name: &str, base_weight: Vec<Vec<f64>>, ) -> LoraResult<()>
Wrap base_weight in a new LoRA layer registered under name.
Sourcepub fn forward(
&mut self,
name: &str,
input: &[Vec<f64>],
) -> LoraResult<Vec<Vec<f64>>>
pub fn forward( &mut self, name: &str, input: &[Vec<f64>], ) -> LoraResult<Vec<Vec<f64>>>
Forward pass through the named layer.
Sourcepub fn merge_all(&mut self) -> LoraResult<()>
pub fn merge_all(&mut self) -> LoraResult<()>
Merge all layers.
Sourcepub fn unmerge_all(&mut self) -> LoraResult<()>
pub fn unmerge_all(&mut self) -> LoraResult<()>
Unmerge all layers.
Sourcepub fn total_trainable_params(&self) -> usize
pub fn total_trainable_params(&self) -> usize
Sum of trainable params across all layers.
Sourcepub fn summary(&self) -> LoraAdapterSummary
pub fn summary(&self) -> LoraAdapterSummary
Build a summary with per-layer statistics.
Auto Trait Implementations§
impl Freeze for LoraAdapter
impl RefUnwindSafe for LoraAdapter
impl Send for LoraAdapter
impl Sync for LoraAdapter
impl Unpin for LoraAdapter
impl UnsafeUnpin for LoraAdapter
impl UnwindSafe for LoraAdapter
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