pub struct Int4EmbeddingsView<'a> {
pub scales: &'a [u8],
pub codes: &'a [u8],
pub n: usize,
pub dim: usize,
pub blocks: usize,
}Expand description
Decoded view over an int4 embeddings payload. Slices borrow the input bytes (no copy); accessors decode scales/codes on demand.
Fields§
§scales: &'a [u8]f16 LE group scales, n * blocks of them, row-major.
codes: &'a [u8]packed nibble codes, n * dim/2 bytes.
n: usize§dim: usize§blocks: usizeImplementations§
Source§impl<'a> Int4EmbeddingsView<'a>
impl<'a> Int4EmbeddingsView<'a>
pub fn parse(bytes: &'a [u8], n: usize, dim: usize) -> Result<Self>
Sourcepub fn group_scale(&self, i: usize, g: usize) -> f32
pub fn group_scale(&self, i: usize, g: usize) -> f32
Read the f16 group scale g of row i as f32.
Sourcepub fn row_codes(&self, i: usize) -> &'a [u8] ⓘ
pub fn row_codes(&self, i: usize) -> &'a [u8] ⓘ
Borrow row i’s packed nibble bytes (dim/2 of them).
Sourcepub fn row_scales_f32(&self, i: usize) -> Vec<f32>
pub fn row_scales_f32(&self, i: usize) -> Vec<f32>
Decode row i’s f16 group scales into a fresh Vec<f32> (one per
64-dim block). One-shot use only (the packed ANN store materializes
every row once); the per-candidate rerank uses row_scales_into.
Sourcepub fn row_scales_into(&self, i: usize, out: &mut [f32])
pub fn row_scales_into(&self, i: usize, out: &mut [f32])
Decode row i’s f16 group scales into a caller-owned buffer of
exactly blocks f32s, so a rerank over thousands of candidates
reuses one allocation instead of one Vec per row.
§Panics
When out.len() != self.blocks.
Auto Trait Implementations§
impl<'a> Freeze for Int4EmbeddingsView<'a>
impl<'a> RefUnwindSafe for Int4EmbeddingsView<'a>
impl<'a> Send for Int4EmbeddingsView<'a>
impl<'a> Sync for Int4EmbeddingsView<'a>
impl<'a> Unpin for Int4EmbeddingsView<'a>
impl<'a> UnsafeUnpin for Int4EmbeddingsView<'a>
impl<'a> UnwindSafe for Int4EmbeddingsView<'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
Mutably borrows from an owned value. Read more