pub struct BinaryVector<const N: usize> {
pub data: Vec<u8, N>,
pub dim: usize,
pub threshold: i8,
}Expand description
Binary quantized vector - 1 bit per dimension
Fields§
§data: Vec<u8, N>Packed binary data (8 dimensions per byte)
dim: usizeOriginal dimension count
threshold: i8Threshold used for binarization
Implementations§
Source§impl<const N: usize> BinaryVector<N>
impl<const N: usize> BinaryVector<N>
Sourcepub fn from_i8(values: &[i8], threshold: i8) -> Result<Self>
pub fn from_i8(values: &[i8], threshold: i8) -> Result<Self>
Create binary vector from INT8 values Values >= threshold become 1, values < threshold become 0
Sourcepub fn from_f32(values: &[f32], threshold: f32) -> Result<Self>
pub fn from_f32(values: &[f32], threshold: f32) -> Result<Self>
Create binary vector from f32 values (for host-side quantization)
Sourcepub fn compression_ratio(&self) -> f32
pub fn compression_ratio(&self) -> f32
Memory savings compared to INT8
Trait Implementations§
Source§impl<const N: usize> Clone for BinaryVector<N>
impl<const N: usize> Clone for BinaryVector<N>
Source§fn clone(&self) -> BinaryVector<N>
fn clone(&self) -> BinaryVector<N>
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<const N: usize> Freeze for BinaryVector<N>
impl<const N: usize> RefUnwindSafe for BinaryVector<N>
impl<const N: usize> Send for BinaryVector<N>
impl<const N: usize> Sync for BinaryVector<N>
impl<const N: usize> Unpin for BinaryVector<N>
impl<const N: usize> UnwindSafe for BinaryVector<N>
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