pub struct GradientCompressor;Expand description
Gradient compression utilities
Implementations§
Source§impl GradientCompressor
impl GradientCompressor
Sourcepub fn top_k(
values: &[f32],
shape: Vec<usize>,
k: usize,
) -> Result<SparseGradient, GradientError>
pub fn top_k( values: &[f32], shape: Vec<usize>, k: usize, ) -> Result<SparseGradient, GradientError>
Compress gradient using top-k sparsification
Sourcepub fn threshold(
values: &[f32],
shape: Vec<usize>,
threshold: f32,
) -> SparseGradient
pub fn threshold( values: &[f32], shape: Vec<usize>, threshold: f32, ) -> SparseGradient
Compress gradient using threshold-based sparsification
Sourcepub fn quantize(values: &[f32], shape: Vec<usize>) -> QuantizedGradient
pub fn quantize(values: &[f32], shape: Vec<usize>) -> QuantizedGradient
Compress gradient using quantization
Sourcepub fn random_sparsification(
values: &[f32],
shape: Vec<usize>,
keep_ratio: f32,
) -> Result<SparseGradient, GradientError>
pub fn random_sparsification( values: &[f32], shape: Vec<usize>, keep_ratio: f32, ) -> Result<SparseGradient, GradientError>
Compress gradient using random sparsification
Auto Trait Implementations§
impl Freeze for GradientCompressor
impl RefUnwindSafe for GradientCompressor
impl Send for GradientCompressor
impl Sync for GradientCompressor
impl Unpin for GradientCompressor
impl UnwindSafe for GradientCompressor
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