Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix seg faults in CAGRA C++ unit tests #3552

Closed
wants to merge 6 commits into from
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
Loading