pub struct StructuredPruner { /* private fields */ }Expand description
Structured pruner for neural network layers
Implementations§
Source§impl StructuredPruner
impl StructuredPruner
Sourcepub fn new(config: PruningConfig) -> CoreResult<Self>
pub fn new(config: PruningConfig) -> CoreResult<Self>
Create a new structured pruner
Sourcepub fn prune(
&mut self,
name: &str,
weights: &Array2<f32>,
) -> CoreResult<PruningMask>
pub fn prune( &mut self, name: &str, weights: &Array2<f32>, ) -> CoreResult<PruningMask>
Prune a 2D weight matrix
Sourcepub fn prune_progressive(
&mut self,
name: &str,
weights: &Array2<f32>,
) -> CoreResult<Vec<PruningMask>>
pub fn prune_progressive( &mut self, name: &str, weights: &Array2<f32>, ) -> CoreResult<Vec<PruningMask>>
Progressive pruning over multiple iterations
Sourcepub fn get_mask(&self, name: &str) -> Option<&PruningMask>
pub fn get_mask(&self, name: &str) -> Option<&PruningMask>
Get mask for a layer
Sourcepub fn masks(&self) -> &HashMap<String, PruningMask>
pub fn masks(&self) -> &HashMap<String, PruningMask>
Get all masks
Sourcepub fn global_sparsity(&self) -> f32
pub fn global_sparsity(&self) -> f32
Compute global sparsity across all pruned layers
Sourcepub fn global_compression_ratio(&self) -> f32
pub fn global_compression_ratio(&self) -> f32
Get compression ratio across all layers
Auto Trait Implementations§
impl Freeze for StructuredPruner
impl RefUnwindSafe for StructuredPruner
impl Send for StructuredPruner
impl Sync for StructuredPruner
impl Unpin for StructuredPruner
impl UnwindSafe for StructuredPruner
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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