pub struct Quantizer<T: FloatBounds> { /* private fields */ }Expand description
Main quantization engine
Implementations§
Source§impl<T: FloatBounds> Quantizer<T>
impl<T: FloatBounds> Quantizer<T>
Sourcepub fn new(config: QuantizationConfig) -> Self
pub fn new(config: QuantizationConfig) -> Self
Create new quantizer
Sourcepub fn calibrate(
&mut self,
model_data: &HashMap<String, Array2<T>>,
) -> NeuralResult<()>
pub fn calibrate( &mut self, model_data: &HashMap<String, Array2<T>>, ) -> NeuralResult<()>
Calibrate quantization parameters using sample data
Sourcepub fn quantize_tensor(
&self,
tensor: &Array2<T>,
layer_name: &str,
) -> NeuralResult<QuantizedTensor>
pub fn quantize_tensor( &self, tensor: &Array2<T>, layer_name: &str, ) -> NeuralResult<QuantizedTensor>
Quantize a tensor
Sourcepub fn dequantize_tensor(
&self,
quantized: &QuantizedTensor,
) -> NeuralResult<Array2<T>>
pub fn dequantize_tensor( &self, quantized: &QuantizedTensor, ) -> NeuralResult<Array2<T>>
Dequantize a quantized tensor
Sourcepub fn quantize_weights(
&mut self,
weights: &HashMap<String, Array2<T>>,
) -> NeuralResult<HashMap<String, QuantizedTensor>>
pub fn quantize_weights( &mut self, weights: &HashMap<String, Array2<T>>, ) -> NeuralResult<HashMap<String, QuantizedTensor>>
Quantize model weights
Sourcepub fn fake_quantize_tensor(
&self,
tensor: &Array2<T>,
layer_name: &str,
) -> NeuralResult<Array2<T>>
pub fn fake_quantize_tensor( &self, tensor: &Array2<T>, layer_name: &str, ) -> NeuralResult<Array2<T>>
Apply fake quantization (for QAT)
Sourcepub fn compute_quantization_error(
&self,
original: &Array2<T>,
quantized: &QuantizedTensor,
) -> NeuralResult<QuantizationMetrics>
pub fn compute_quantization_error( &self, original: &Array2<T>, quantized: &QuantizedTensor, ) -> NeuralResult<QuantizationMetrics>
Compute quantization error
Sourcepub fn analyze_layer_sensitivity(
&mut self,
layers_data: &HashMap<String, Array2<T>>,
) -> NeuralResult<HashMap<String, f64>>
pub fn analyze_layer_sensitivity( &mut self, layers_data: &HashMap<String, Array2<T>>, ) -> NeuralResult<HashMap<String, f64>>
Analyze quantization sensitivity
Auto Trait Implementations§
impl<T> Freeze for Quantizer<T>
impl<T> RefUnwindSafe for Quantizer<T>where
T: RefUnwindSafe,
impl<T> Send for Quantizer<T>
impl<T> Sync for Quantizer<T>
impl<T> Unpin for Quantizer<T>where
T: Unpin,
impl<T> UnsafeUnpin for Quantizer<T>
impl<T> UnwindSafe for Quantizer<T>where
T: UnwindSafe + RefUnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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