pub struct ChannelDither { /* private fields */ }Expand description
Per-channel dither pool seeded from (layer_id, channel_id) pairs.
Allocates one GoldenRatioDither per channel; each is independently
advanced, so channels cannot constructively interfere.
Implementations§
Source§impl ChannelDither
impl ChannelDither
Sourcepub fn new(layer_id: u32, n_channels: usize, bits: u32, eps: f32) -> Self
pub fn new(layer_id: u32, n_channels: usize, bits: u32, eps: f32) -> Self
Build a pool of n_channels dithers for layer_id / bits / eps.
Sourcepub fn quantize_batch(&mut self, activations: &mut [f32])
pub fn quantize_batch(&mut self, activations: &mut [f32])
Quantize activations in-place. Each column (channel dimension) uses
its own independent dither state.
activations is a flat row-major tensor of shape [batch, channels].
If the slice is not a multiple of n_channels, the remainder is
processed using channel 0.
Sourcepub fn n_channels(&self) -> usize
pub fn n_channels(&self) -> usize
Number of channels in this pool.
Auto Trait Implementations§
impl Freeze for ChannelDither
impl RefUnwindSafe for ChannelDither
impl Send for ChannelDither
impl Sync for ChannelDither
impl Unpin for ChannelDither
impl UnsafeUnpin for ChannelDither
impl UnwindSafe for ChannelDither
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