Skip to main content

DiagonalSSM

Struct DiagonalSSM 

Source
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

Source

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);
Source

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 dimensions
  • delta – fixed discretization step size
  • b – 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.

Source

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 * x
Source

pub fn n_state(&self) -> usize

Get the number of state dimensions.

Source

pub fn log_a(&self) -> &[f64]

Get the log-A parameters (for inspection/serialization).

Source

pub fn delta(&self) -> f64

Get the fixed step size.

Trait Implementations§

Source§

impl SSMLayer for DiagonalSSM

Source§

fn forward(&mut self, input: &[f64]) -> Vec<f64>

Process one input timestep and return the output vector. Read more
Source§

fn state(&self) -> &[f64]

Get a reference to the current hidden state.
Source§

fn output_dim(&self) -> usize

Output dimension of this SSM layer.
Source§

fn reset(&mut self)

Reset hidden state to zeros, as if no data has been seen.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.