MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / quantize_batch

Method quantize_batch

nodedb-vector/src/quantize/sq8.rs:107–113  ·  view source on GitHub ↗

Batch quantize: quantize all vectors into a contiguous byte array. Returns `dim * N` bytes laid out as `[v0_d0, v0_d1, ..., v1_d0, ...]`.

(&self, vectors: &[&[f32]])

Source from the content-addressed store, hash-verified

105 ///
106 /// Returns `dim * N` bytes laid out as `[v0_d0, v0_d1, ..., v1_d0, ...]`.
107 pub fn quantize_batch(&self, vectors: &[&[f32]]) -> Vec<u8> {
108 let mut out = Vec::with_capacity(self.dim * vectors.len());
109 for v in vectors {
110 out.extend(self.quantize(v));
111 }
112 out
113 }
114
115 /// Dequantize INT8 back to FP32 (lossy reconstruction).
116 pub fn dequantize(&self, quantized: &[u8]) -> Vec<f32> {

Callers 1

batch_quantizeFunction · 0.80

Calls 3

quantizeMethod · 0.80
lenMethod · 0.45
extendMethod · 0.45

Tested by 1

batch_quantizeFunction · 0.64