pub struct DiscretizationCache { /* private fields */ }Expand description
Cache for discretized SSM matrices to avoid recomputation
Implementations§
Source§impl DiscretizationCache
impl DiscretizationCache
Sourcepub fn new(num_layers: usize, hidden_dim: usize, state_dim: usize) -> Self
pub fn new(num_layers: usize, hidden_dim: usize, state_dim: usize) -> Self
Create a new discretization cache
Sourcepub fn update(
&mut self,
layer_idx: usize,
delta: f32,
a_bar: Array2<f32>,
b_bar: Array2<f32>,
)
pub fn update( &mut self, layer_idx: usize, delta: f32, a_bar: Array2<f32>, b_bar: Array2<f32>, )
Update the cache with new discretized matrices
Sourcepub fn get(
&self,
layer_idx: usize,
delta: f32,
) -> Option<(&Array2<f32>, &Array2<f32>)>
pub fn get( &self, layer_idx: usize, delta: f32, ) -> Option<(&Array2<f32>, &Array2<f32>)>
Get cached discretized matrices if valid
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Invalidate the cache
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DiscretizationCache
impl RefUnwindSafe for DiscretizationCache
impl Send for DiscretizationCache
impl Sync for DiscretizationCache
impl Unpin for DiscretizationCache
impl UnwindSafe for DiscretizationCache
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