diff --git a/faiss/IndexAdditiveQuantizer.cpp b/faiss/IndexAdditiveQuantizer.cpp index a7ce3fce00..8dc6bcd167 100644 --- a/faiss/IndexAdditiveQuantizer.cpp +++ b/faiss/IndexAdditiveQuantizer.cpp @@ -527,7 +527,7 @@ void ResidualCoarseQuantizer::search( float* distances, idx_t* labels, const SearchParameters* params_in) const { - float beam_factor_2 = this->beam_factor; + float actual_beam_factor = this->beam_factor; if (params_in) { auto params = dynamic_cast( @@ -535,15 +535,15 @@ void ResidualCoarseQuantizer::search( FAISS_THROW_IF_NOT_MSG( params, "need SearchParametersResidualCoarseQuantizer parameters"); - beam_factor_2 = params->beam_factor; + actual_beam_factor = params->beam_factor; } - if (beam_factor_2 < 0) { + if (actual_beam_factor < 0) { AdditiveCoarseQuantizer::search(n, x, k, distances, labels); return; } - int beam_size = int(k * beam_factor_2); + int beam_size = int(k * actual_beam_factor); if (beam_size > ntotal) { beam_size = ntotal; } diff --git a/faiss/IndexIVFFastScan.cpp b/faiss/IndexIVFFastScan.cpp index 6c140c554f..f95ad354a7 100644 --- a/faiss/IndexIVFFastScan.cpp +++ b/faiss/IndexIVFFastScan.cpp @@ -56,17 +56,17 @@ IndexIVFFastScan::IndexIVFFastScan() { void IndexIVFFastScan::init_fastscan( size_t M, - size_t nbits_2, + size_t nbits_init, size_t nlist, MetricType /* metric */, int bbs_2) { FAISS_THROW_IF_NOT(bbs_2 % 32 == 0); - FAISS_THROW_IF_NOT(nbits_2 == 4); + FAISS_THROW_IF_NOT(nbits_init == 4); this->M = M; - this->nbits = nbits_2; + this->nbits = nbits_init; this->bbs = bbs_2; - ksub = (1 << nbits_2); + ksub = (1 << nbits_init); M2 = roundup(M, 2); code_size = M2 / 2; @@ -1028,11 +1028,11 @@ void IndexIVFFastScan::search_implem_12( // prepare the result handlers - int qbs2_2 = this->qbs2 ? this->qbs2 : 11; + int actual_qbs2 = this->qbs2 ? this->qbs2 : 11; std::vector tmp_bias; if (biases.get()) { - tmp_bias.resize(qbs2_2); + tmp_bias.resize(actual_qbs2); handler.dbias = tmp_bias.data(); } @@ -1045,7 +1045,7 @@ void IndexIVFFastScan::search_implem_12( int list_no = qcs[i0].list_no; size_t i1 = i0 + 1; - while (i1 < qcs.size() && i1 < i0 + qbs2_2) { + while (i1 < qcs.size() && i1 < i0 + actual_qbs2) { if (qcs[i1].list_no != list_no) { break; } @@ -1065,7 +1065,7 @@ void IndexIVFFastScan::search_implem_12( std::vector q_map(nc), lut_entries(nc); AlignedTable LUT(nc * dim12); memset(LUT.get(), -1, nc * dim12); - int qbs_2 = pq4_preferred_qbs(nc); + int qbs_for_list = pq4_preferred_qbs(nc); for (size_t i = i0; i < i1; i++) { const QC& qc = qcs[i]; @@ -1077,7 +1077,11 @@ void IndexIVFFastScan::search_implem_12( } } pq4_pack_LUT_qbs_q_map( - qbs_2, M2, dis_tables.get(), lut_entries.data(), LUT.get()); + qbs_for_list, + M2, + dis_tables.get(), + lut_entries.data(), + LUT.get()); // access the inverted list @@ -1093,7 +1097,13 @@ void IndexIVFFastScan::search_implem_12( handler.id_map = ids.get(); pq4_accumulate_loop_qbs( - qbs_2, list_size, M2, codes.get(), LUT.get(), handler, scaler); + qbs_for_list, + list_size, + M2, + codes.get(), + LUT.get(), + handler, + scaler); // prepare for next loop i0 = i1; } @@ -1231,11 +1241,11 @@ void IndexIVFFastScan::search_implem_14( is_max, impl, n, k, local_dis.data(), local_idx.data(), sel)); handler->begin(normalizers.get()); - int qbs2_2 = this->qbs2 ? this->qbs2 : 11; + int actual_qbs2 = this->qbs2 ? this->qbs2 : 11; std::vector tmp_bias; if (biases.get()) { - tmp_bias.resize(qbs2_2); + tmp_bias.resize(actual_qbs2); handler->dbias = tmp_bias.data(); } @@ -1255,7 +1265,7 @@ void IndexIVFFastScan::search_implem_14( std::vector q_map(nc), lut_entries(nc); AlignedTable LUT(nc * dim12); memset(LUT.get(), -1, nc * dim12); - int qbs_2 = pq4_preferred_qbs(nc); + int qbs_for_list = pq4_preferred_qbs(nc); for (size_t i = i0; i < i1; i++) { const QC& qc = qcs[i]; @@ -1268,7 +1278,11 @@ void IndexIVFFastScan::search_implem_14( } } pq4_pack_LUT_qbs_q_map( - qbs_2, M2, dis_tables.get(), lut_entries.data(), LUT.get()); + qbs_for_list, + M2, + dis_tables.get(), + lut_entries.data(), + LUT.get()); // access the inverted list @@ -1284,7 +1298,7 @@ void IndexIVFFastScan::search_implem_14( handler->id_map = ids.get(); pq4_accumulate_loop_qbs( - qbs_2, + qbs_for_list, list_size, M2, codes.get(), diff --git a/faiss/impl/NSG.cpp b/faiss/impl/NSG.cpp index 32ade32b71..8a6aaf9d90 100644 --- a/faiss/impl/NSG.cpp +++ b/faiss/impl/NSG.cpp @@ -301,8 +301,8 @@ void NSG::search_on_graph( retset[k].flag = false; int n = retset[k].id; - size_t nneigh_2 = graph.get_neighbors(n, neighbors.data()); - for (int m = 0; m < nneigh_2; m++) { + size_t nneigh_for_n = graph.get_neighbors(n, neighbors.data()); + for (int m = 0; m < nneigh_for_n; m++) { int id = neighbors[m]; if (id > ntotal || vt.get(id)) { continue;