pub struct MultiScaleRetention { /* private fields */ }Expand description
Multi-Scale Retention (MSR) Module
Implements retention mechanism with multiple heads, each operating at different scales
Implementations§
Source§impl MultiScaleRetention
impl MultiScaleRetention
Sourcepub fn new(config: RetNetConfig) -> CoreResult<Self>
pub fn new(config: RetNetConfig) -> CoreResult<Self>
Create a new multi-scale retention module
Sourcepub fn step(
&self,
input: &Array1<f32>,
state: &mut Array3<f32>,
) -> CoreResult<Array1<f32>>
pub fn step( &self, input: &Array1<f32>, state: &mut Array3<f32>, ) -> CoreResult<Array1<f32>>
Recurrent forward step (O(1) inference)
Updates retention state and computes output State: (num_heads, head_dim, head_dim)
Sourcepub fn forward_sequence(&self, input: &Array2<f32>) -> CoreResult<Array2<f32>>
pub fn forward_sequence(&self, input: &Array2<f32>) -> CoreResult<Array2<f32>>
Parallel forward for sequence (training mode)
Input shape: (seq_len, hidden_dim) Output shape: (seq_len, hidden_dim)
Sourcepub fn reset_state(&self) -> Array3<f32>
pub fn reset_state(&self) -> Array3<f32>
Reset retention state
Sourcepub fn num_parameters(&self) -> usize
pub fn num_parameters(&self) -> usize
Get number of parameters
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MultiScaleRetention
impl RefUnwindSafe for MultiScaleRetention
impl Send for MultiScaleRetention
impl Sync for MultiScaleRetention
impl Unpin for MultiScaleRetention
impl UnwindSafe for MultiScaleRetention
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> 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