Encode a single FP32 vector into an SQ8 `UnifiedQuantizedVector`. # Panics The `UnifiedQuantizedVector::new` call will only fail if the outlier count mismatches the bitmask, or an outlier dim_index ≥ 64. Neither condition can arise here: `outlier_bitmask` is 0 and `outliers` is empty. The `expect` is therefore unreachable in practice.
(&self, v: &[f32])
| 49 | /// condition can arise here: `outlier_bitmask` is 0 and `outliers` is |
| 50 | /// empty. The `expect` is therefore unreachable in practice. |
| 51 | fn encode(&self, v: &[f32]) -> Self::Quantized { |
| 52 | let codes = self.quantize(v); |
| 53 | let header = QuantHeader { |
| 54 | quant_mode: QuantMode::Sq8 as u16, |
| 55 | dim: self.dim as u16, |
| 56 | global_scale: 0.0, |
| 57 | residual_norm: 0.0, |
| 58 | dot_quantized: 0.0, |
| 59 | outlier_bitmask: 0, |
| 60 | reserved: [0; 8], |
| 61 | }; |
| 62 | let uqv = UnifiedQuantizedVector::new(header, &codes, &[]) |
| 63 | .expect("Sq8Codec::encode: layout construction is infallible (no outliers)"); |
| 64 | Sq8Quantized(uqv) |
| 65 | } |
| 66 | |
| 67 | /// Prepare the FP32 query for asymmetric distance computations. |
| 68 | /// |
no test coverage detected