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

selector parameter for FastScan #3362

Closed
wants to merge 2 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
5 changes: 4 additions & 1 deletion faiss/IVFlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ void search_with_parameters(
const IndexIVF* index_ivf = dynamic_cast<const IndexIVF*>(index);
FAISS_THROW_IF_NOT(index_ivf);

index_ivf->quantizer->search(n, x, params->nprobe, Dq.data(), Iq.data());
SearchParameters* quantizer_params =
(params) ? params->quantizer_params : nullptr;
index_ivf->quantizer->search(
n, x, params->nprobe, Dq.data(), Iq.data(), quantizer_params);

if (nb_dis_ptr) {
*nb_dis_ptr = count_ndis(index_ivf, n * params->nprobe, Iq.data());
Expand Down
10 changes: 6 additions & 4 deletions faiss/IndexFastScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ void estimators_from_tables_generic(
dt += index.ksub;
}
}

if (C::cmp(heap_dis[0], dis)) {
heap_pop<C>(k, heap_dis, heap_ids);
heap_push<C>(k, heap_dis, heap_ids, dis, j);
Expand All @@ -203,17 +204,18 @@ ResultHandlerCompare<C, false>* make_knn_handler(
idx_t k,
size_t ntotal,
float* distances,
idx_t* labels) {
idx_t* labels,
const IDSelector* sel = nullptr) {
using HeapHC = HeapHandler<C, false>;
using ReservoirHC = ReservoirHandler<C, false>;
using SingleResultHC = SingleResultHandler<C, false>;

if (k == 1) {
return new SingleResultHC(n, ntotal, distances, labels);
return new SingleResultHC(n, ntotal, distances, labels, sel);
} else if (impl % 2 == 0) {
return new HeapHC(n, ntotal, k, distances, labels);
return new HeapHC(n, ntotal, k, distances, labels, sel);
} else /* if (impl % 2 == 1) */ {
return new ReservoirHC(n, ntotal, k, 2 * k, distances, labels);
return new ReservoirHC(n, ntotal, k, 2 * k, distances, labels, sel);
}
}

Expand Down
Loading