pub struct QuantizationParams {
pub min: Vec<f32>,
pub max: Vec<f32>,
pub dim: usize,
}Expand description
Per-dimension quantization calibration: lower and upper bounds.
Fields§
§min: Vec<f32>§max: Vec<f32>§dim: usizeImplementations§
Source§impl QuantizationParams
impl QuantizationParams
Sourcepub fn fit(vectors: &[Vec<f32>]) -> Result<Self>
pub fn fit(vectors: &[Vec<f32>]) -> Result<Self>
Fit calibration bounds from a sample of vectors. If a dimension is constant (min == max) a tiny epsilon range is used so the value quantizes to a stable code rather than dividing by zero.
Sourcepub fn quantize(&self, vector: &[f32]) -> Vec<i8>
pub fn quantize(&self, vector: &[f32]) -> Vec<i8>
Quantize a single f32 vector into Int8 codes.
Sourcepub fn dequantize(&self, codes: &[i8]) -> Vec<f32>
pub fn dequantize(&self, codes: &[i8]) -> Vec<f32>
Dequantize an Int8 code back to an approximate f32 vector.
Trait Implementations§
Source§impl Clone for QuantizationParams
impl Clone for QuantizationParams
Source§fn clone(&self) -> QuantizationParams
fn clone(&self) -> QuantizationParams
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for QuantizationParams
impl RefUnwindSafe for QuantizationParams
impl Send for QuantizationParams
impl Sync for QuantizationParams
impl Unpin for QuantizationParams
impl UnsafeUnpin for QuantizationParams
impl UnwindSafe for QuantizationParams
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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