pub struct ModelQuantizer { /* private fields */ }Expand description
Model quantizer
Implementations§
Source§impl ModelQuantizer
impl ModelQuantizer
Sourcepub fn new(config: QuantizationConfig, device: Device) -> Result<Self>
pub fn new(config: QuantizationConfig, device: Device) -> Result<Self>
Create a new model quantizer
Sourcepub fn config(&self) -> &QuantizationConfig
pub fn config(&self) -> &QuantizationConfig
Get quantization config
Sourcepub fn start_calibration(&mut self)
pub fn start_calibration(&mut self)
Start calibration phase
Sourcepub fn finish_calibration(&mut self)
pub fn finish_calibration(&mut self)
Finish calibration phase
Sourcepub fn calibrate(
&mut self,
layer_name: &str,
tensor: &Tensor,
) -> CandleResult<()>
pub fn calibrate( &mut self, layer_name: &str, tensor: &Tensor, ) -> CandleResult<()>
Calibrate with a tensor (collect statistics)
Sourcepub fn quantize_tensor(
&self,
tensor: &Tensor,
layer_name: &str,
precision: QuantizationPrecision,
) -> CandleResult<QuantizedTensor>
pub fn quantize_tensor( &self, tensor: &Tensor, layer_name: &str, precision: QuantizationPrecision, ) -> CandleResult<QuantizedTensor>
Quantize a tensor to specified precision
Sourcepub fn get_stats_summary(&self) -> HashMap<String, QuantizationStatsSummary>
pub fn get_stats_summary(&self) -> HashMap<String, QuantizationStatsSummary>
Get quantization statistics summary
Sourcepub fn estimate_memory_savings(
&self,
original_model_size_mb: f32,
) -> QuantizationMemoryAnalysis
pub fn estimate_memory_savings( &self, original_model_size_mb: f32, ) -> QuantizationMemoryAnalysis
Estimate memory savings from quantization
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ModelQuantizer
impl RefUnwindSafe for ModelQuantizer
impl Send for ModelQuantizer
impl Sync for ModelQuantizer
impl Unpin for ModelQuantizer
impl UnsafeUnpin for ModelQuantizer
impl UnwindSafe for ModelQuantizer
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