From 036393452912b7b1ef2448aec8e2ef0bb880bf43 Mon Sep 17 00:00:00 2001 From: Bhavik Sheth Date: Wed, 24 Jul 2024 21:16:47 -0700 Subject: [PATCH] Add warning on adding nbits to LSH index factory (#3687) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3687 We will write a warning if nbits is not specified while using index factory with LSH. The warning lets users know we will be using default d as nbits. Reviewed By: ramilbakhshyiev Differential Revision: D60187935 fbshipit-source-id: 0fa960eeed615d857add77fa131a4cfa1989809d --- faiss/index_factory.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/faiss/index_factory.cpp b/faiss/index_factory.cpp index bfd703653b..f2b30136aa 100644 --- a/faiss/index_factory.cpp +++ b/faiss/index_factory.cpp @@ -531,7 +531,15 @@ Index* parse_other_indexes( // IndexLSH if (match("LSH([0-9]*)(r?)(t?)")) { - int nbits = sm[1].length() > 0 ? std::stoi(sm[1].str()) : d; + int nbits; + if (sm[1].length() > 0) { + nbits = std::stoi(sm[1].str()); + } else { + nbits = d; + fprintf(stderr, + "WARN: nbits not specified, defaulting to d = %d\n", + d); + } bool rotate_data = sm[2].length() > 0; bool train_thresholds = sm[3].length() > 0; FAISS_THROW_IF_NOT(metric == METRIC_L2);