Skip to main content

Pruner

Trait Pruner 

Source
pub trait Pruner {
    // Required methods
    fn prune(
        &self,
        weights: &Array2<f64>,
    ) -> TrainResult<(Array2<f64>, PruningMask)>;
    fn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>;
    fn apply_mask(
        &self,
        weights: &Array2<f64>,
        mask: &PruningMask,
    ) -> TrainResult<Array2<f64>>;
    fn config(&self) -> &PruningConfig;
    fn update_ratio(&mut self, iteration: usize);
}
Expand description

Trait for pruning strategies.

Required Methods§

Source

fn prune( &self, weights: &Array2<f64>, ) -> TrainResult<(Array2<f64>, PruningMask)>

Prune weights and return pruned weights and mask.

Source

fn generate_mask(&self, weights: &Array2<f64>) -> TrainResult<PruningMask>

Generate pruning mask without modifying weights.

Source

fn apply_mask( &self, weights: &Array2<f64>, mask: &PruningMask, ) -> TrainResult<Array2<f64>>

Apply existing mask to weights.

Source

fn config(&self) -> &PruningConfig

Get pruning configuration.

Source

fn update_ratio(&mut self, iteration: usize)

Update pruning ratio for iterative pruning.

Implementors§