pub struct DiagonalSSM { /* private fields */ }Available on crate feature
alloc only.Expand description
Non-selective diagonal SSM with fixed A, B, C, and step size.
This is the simplest SSM variant: all parameters are determined at construction time and do not adapt to input content. The hidden state is an N-dimensional vector that evolves through element-wise recurrence.
§When to Use
Use DiagonalSSM when:
- You want a simple temporal smoothing/memory layer
- Input-dependent selectivity is not needed
- You need a fast baseline to compare against
SelectiveSSM
§Example
use irithyll_core::ssm::diagonal::DiagonalSSM;
use irithyll_core::ssm::SSMLayer;
let mut ssm = DiagonalSSM::new(8, 0.1);
let output = ssm.forward(&[1.0]);
assert_eq!(output.len(), 1);Implementations§
Source§impl DiagonalSSM
impl DiagonalSSM
Sourcepub fn new(n_state: usize, delta: f64) -> Self
pub fn new(n_state: usize, delta: f64) -> Self
Create a new non-selective diagonal SSM.
Initializes A via the Mamba strategy (A_n = -(n+1)), sets B and C
to ones, D (skip connection) to zero, and pre-computes the discretized
matrices using ZOH.
§Arguments
n_state– number of hidden state dimensions (N)delta– fixed discretization step size (positive)
§Example
use irithyll_core::ssm::diagonal::DiagonalSSM;
let ssm = DiagonalSSM::new(16, 0.01);Sourcepub fn with_params(
n_state: usize,
delta: f64,
b: Vec<f64>,
c: Vec<f64>,
d_skip: f64,
) -> Self
pub fn with_params( n_state: usize, delta: f64, b: Vec<f64>, c: Vec<f64>, d_skip: f64, ) -> Self
Create a diagonal SSM with custom B, C vectors and skip connection.
§Arguments
n_state– number of hidden state dimensionsdelta– fixed discretization step sizeb– input projection vector (length n_state)c– output projection vector (length n_state)d_skip– skip connection weight
§Panics
Debug-asserts that b.len() == n_state and c.len() == n_state.
Sourcepub fn forward_scalar(&mut self, x: f64) -> f64
pub fn forward_scalar(&mut self, x: f64) -> f64
Process a single scalar input and return the scalar output.
Updates the hidden state via:
h_n = a_bar_n * h_n + b_bar_factor_n * b_n * x
y = C^T * h + D * xTrait Implementations§
Auto Trait Implementations§
impl Freeze for DiagonalSSM
impl RefUnwindSafe for DiagonalSSM
impl Send for DiagonalSSM
impl Sync for DiagonalSSM
impl Unpin for DiagonalSSM
impl UnsafeUnpin for DiagonalSSM
impl UnwindSafe for DiagonalSSM
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