Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: min.tian <[email protected]>
  • Loading branch information
alwayslove2013 committed Dec 27, 2024
1 parent f71becf commit 9cb0dba
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/comp/brute_force.cc
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,6 @@ BruteForce::AnnIterator(const DataSetPtr base_dataset, const DataSetPtr query_da
faiss::MetricType faiss_metric_type = result.value();
bool is_cosine = IsMetricType(metric_str, metric::COSINE);
auto larger_is_closer = faiss::is_similarity_metric(faiss_metric_type) || is_cosine;
std::unique_ptr<float[]> norms = is_cosine ? GetVecNorms<DataType>(base_dataset) : nullptr;
auto vec = std::vector<IndexNode::IteratorPtr>(nq, nullptr);

try {
Expand Down Expand Up @@ -814,6 +813,7 @@ BruteForce::AnnIterator(const DataSetPtr base_dataset, const DataSetPtr query_da
}
case faiss::METRIC_INNER_PRODUCT: {
if (is_cosine) {
std::unique_ptr<float[]> norms = GetVecNorms<DataType>(base_dataset);
if constexpr (std::is_same_v<DataType, knowhere::fp32>) {
auto copied_query = CopyAndNormalizeVecs(cur_query, 1, dim);
faiss::all_cosine(copied_query.get(), (const float*)xb, norms.get(), dim, 1, nb,
Expand Down

0 comments on commit 9cb0dba

Please sign in to comment.