Skip to content

Commit f88b1ac

Browse files
authored
fix: preprocess for halfvec (#140)
Signed-off-by: usamoi <[email protected]>
1 parent eda6f4e commit f88b1ac

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/vchordrq/index/am_options.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,16 @@ impl Opfamily {
172172
(B::Vecf32(x), PgDistanceKind::L2) => O::Vecf32(x.own()),
173173
(B::Vecf32(x), PgDistanceKind::Dot) => O::Vecf32(x.own()),
174174
(B::Vecf32(x), PgDistanceKind::Cos) => O::Vecf32(x.function_normalize()),
175-
(B::Vecf16(x), _) => O::Vecf16(x.own()),
175+
(B::Vecf16(x), PgDistanceKind::L2) => O::Vecf16(x.own()),
176+
(B::Vecf16(x), PgDistanceKind::Dot) => O::Vecf16(x.own()),
177+
(B::Vecf16(x), PgDistanceKind::Cos) => O::Vecf16(x.function_normalize()),
176178
}
177179
}
178180
pub fn process(self, x: Distance) -> f32 {
179181
match self.pg_distance {
180182
PgDistanceKind::Cos => f32::from(x) + 1.0f32,
181183
PgDistanceKind::L2 => f32::from(x).sqrt(),
182-
_ => f32::from(x),
184+
PgDistanceKind::Dot => x.into(),
183185
}
184186
}
185187
pub fn distance_kind(self) -> DistanceKind {

0 commit comments

Comments
 (0)