Encode an FP32 vector into binary sign bits. # Panics `UnifiedQuantizedVector::new` fails only on outlier-count/bitmask mismatches. With `outlier_bitmask = 0` and an empty outliers slice this can never happen. The `expect` is therefore unreachable in practice.
(&self, v: &[f32])
| 58 | /// mismatches. With `outlier_bitmask = 0` and an empty outliers slice this |
| 59 | /// can never happen. The `expect` is therefore unreachable in practice. |
| 60 | fn encode(&self, v: &[f32]) -> Self::Quantized { |
| 61 | let bits = binary::encode(v); |
| 62 | let header = QuantHeader { |
| 63 | quant_mode: QuantMode::Binary as u16, |
| 64 | dim: self.dim as u16, |
| 65 | global_scale: 0.0, |
| 66 | residual_norm: 0.0, |
| 67 | dot_quantized: 0.0, |
| 68 | outlier_bitmask: 0, |
| 69 | reserved: [0; 8], |
| 70 | }; |
| 71 | let uqv = UnifiedQuantizedVector::new(header, &bits, &[]) |
| 72 | .expect("BinaryCodec::encode: layout construction is infallible (no outliers)"); |
| 73 | BinaryQuantized(uqv) |
| 74 | } |
| 75 | |
| 76 | /// Pre-encode the query to binary sign bits for fast Hamming comparison. |
| 77 | fn prepare_query(&self, q: &[f32]) -> Self::Query { |