pub struct TurboQuantized { /* private fields */ }alloc only.Expand description
Quantized weight vector (owned).
Created by quantize, quantize_weights, quantize_f32, or
quantize_i16. Supports inference via predict
and serialization via to_bytes.
Weights are stored in Hadamard-rotated space (H * D * w). During prediction,
the same rotation is applied to features so the dot product is preserved.
Implementations§
Source§impl TurboQuantized
impl TurboQuantized
Sourcepub fn predict(&self, features: &[f64]) -> f64
pub fn predict(&self, features: &[f64]) -> f64
Dot product of quantized weights with a feature vector.
Applies the same Hadamard rotation to features, then computes
the dot product with the quantized rotated weights over the full
padded length. Since HD is orthogonal, w . x == (HD*w) . (HD*x).
Sourcepub fn predict_with_scratch(&self, features: &[f64], scratch: &mut [f64]) -> f64
pub fn predict_with_scratch(&self, features: &[f64], scratch: &mut [f64]) -> f64
Predict using a caller-provided scratch buffer for the Hadamard rotation.
scratch must have length >= padded_len. This avoids allocation,
making it suitable for embedded inference loops.
Sourcepub fn dequantize(&self) -> Vec<f64>
pub fn dequantize(&self) -> Vec<f64>
Dequantize all weights back to f64 (approximate original space).
Unpacks all padded_len rotated values, then applies the inverse
Hadamard rotation to recover approximate original weights.
Sourcepub fn padded_len(&self) -> usize
pub fn padded_len(&self) -> usize
Power-of-2 padded length used for FWHT (needed for scratch allocation).
Sourcepub fn compression_ratio(&self) -> f64
pub fn compression_ratio(&self) -> f64
Compression ratio vs f64 (original bytes / packed bytes).
Auto Trait Implementations§
impl Freeze for TurboQuantized
impl RefUnwindSafe for TurboQuantized
impl Send for TurboQuantized
impl Sync for TurboQuantized
impl Unpin for TurboQuantized
impl UnsafeUnpin for TurboQuantized
impl UnwindSafe for TurboQuantized
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
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>
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>
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