pub struct Linear {
pub weight: Tensor,
pub lora: Option<LoRAAdapter>,
}Expand description
Bias-free linear layer y = x @ weight with an optional LoRA adapter.
Fields§
§weight: TensorWeight [in, out] (already transposed from the PyTorch [out, in]).
lora: Option<LoRAAdapter>Optional low-rank adapter added to the output.
Implementations§
Source§impl Linear
impl Linear
Sourcepub fn with_lora(weight: Tensor, lora: LoRAAdapter) -> Self
pub fn with_lora(weight: Tensor, lora: LoRAAdapter) -> Self
A layer with a LoRA adapter.
Sourcepub fn forward(&self, engine: &ComputeEngine, x: &Tensor) -> Tensor
pub fn forward(&self, engine: &ComputeEngine, x: &Tensor) -> Tensor
Projects [tokens, in] or [batch, seq, in] to the same leading
shape with out features.
Sourcepub fn named_params(&self, prefix: &str) -> HashMap<String, Tensor>
pub fn named_params(&self, prefix: &str) -> HashMap<String, Tensor>
Parameters keyed by Hugging Face-style names under prefix.
Sourcepub fn lora_params(&self) -> Vec<Tensor>
pub fn lora_params(&self) -> Vec<Tensor>
Only the LoRA adapter tensors (what LoRA fine-tuning updates).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Linear
impl !Send for Linear
impl !Sync for Linear
impl !UnwindSafe for Linear
impl Freeze for Linear
impl Unpin for Linear
impl UnsafeUnpin for Linear
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,
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