ruvector_sparse_inference/sparse/
mod.rs1mod ffn;
6
7pub use ffn::SparseFfn;
8pub use crate::config::ActivationType;
9
10pub trait FeedForward: Send + Sync {
12 fn forward_sparse(&self, input: &[f32], active_neurons: &[usize]) -> crate::error::Result<Vec<f32>>;
14
15 fn forward_dense(&self, input: &[f32]) -> crate::error::Result<Vec<f32>>;
17}
18
19impl FeedForward for SparseFfn {
20 fn forward_sparse(&self, input: &[f32], active_neurons: &[usize]) -> crate::error::Result<Vec<f32>> {
21 SparseFfn::forward_sparse(self, input, active_neurons)
22 }
23
24 fn forward_dense(&self, input: &[f32]) -> crate::error::Result<Vec<f32>> {
25 SparseFfn::forward_dense(self, input)
26 }
27}
28
29pub struct SwiGLUFfn;
31
32impl SwiGLUFfn {
33 pub fn new(_input_dim: usize, _hidden_dim: usize) -> Self {
35 Self
36 }
37}
38
39impl FeedForward for SwiGLUFfn {
40 fn forward_sparse(&self, _input: &[f32], _active_neurons: &[usize]) -> crate::error::Result<Vec<f32>> {
41 unimplemented!("SwiGLUFfn not yet implemented")
42 }
43
44 fn forward_dense(&self, _input: &[f32]) -> crate::error::Result<Vec<f32>> {
45 unimplemented!("SwiGLUFfn not yet implemented")
46 }
47}