pub struct Quantizer { /* private fields */ }Expand description
High-level quantizer that combines configuration with optional calibration.
Implementations§
Source§impl Quantizer
impl Quantizer
Sourcepub fn new(config: QuantConfig) -> Self
pub fn new(config: QuantConfig) -> Self
Create a quantizer with the given configuration (no calibration).
Sourcepub fn with_calibration(
config: QuantConfig,
stats: HashMap<String, ActivationStats>,
) -> Self
pub fn with_calibration( config: QuantConfig, stats: HashMap<String, ActivationStats>, ) -> Self
Create a quantizer with configuration and pre-collected activation statistics.
Sourcepub fn quantize_tensor_with_name(
&self,
name: &str,
data: &[f32],
shape: Vec<usize>,
) -> Result<QuantizedTensorType>
pub fn quantize_tensor_with_name( &self, name: &str, data: &[f32], shape: Vec<usize>, ) -> Result<QuantizedTensorType>
Quantize a tensor with optional calibration.
Sourcepub fn quantize_tensor(
&self,
data: &[f32],
shape: Vec<usize>,
) -> Result<QuantizedTensorType>
pub fn quantize_tensor( &self, data: &[f32], shape: Vec<usize>, ) -> Result<QuantizedTensorType>
Quantize a tensor using the configured bit width and per-channel setting.
§Errors
Returns QuantizeError::InvalidTensor or QuantizeError::UnsupportedConfig.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Quantizer
impl RefUnwindSafe for Quantizer
impl Send for Quantizer
impl Sync for Quantizer
impl Unpin for Quantizer
impl UnsafeUnpin for Quantizer
impl UnwindSafe for Quantizer
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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