pub struct Sq8Vector {
pub min: f32,
pub max: f32,
pub bytes: Vec<u8>,
}Expand description
SQ8-quantized vector: every dimension stored as one byte plus a shared (min, max) reconstruction frame.
Reconstruction: x_i ≈ min + (byte_i / 255) * (max - min).
Quantization error bound (per element): (max - min) / 510
— half the quantization step (max - min) / 255 thanks to
round-to-nearest.
Fields§
§min: f32§max: f32§bytes: Vec<u8>Implementations§
Source§impl Sq8Vector
impl Sq8Vector
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialise to the standalone byte format. Always succeeds.
Panics if the dimension exceeds u32::MAX — but DataType::Vector
already caps dim at u32 at the type level, so this is a no-op
invariant on real inputs.
Sourcepub fn from_bytes(input: &[u8]) -> Result<Self, QuantizeError>
pub fn from_bytes(input: &[u8]) -> Result<Self, QuantizeError>
Parse the standalone byte format. Strict — body length must equal the declared dim exactly (no extra trailing bytes).
Sourcepub const fn encoded_size_for(dim: usize) -> usize
pub const fn encoded_size_for(dim: usize) -> usize
Bytes encoded by to_bytes for an instance of dim dimensions.
Handy for buffer pre-sizing on the segment writer side.
Trait Implementations§
impl StructuralPartialEq for Sq8Vector
Auto Trait Implementations§
impl Freeze for Sq8Vector
impl RefUnwindSafe for Sq8Vector
impl Send for Sq8Vector
impl Sync for Sq8Vector
impl Unpin for Sq8Vector
impl UnsafeUnpin for Sq8Vector
impl UnwindSafe for Sq8Vector
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