pub struct TurboQuantizedView<'a> { /* private fields */ }alloc only.Expand description
Zero-copy view over a TurboQuant packed binary.
Constructed from &[u8] with no allocation – suitable for embedded
targets where the binary is in flash/ROM. Note: predict does allocate
for the Hadamard rotation of the feature vector; use
predict_with_scratch for zero-alloc inference.
Implementations§
Source§impl<'a> TurboQuantizedView<'a>
impl<'a> TurboQuantizedView<'a>
Sourcepub fn from_bytes(bytes: &'a [u8]) -> Result<Self, FormatError>
pub fn from_bytes(bytes: &'a [u8]) -> Result<Self, FormatError>
Parse a TurboQuant binary from raw bytes.
Returns FormatError::Truncated
if the buffer is too short, has inconsistent length, or contains an
unknown quantization mode.
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.
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 padded_len(&self) -> usize
pub fn padded_len(&self) -> usize
Power-of-2 padded length used for FWHT.
Auto Trait Implementations§
impl<'a> Freeze for TurboQuantizedView<'a>
impl<'a> RefUnwindSafe for TurboQuantizedView<'a>
impl<'a> Send for TurboQuantizedView<'a>
impl<'a> Sync for TurboQuantizedView<'a>
impl<'a> Unpin for TurboQuantizedView<'a>
impl<'a> UnsafeUnpin for TurboQuantizedView<'a>
impl<'a> UnwindSafe for TurboQuantizedView<'a>
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