Skip to content

Commit dbdd63b

Browse files
mengdilinfacebook-github-bot
authored andcommitted
assign_index should default to null (facebookresearch#3855)
Summary: Pull Request resolved: facebookresearch#3855 Laser clients are calling RCQ search with a query size of 1 and the bulk of the overhead came from IndexFlat add/search. With a small query size, using IndexFlatL2 does lots of unnecessary copies to the IndexFlatL2. By default, we should fall back to https://fburl.com/code/jpt236mz branch unless the client overrides `assign_index` with `assign_index_factory`. Reviewed By: bshethmeta Differential Revision: D62644305 fbshipit-source-id: 2434e2b238968304dc5b346637f8ca956e6bd548
1 parent 52ce3f5 commit dbdd63b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

faiss/impl/residual_quantizer_encode_steps.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,6 @@ void refine_beam_mp(
664664
std::unique_ptr<Index> assign_index;
665665
if (rq.assign_index_factory) {
666666
assign_index.reset((*rq.assign_index_factory)(rq.d));
667-
} else {
668-
assign_index.reset(new IndexFlatL2(rq.d));
669667
}
670668

671669
// main loop
@@ -701,7 +699,9 @@ void refine_beam_mp(
701699
assign_index.get(),
702700
rq.approx_topk_mode);
703701

704-
assign_index->reset();
702+
if (assign_index != nullptr) {
703+
assign_index->reset();
704+
}
705705

706706
std::swap(codes_ptr, new_codes_ptr);
707707
std::swap(residuals_ptr, new_residuals_ptr);

0 commit comments

Comments
 (0)