From 9be22c3e5e3bb5b8e5bd6e646910dfec5357b8e0 Mon Sep 17 00:00:00 2001 From: Mengdi Lin Date: Thu, 5 Dec 2024 12:42:40 -0800 Subject: [PATCH 1/2] Improve naming due to codemod (#4064) Summary: Apply matthijs' comments on better naming in D52582914 Reviewed By: junjieqi Differential Revision: D66822957 --- faiss/IndexFastScan.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/faiss/IndexFastScan.cpp b/faiss/IndexFastScan.cpp index 8d10ecc9d9..b18d15bc17 100644 --- a/faiss/IndexFastScan.cpp +++ b/faiss/IndexFastScan.cpp @@ -33,22 +33,22 @@ inline size_t roundup(size_t a, size_t b) { void IndexFastScan::init_fastscan( int d, - size_t M_2, - size_t nbits_2, + size_t M_init, + size_t nbits_init, MetricType metric, int bbs) { - FAISS_THROW_IF_NOT(nbits_2 == 4); + FAISS_THROW_IF_NOT(nbits_init == 4); FAISS_THROW_IF_NOT(bbs % 32 == 0); this->d = d; - this->M = M_2; - this->nbits = nbits_2; + this->M = M_init; + this->nbits = nbits_init; this->metric_type = metric; this->bbs = bbs; - ksub = (1 << nbits_2); + ksub = (1 << nbits_init); - code_size = (M_2 * nbits_2 + 7) / 8; + code_size = (M_init * nbits_init + 7) / 8; ntotal = ntotal2 = 0; - M2 = roundup(M_2, 2); + M2 = roundup(M_init, 2); is_trained = false; } From f1a85d43f10371297104af7cc5e6311655b5212b Mon Sep 17 00:00:00 2001 From: Mengdi Lin Date: Thu, 5 Dec 2024 12:42:40 -0800 Subject: [PATCH 2/2] Improve naming due to codemod Summary: improve neighbors_2 naming from codemod Reviewed By: junjieqi Differential Revision: D66823395 --- faiss/impl/HNSW.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/faiss/impl/HNSW.cpp b/faiss/impl/HNSW.cpp index 4f1ac7c3ba..642bf7c532 100644 --- a/faiss/impl/HNSW.cpp +++ b/faiss/impl/HNSW.cpp @@ -493,17 +493,17 @@ void HNSW::add_links_starting_from( ::faiss::shrink_neighbor_list(ptdis, link_targets, M, keep_max_size_level0); - std::vector neighbors_2; - neighbors_2.reserve(link_targets.size()); + std::vector neighbors_to_add; + neighbors_to_add.reserve(link_targets.size()); while (!link_targets.empty()) { storage_idx_t other_id = link_targets.top().id; add_link(*this, ptdis, pt_id, other_id, level, keep_max_size_level0); - neighbors_2.push_back(other_id); + neighbors_to_add.push_back(other_id); link_targets.pop(); } omp_unset_lock(&locks[pt_id]); - for (storage_idx_t other_id : neighbors_2) { + for (storage_idx_t other_id : neighbors_to_add) { omp_set_lock(&locks[other_id]); add_link(*this, ptdis, other_id, pt_id, level, keep_max_size_level0); omp_unset_lock(&locks[other_id]);