Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions faiss/gpu/test/TestGpuIndexCagra.cu
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void copyToTest(
faiss::MetricType metric,
double expected_recall,
bool base_level_only) {
for (int tries = 0; tries < 5; ++tries) {
for (int tries = 0; tries < 100; ++tries) {
Options opt;
if (opt.buildAlgo == faiss::gpu::graph_build_algo::NN_DESCENT &&
metric == faiss::METRIC_INNER_PRODUCT) {
Expand Down Expand Up @@ -330,6 +330,9 @@ void copyToTest(
recall_score.view(),
copy_ref_dis_mds_opt,
ref_dis_mds_opt);
std::cout << "run: " << tries
<< ", recall_score: " << *recall_score.data_handle()
<< std::endl;
ASSERT_TRUE(*recall_score.data_handle() > expected_recall);
}
}
Expand Down Expand Up @@ -468,7 +471,7 @@ int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);

// just run with a fixed test seed
faiss::gpu::setTestSeed(100);
faiss::gpu::setTestSeed(101);

return RUN_ALL_TESTS();
}