pub struct QuantizedVector {
pub data: Vec<u8>,
pub min: f32,
pub max: f32,
}Expand description
A quantized vector using 8-bit scalar quantization.
Each f32 value is mapped to a u8 (0-255) using min/max scaling.
The original value can be reconstructed as: value = (data[i] / 255.0) * (max - min) + min
Fields§
§data: Vec<u8>Quantized data (1 byte per dimension instead of 4).
min: f32Minimum value in the original vector.
max: f32Maximum value in the original vector.
Implementations§
Source§impl QuantizedVector
impl QuantizedVector
Sourcepub fn to_f32(&self) -> Vec<f32>
pub fn to_f32(&self) -> Vec<f32>
Reconstructs the original f32 vector from quantized data.
Note: This is a lossy operation. The reconstructed values are approximations.
Sourcepub fn memory_size(&self) -> usize
pub fn memory_size(&self) -> usize
Returns the memory size in bytes.
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self>
pub fn from_bytes(bytes: &[u8]) -> Result<Self>
Trait Implementations§
Source§impl Clone for QuantizedVector
impl Clone for QuantizedVector
Source§fn clone(&self) -> QuantizedVector
fn clone(&self) -> QuantizedVector
Returns a duplicate of the value. Read more
1.0.0 · 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 QuantizedVector
impl RefUnwindSafe for QuantizedVector
impl Send for QuantizedVector
impl Sync for QuantizedVector
impl Unpin for QuantizedVector
impl UnwindSafe for QuantizedVector
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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