Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion faiss/IndexHNSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ void IndexHNSWCagra::search(

std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<idx_t> distrib(0, this->ntotal);
std::uniform_int_distribution<idx_t> distrib(0, this->ntotal - 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this->ntotal be 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only if vectors have not been added to the index, then calling search is invalid in any case.


for (idx_t j = 0; j < num_base_level_search_entrypoints; j++) {
auto idx = distrib(gen);
Expand Down
6 changes: 3 additions & 3 deletions faiss/gpu/test/TestGpuIndexCagra.cu
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void queryTest(faiss::MetricType metric, double expected_recall) {
recall_score.view(),
test_dis_mds_opt,
ref_dis_mds_opt);
ASSERT_TRUE(*recall_score.data_handle() > expected_recall);
ASSERT_GT(*recall_score.data_handle(), expected_recall);
}
}

Expand Down Expand Up @@ -330,7 +330,7 @@ void copyToTest(
recall_score.view(),
copy_ref_dis_mds_opt,
ref_dis_mds_opt);
ASSERT_TRUE(*recall_score.data_handle() > expected_recall);
ASSERT_GT(*recall_score.data_handle(), expected_recall);
}
}

Expand Down Expand Up @@ -452,7 +452,7 @@ void copyFromTest(faiss::MetricType metric, double expected_recall) {
recall_score.view(),
copy_test_dis_mds_opt,
test_dis_mds_opt);
ASSERT_TRUE(*recall_score.data_handle() > expected_recall);
ASSERT_GT(*recall_score.data_handle(), expected_recall);
}
}

Expand Down