pub struct MambaBlock<B: Backend> { /* private fields */ }Expand description
Mamba block for selective state space modeling.
Implementations§
Source§impl<B: Backend> MambaBlock<B>
impl<B: Backend> MambaBlock<B>
Sourcepub fn new(state_dim: usize, input_dim: usize, expand_ratio: usize) -> Self
pub fn new(state_dim: usize, input_dim: usize, expand_ratio: usize) -> Self
Create a new Mamba block.
Sourcepub fn from_config(config: &MambaConfig) -> Self
pub fn from_config(config: &MambaConfig) -> Self
Create a Mamba block from configuration.
Sourcepub fn expand_ratio(&self) -> usize
pub fn expand_ratio(&self) -> usize
Expansion ratio configured for the block.
Sourcepub fn forward(
&self,
input: Tensor<B, 3>,
params: &MambaParameters<B>,
state: Option<MambaState<B>>,
selective: bool,
) -> Result<(Tensor<B, 3>, MambaState<B>), &'static str>
pub fn forward( &self, input: Tensor<B, 3>, params: &MambaParameters<B>, state: Option<MambaState<B>>, selective: bool, ) -> Result<(Tensor<B, 3>, MambaState<B>), &'static str>
Forward pass for selective state space modeling.
§Shapes
input: [batch, seq_len, input_dim]state: [batch, state_dim]
Sourcepub fn forward_with_config(
&self,
input: Tensor<B, 3>,
params: &MambaParameters<B>,
state: Option<MambaState<B>>,
config: &MambaConfig,
) -> Result<(Tensor<B, 3>, MambaState<B>), &'static str>
pub fn forward_with_config( &self, input: Tensor<B, 3>, params: &MambaParameters<B>, state: Option<MambaState<B>>, config: &MambaConfig, ) -> Result<(Tensor<B, 3>, MambaState<B>), &'static str>
Forward pass using configuration for selective gating.
Auto Trait Implementations§
impl<B> Freeze for MambaBlock<B>
impl<B> RefUnwindSafe for MambaBlock<B>where
B: RefUnwindSafe,
impl<B> Send for MambaBlock<B>
impl<B> Sync for MambaBlock<B>
impl<B> Unpin for MambaBlock<B>where
B: Unpin,
impl<B> UnwindSafe for MambaBlock<B>where
B: UnwindSafe,
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