pub struct DynamicQuantizer { /* private fields */ }Expand description
Dynamic quantizer for automatic model compression
Implementations§
Source§impl DynamicQuantizer
impl DynamicQuantizer
Sourcepub fn with_strategy(self, strategy: QuantStrategy) -> Self
pub fn with_strategy(self, strategy: QuantStrategy) -> Self
Set quantization strategy
Sourcepub fn with_calibration_samples(self, samples: usize) -> Self
pub fn with_calibration_samples(self, samples: usize) -> Self
Set number of calibration samples
Sourcepub fn with_granularity(self, granularity: QuantizationGranularity) -> Self
pub fn with_granularity(self, granularity: QuantizationGranularity) -> Self
Set quantization granularity for INT8
Sourcepub fn classify_layer(&self, layer_name: &str) -> LayerSensitivity
pub fn classify_layer(&self, layer_name: &str) -> LayerSensitivity
Classify layer sensitivity based on name
Sourcepub fn quantize_weight(
&self,
weight: &Array2<f32>,
layer_name: &str,
) -> ModelResult<QuantizedWeightStorage>
pub fn quantize_weight( &self, weight: &Array2<f32>, layer_name: &str, ) -> ModelResult<QuantizedWeightStorage>
Quantize a single weight tensor
Sourcepub fn quantize_weights(
&self,
weights: &HashMap<String, Array2<f32>>,
) -> ModelResult<HashMap<String, QuantizedWeightStorage>>
pub fn quantize_weights( &self, weights: &HashMap<String, Array2<f32>>, ) -> ModelResult<HashMap<String, QuantizedWeightStorage>>
Quantize all weights in a model
Sourcepub fn calculate_memory_savings(
&self,
original_weights: &HashMap<String, Array2<f32>>,
quantized_weights: &HashMap<String, QuantizedWeightStorage>,
) -> QuantizationStats
pub fn calculate_memory_savings( &self, original_weights: &HashMap<String, Array2<f32>>, quantized_weights: &HashMap<String, QuantizedWeightStorage>, ) -> QuantizationStats
Calculate total memory savings
Sourcepub fn strategy(&self) -> QuantStrategy
pub fn strategy(&self) -> QuantStrategy
Get quantization strategy
Sourcepub fn calibration_samples(&self) -> usize
pub fn calibration_samples(&self) -> usize
Get calibration sample count
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DynamicQuantizer
impl RefUnwindSafe for DynamicQuantizer
impl Send for DynamicQuantizer
impl Sync for DynamicQuantizer
impl Unpin for DynamicQuantizer
impl UnwindSafe for DynamicQuantizer
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