(&self, query: &[f32], candidate: &[u8])
| 167 | /// Asymmetric negative inner product: query (FP32) vs candidate (INT8). |
| 168 | #[inline] |
| 169 | pub fn asymmetric_ip(&self, query: &[f32], candidate: &[u8]) -> f32 { |
| 170 | debug_assert_eq!(query.len(), self.dim); |
| 171 | debug_assert_eq!(candidate.len(), self.dim); |
| 172 | let mut dot = 0.0f32; |
| 173 | for d in 0..self.dim { |
| 174 | let dequant = self.mins[d] + candidate[d] as f32 * self.scales[d]; |
| 175 | dot += query[d] * dequant; |
| 176 | } |
| 177 | -dot |
| 178 | } |
| 179 | |
| 180 | /// Dimension count. |
| 181 | pub fn dim(&self) -> usize { |