pub struct LowRankPredictor { /* private fields */ }Expand description
Low-rank activation predictor using P·Q factorization.
This predictor uses a low-rank approximation to predict which neurons will be active before performing the full computation:
- P matrix [r, input_dim]: Compresses input to rank r
- Q matrix [hidden_dim, r]: Scores neurons based on compressed input
The prediction process:
- Compress input: z = P · x (r dimensions)
- Score neurons: scores = Q · z (hidden_dim dimensions)
- Select active neurons based on threshold or top-K
Implementations§
Source§impl LowRankPredictor
impl LowRankPredictor
Sourcepub fn new(
input_dim: usize,
hidden_dim: usize,
rank: usize,
config: SparsityConfig,
) -> Result<Self>
pub fn new( input_dim: usize, hidden_dim: usize, rank: usize, config: SparsityConfig, ) -> Result<Self>
Create a new low-rank predictor with random initialization.
Sourcepub fn from_matrices(
p_matrix: Array2<f32>,
q_matrix: Array2<f32>,
config: SparsityConfig,
) -> Result<Self>
pub fn from_matrices( p_matrix: Array2<f32>, q_matrix: Array2<f32>, config: SparsityConfig, ) -> Result<Self>
Create from existing matrices.
Get hidden dimension (number of neurons).
Trait Implementations§
Source§impl Clone for LowRankPredictor
impl Clone for LowRankPredictor
Source§fn clone(&self) -> LowRankPredictor
fn clone(&self) -> LowRankPredictor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LowRankPredictor
impl Debug for LowRankPredictor
Source§impl<'de> Deserialize<'de> for LowRankPredictor
impl<'de> Deserialize<'de> for LowRankPredictor
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Predictor for LowRankPredictor
impl Predictor for LowRankPredictor
Source§fn predict(&self, input: &[f32]) -> Result<Vec<usize>>
fn predict(&self, input: &[f32]) -> Result<Vec<usize>>
Predict active neurons for the given input. Read more
Source§fn calibrate(
&mut self,
samples: &[Vec<f32>],
activations: &[Vec<f32>],
) -> Result<()>
fn calibrate( &mut self, samples: &[Vec<f32>], activations: &[Vec<f32>], ) -> Result<()>
Calibrate the predictor using sample data. Read more
Source§fn stats(&self) -> PredictorStats
fn stats(&self) -> PredictorStats
Get predictor statistics.
Auto Trait Implementations§
impl Freeze for LowRankPredictor
impl RefUnwindSafe for LowRankPredictor
impl Send for LowRankPredictor
impl Sync for LowRankPredictor
impl Unpin for LowRankPredictor
impl UnwindSafe for LowRankPredictor
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