pub enum SparsityPattern {
Unstructured,
NM {
n: usize,
m: usize,
},
Block {
height: usize,
width: usize,
},
Row,
Column,
}Expand description
Sparsity pattern constraints.
Defines the structural constraints on which weights can be pruned. Different patterns offer different trade-offs between flexibility and hardware acceleration.
Variants§
Unstructured
No structural constraint - any element can be pruned.
Maximum flexibility but requires sparse hardware for speedup.
NM
N:M sparsity - in every M consecutive elements, exactly N are non-zero.
§Hardware Support
- 2:4 sparsity: NVIDIA Ampere (A100, RTX 30xx) - 2x speedup
- 4:8 sparsity: Future hardware
Block
Block sparsity - entire blocks of size (height, width) are pruned together.
Useful for structured pruning where entire neurons or filters are removed.
Row
Row sparsity - entire rows (output channels) pruned.
Equivalent to pruning entire output neurons.
Column
Column sparsity - entire columns (input channels) pruned.
Equivalent to removing input features.
Implementations§
Trait Implementations§
Source§impl Clone for SparsityPattern
impl Clone for SparsityPattern
Source§fn clone(&self) -> SparsityPattern
fn clone(&self) -> SparsityPattern
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 SparsityPattern
impl Debug for SparsityPattern
Source§impl Default for SparsityPattern
impl Default for SparsityPattern
Source§impl PartialEq for SparsityPattern
impl PartialEq for SparsityPattern
impl Copy for SparsityPattern
impl Eq for SparsityPattern
impl StructuralPartialEq for SparsityPattern
Auto Trait Implementations§
impl Freeze for SparsityPattern
impl RefUnwindSafe for SparsityPattern
impl Send for SparsityPattern
impl Sync for SparsityPattern
impl Unpin for SparsityPattern
impl UnsafeUnpin for SparsityPattern
impl UnwindSafe for SparsityPattern
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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