pub struct LlamaBlock {
pub norm1: RMSNorm,
pub attn: Attention,
pub norm2: RMSNorm,
pub mlp: MLP,
}Expand description
Pre-norm Llama decoder block: attention and MLP with residuals.
Fields§
§norm1: RMSNormNorm before attention (input_layernorm).
attn: AttentionSelf-attention.
norm2: RMSNormNorm before the MLP (post_attention_layernorm).
mlp: MLPFeed-forward.
Implementations§
Source§impl LlamaBlock
impl LlamaBlock
Sourcepub fn forward(
&self,
engine: &ComputeEngine,
input: &Tensor,
pos: usize,
cache: Option<&KVCacheLayer>,
mask: Option<&UnifiedTensor>,
) -> Tensor
pub fn forward( &self, engine: &ComputeEngine, input: &Tensor, pos: usize, cache: Option<&KVCacheLayer>, mask: Option<&UnifiedTensor>, ) -> Tensor
Runs the block on input ([batch, seq, hidden]); see
Attention::forward for pos, cache and mask.
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).
Auto Trait Implementations§
impl !RefUnwindSafe for LlamaBlock
impl !Send for LlamaBlock
impl !Sync for LlamaBlock
impl !UnwindSafe for LlamaBlock
impl Freeze for LlamaBlock
impl Unpin for LlamaBlock
impl UnsafeUnpin for LlamaBlock
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