pub struct PruningMask {
pub mask: Vec<bool>,
pub shape: Vec<usize>,
pub name: Option<String>,
}Expand description
Pruning mask indicating which weights are kept or pruned
The mask uses true to indicate weights that should be KEPT,
and false for weights that should be PRUNED (zeroed).
Fields§
§mask: Vec<bool>Boolean mask (true = keep, false = prune)
shape: Vec<usize>Shape of the mask (same as weight tensor)
name: Option<String>Optional layer name
Implementations§
Source§impl PruningMask
impl PruningMask
Sourcepub fn with_name(mask: Vec<bool>, shape: Vec<usize>, name: String) -> Self
pub fn with_name(mask: Vec<bool>, shape: Vec<usize>, name: String) -> Self
Creates a new pruning mask with a name
Sourcepub fn num_pruned(&self) -> usize
pub fn num_pruned(&self) -> usize
Returns the number of weights pruned
Sourcepub fn and(&self, other: &PruningMask) -> Result<PruningMask>
pub fn and(&self, other: &PruningMask) -> Result<PruningMask>
Combines two masks with logical AND (both must keep)
§Errors
Returns an error if mask sizes don’t match
Sourcepub fn or(&self, other: &PruningMask) -> Result<PruningMask>
pub fn or(&self, other: &PruningMask) -> Result<PruningMask>
Combines two masks with logical OR (either keeps)
§Errors
Returns an error if mask sizes don’t match
Sourcepub fn invert(&self) -> PruningMask
pub fn invert(&self) -> PruningMask
Inverts the mask
Sourcepub fn apply(&self, weights: &WeightTensor) -> Result<WeightTensor>
pub fn apply(&self, weights: &WeightTensor) -> Result<WeightTensor>
Applies the mask to a weight tensor, zeroing pruned weights
§Errors
Returns an error if sizes don’t match
Trait Implementations§
Source§impl Clone for PruningMask
impl Clone for PruningMask
Source§fn clone(&self) -> PruningMask
fn clone(&self) -> PruningMask
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 moreAuto Trait Implementations§
impl Freeze for PruningMask
impl RefUnwindSafe for PruningMask
impl Send for PruningMask
impl Sync for PruningMask
impl Unpin for PruningMask
impl UnsafeUnpin for PruningMask
impl UnwindSafe for PruningMask
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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