Skip to content

Commit

Permalink
Optimize NormalizeVec
Browse files Browse the repository at this point in the history
Signed-off-by: Cai Yudong <[email protected]>
  • Loading branch information
cydrain committed Aug 30, 2024
1 parent 613f06f commit 7764c6a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ NormalizeVec(DataType* x, int32_t d) {
} else if constexpr (std::is_same_v<DataType, bf16>) {
norm_l2_sqr = faiss::bf16_vec_norm_L2sqr(x, d);
} else {
LOG_KNOWHERE_ERROR_ << "unknown datatype";
for (int32_t i = 0; i < d; i++) {
norm_l2_sqr += (float)x[i] * (float)x[i];
}
}

if (norm_l2_sqr > 0 && std::abs(1.0f - norm_l2_sqr) > FloatAccuracy) {
Expand Down

0 comments on commit 7764c6a

Please sign in to comment.