faiss 0.6.5 → 0.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/ext/faiss/extconf.rb +1 -0
  4. data/ext/faiss/index.cpp +42 -0
  5. data/lib/faiss/version.rb +1 -1
  6. data/vendor/faiss/faiss/IVFlib.cpp +48 -51
  7. data/vendor/faiss/faiss/IVFlib.h +6 -2
  8. data/vendor/faiss/faiss/Index.cpp +2 -2
  9. data/vendor/faiss/faiss/Index.h +3 -3
  10. data/vendor/faiss/faiss/IndexBinary.cpp +2 -2
  11. data/vendor/faiss/faiss/IndexBinary.h +2 -2
  12. data/vendor/faiss/faiss/IndexBinaryFlat.cpp +1 -0
  13. data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +6 -3
  14. data/vendor/faiss/faiss/IndexBinaryIVF.cpp +6 -11
  15. data/vendor/faiss/faiss/IndexFastScan.cpp +1 -1
  16. data/vendor/faiss/faiss/IndexFlat.cpp +1 -1
  17. data/vendor/faiss/faiss/IndexHNSW.cpp +12 -10
  18. data/vendor/faiss/faiss/IndexHNSW.h +2 -5
  19. data/vendor/faiss/faiss/IndexIDMap.cpp +17 -4
  20. data/vendor/faiss/faiss/IndexIDMap.h +10 -5
  21. data/vendor/faiss/faiss/IndexIVF.cpp +68 -37
  22. data/vendor/faiss/faiss/IndexIVF.h +37 -1
  23. data/vendor/faiss/faiss/IndexIVFFastScan.cpp +5 -15
  24. data/vendor/faiss/faiss/IndexIVFFlat.h +6 -6
  25. data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +1 -1
  26. data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +28 -44
  27. data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +2 -11
  28. data/vendor/faiss/faiss/IndexIVFRaBitQSSD.cpp +1694 -0
  29. data/vendor/faiss/faiss/IndexIVFRaBitQSSD.h +288 -0
  30. data/vendor/faiss/faiss/IndexIVFSQFastScan.cpp +7 -2
  31. data/vendor/faiss/faiss/IndexNNDescent.cpp +21 -0
  32. data/vendor/faiss/faiss/IndexRaBitQ.cpp +189 -41
  33. data/vendor/faiss/faiss/IndexRaBitQ.h +5 -0
  34. data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +1 -1
  35. data/vendor/faiss/faiss/IndexRaBitQFastScan.h +2 -2
  36. data/vendor/faiss/faiss/SuperKMeans.cpp +2 -2
  37. data/vendor/faiss/faiss/VectorTransform.cpp +156 -9
  38. data/vendor/faiss/faiss/VectorTransform.h +24 -1
  39. data/vendor/faiss/faiss/factory_tools.cpp +19 -1
  40. data/vendor/faiss/faiss/gpu/Dataset.h +66 -14
  41. data/vendor/faiss/faiss/gpu/GpuIndexBinaryCagra.h +8 -2
  42. data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +8 -2
  43. data/vendor/faiss/faiss/gpu/impl/optimal_kmeans/GpuOptimalKMeans.h +184 -0
  44. data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +12 -4
  45. data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +6 -5
  46. data/vendor/faiss/faiss/gpu_metal/GpuIndexFlat.h +1 -1
  47. data/vendor/faiss/faiss/gpu_metal/MetalCloner.h +1 -1
  48. data/vendor/faiss/faiss/gpu_metal/MetalDistance.h +1 -1
  49. data/vendor/faiss/faiss/gpu_metal/MetalFlatKernels.h +1 -1
  50. data/vendor/faiss/faiss/gpu_metal/MetalIndex.h +1 -1
  51. data/vendor/faiss/faiss/gpu_metal/MetalIndexBinaryFlat.h +1 -1
  52. data/vendor/faiss/faiss/gpu_metal/MetalIndexFlat.h +1 -1
  53. data/vendor/faiss/faiss/gpu_metal/MetalIndexIVFFlat.h +1 -1
  54. data/vendor/faiss/faiss/gpu_metal/MetalIndexIVFPQ.h +1 -1
  55. data/vendor/faiss/faiss/gpu_metal/MetalKernels.h +1 -1
  56. data/vendor/faiss/faiss/gpu_metal/MetalPythonBridge.h +1 -1
  57. data/vendor/faiss/faiss/gpu_metal/MetalResources.h +1 -1
  58. data/vendor/faiss/faiss/gpu_metal/StandardMetalResources.h +1 -1
  59. data/vendor/faiss/faiss/gpu_metal/impl/MetalIVFFlat.h +1 -1
  60. data/vendor/faiss/faiss/gpu_metal/impl/MetalIVFPQ.h +1 -1
  61. data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +1 -1
  62. data/vendor/faiss/faiss/impl/ClusteringInitialization.cpp +31 -50
  63. data/vendor/faiss/faiss/impl/ClusteringInitialization.h +0 -15
  64. data/vendor/faiss/faiss/impl/CodePacker.cpp +2 -2
  65. data/vendor/faiss/faiss/impl/CodePackerRaBitQ.cpp +2 -2
  66. data/vendor/faiss/faiss/impl/DeterministicNNDescent.cpp +2167 -0
  67. data/vendor/faiss/faiss/impl/DeterministicNNDescent.h +301 -0
  68. data/vendor/faiss/faiss/impl/HNSW.cpp +2 -2
  69. data/vendor/faiss/faiss/impl/HNSW.h +2 -2
  70. data/vendor/faiss/faiss/impl/IDSelector.h +5 -4
  71. data/vendor/faiss/faiss/impl/NNDescent.h +4 -0
  72. data/vendor/faiss/faiss/impl/PiPNN.cpp +4 -2
  73. data/vendor/faiss/faiss/impl/PiPNN.h +1 -1
  74. data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +1 -1
  75. data/vendor/faiss/faiss/impl/RaBitQUtils.cpp +0 -2
  76. data/vendor/faiss/faiss/impl/RaBitQUtils.h +29 -0
  77. data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +14 -13
  78. data/vendor/faiss/faiss/impl/ResultHandler.h +116 -0
  79. data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryIVF_impl.h +1 -3
  80. data/vendor/faiss/faiss/impl/expanded_scanners.h +29 -24
  81. data/vendor/faiss/faiss/impl/fast_scan/fast_scan.cpp +68 -6
  82. data/vendor/faiss/faiss/impl/fast_scan/fast_scan.h +43 -0
  83. data/vendor/faiss/faiss/impl/fast_scan/impl-avx2.cpp +15 -0
  84. data/vendor/faiss/faiss/impl/fast_scan/impl-avx512.cpp +115 -0
  85. data/vendor/faiss/faiss/impl/fast_scan/impl-neon.cpp +13 -0
  86. data/vendor/faiss/faiss/impl/fast_scan/kernels_simd256.h +84 -0
  87. data/vendor/faiss/faiss/impl/fast_scan/kernels_simd512.h +0 -4
  88. data/vendor/faiss/faiss/impl/fast_scan/rabitq_result_handler.h +0 -1
  89. data/vendor/faiss/faiss/impl/fast_scan/simd_result_handlers.h +64 -55
  90. data/vendor/faiss/faiss/impl/hnsw/LockVector.h +1 -2
  91. data/vendor/faiss/faiss/impl/index_read.cpp +146 -9
  92. data/vendor/faiss/faiss/impl/index_write.cpp +29 -5
  93. data/vendor/faiss/faiss/impl/io.cpp +1 -0
  94. data/vendor/faiss/faiss/impl/io_macros.h +2 -2
  95. data/vendor/faiss/faiss/impl/mapped_io.cpp +3 -1
  96. data/vendor/faiss/faiss/impl/maybe_owned_vector.h +78 -41
  97. data/vendor/faiss/faiss/impl/nndescent/gram-avx2.cpp +121 -0
  98. data/vendor/faiss/faiss/impl/nndescent/gram-avx512.cpp +124 -0
  99. data/vendor/faiss/faiss/impl/nndescent/gram-neon.cpp +114 -0
  100. data/vendor/faiss/faiss/impl/nndescent/gram.h +66 -0
  101. data/vendor/faiss/faiss/impl/optimal_kmeans/BlockCombiner-avx512.cpp +431 -0
  102. data/vendor/faiss/faiss/impl/optimal_kmeans/BlockCombiner-inl.h +1157 -0
  103. data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeans.cpp +282 -0
  104. data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeans.h +226 -0
  105. data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeansCompressed.cpp +1567 -0
  106. data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeansCompressed.h +281 -0
  107. data/vendor/faiss/faiss/impl/pipnn/HashPrune.cpp +1 -1
  108. data/vendor/faiss/faiss/impl/platform_macros.h +47 -28
  109. data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQScanner_impl.h +6 -1
  110. data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQ_QueryTables.cpp +17 -17
  111. data/vendor/faiss/faiss/impl/result_handler/ResultHandler.cpp +68 -1
  112. data/vendor/faiss/faiss/impl/result_handler/avx2.cpp +70 -2
  113. data/vendor/faiss/faiss/impl/result_handler/avx512.cpp +2 -1
  114. data/vendor/faiss/faiss/impl/scalar_quantizer/EDENQuantizer.cpp +1 -1
  115. data/vendor/faiss/faiss/impl/scalar_quantizer/scanners.h +26 -26
  116. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx2.cpp +48 -45
  117. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512-impl.h +34 -32
  118. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512-spr.cpp +8 -6
  119. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512.cpp +4 -3
  120. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-neon.cpp +34 -33
  121. data/vendor/faiss/faiss/impl/simdlib/simdlib_avx512.h +20 -20
  122. data/vendor/faiss/faiss/impl/simdlib/simdlib_neon.h +4 -4
  123. data/vendor/faiss/faiss/impl/zerocopy_io.cpp +2 -1
  124. data/vendor/faiss/faiss/index_factory.cpp +30 -6
  125. data/vendor/faiss/faiss/invlists/DirectMap.cpp +1 -1
  126. data/vendor/faiss/faiss/invlists/DiskIOBackend.cpp +121 -0
  127. data/vendor/faiss/faiss/invlists/DiskIOBackend.h +71 -0
  128. data/vendor/faiss/faiss/invlists/InvertedLists.cpp +12 -9
  129. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +26 -0
  130. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.h +5 -0
  131. data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +9 -24
  132. data/vendor/faiss/faiss/invlists/RaBitQSSDInvertedLists.cpp +751 -0
  133. data/vendor/faiss/faiss/invlists/RaBitQSSDInvertedLists.h +224 -0
  134. data/vendor/faiss/faiss/svs/IndexSVSFaissUtils.h +2 -7
  135. data/vendor/faiss/faiss/svs/IndexSVSFlat.cpp +1 -1
  136. data/vendor/faiss/faiss/svs/IndexSVSIVF.cpp +2 -2
  137. data/vendor/faiss/faiss/svs/IndexSVSVamana.cpp +4 -4
  138. data/vendor/faiss/faiss/utils/WorkerThread.h +0 -1
  139. data/vendor/faiss/faiss/utils/distances.cpp +246 -34
  140. data/vendor/faiss/faiss/utils/distances.h +145 -2
  141. data/vendor/faiss/faiss/utils/extra_distances.h +2 -1
  142. data/vendor/faiss/faiss/utils/hamming-inl.h +3 -0
  143. data/vendor/faiss/faiss/utils/partitioning.cpp +2 -2
  144. data/vendor/faiss/faiss/utils/rabitq_simd.h +120 -6
  145. data/vendor/faiss/faiss/utils/simd_impl/distances_arm_sve.cpp +47 -7
  146. data/vendor/faiss/faiss/utils/simd_impl/distances_autovec-inl.h +7 -3
  147. data/vendor/faiss/faiss/utils/simd_impl/distances_avx2.cpp +47 -7
  148. data/vendor/faiss/faiss/utils/simd_impl/distances_avx512.cpp +50 -10
  149. data/vendor/faiss/faiss/utils/simd_impl/distances_simdlib256.h +3 -3
  150. data/vendor/faiss/faiss/utils/simd_impl/exhaustive_L2sqr_blas_cmax.h +13 -0
  151. data/vendor/faiss/faiss/utils/simd_impl/partitioning_simdlib256.h +16 -15
  152. data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx2.cpp +131 -36
  153. data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx512.cpp +156 -45
  154. data/vendor/faiss/faiss/utils/simd_levels.cpp +3 -3
  155. data/vendor/faiss/faiss/utils/sorting.cpp +6 -5
  156. data/vendor/faiss/faiss/utils/utils.cpp +4 -0
  157. metadata +20 -1
@@ -5,7 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- // AVX2 specialisation of Top1 add_results (8-wide branchless argmin/argmax).
8
+ // AVX2 specialisations of Top1 add_results (8-wide branchless argmin/argmax)
9
+ // and Top2 add_results for CMax (8 lanes of best and second best).
9
10
  // Reservoir stays on the NONE path — VPCOMPRESSPS requires AVX512F.
10
11
 
11
12
  #include <faiss/impl/ResultHandler.h>
@@ -31,7 +32,8 @@ void top1_add_results_avx2(
31
32
  using TI = typename C::TI;
32
33
  const __m256i vstep = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
33
34
 
34
- for (size_t qi = self->i0; qi < self->i1; qi++) {
35
+ #pragma omp parallel for if (self->i1 - self->i0 >= 16)
36
+ for (int64_t qi = self->i0; qi < static_cast<int64_t>(self->i1); qi++) {
35
37
  const float* dis_tab_i = dis_tab_in + (j1 - j0) * (qi - self->i0) - j0;
36
38
 
37
39
  // Hoist best_dis / best_idx into locals so the compiler keeps them in
@@ -86,10 +88,76 @@ void top1_add_results_avx2(
86
88
  }
87
89
  }
88
90
 
91
+ /// AVX2 Top2 add_results for L2: each lane keeps its best and second best
92
+ /// with strict comparisons (the first of equal distances, NaN never), then
93
+ /// the lanes and the tail are merged into the query's pair, lower id first.
94
+ template <class C>
95
+ void top2_add_results_avx2(
96
+ Top2BlockResultHandler<C, false>* self,
97
+ size_t j0,
98
+ size_t j1,
99
+ const float* dis_tab_in) {
100
+ using TI = typename C::TI;
101
+ const size_t n = j1 - j0;
102
+ #pragma omp parallel for if (self->i1 - self->i0 >= 16)
103
+ for (int64_t qi = self->i0; qi < static_cast<int64_t>(self->i1); qi++) {
104
+ const float* dis_tab_i = dis_tab_in + n * (qi - self->i0);
105
+ float* dis2 = self->dis_tab + 2 * qi;
106
+ TI* ids2 = self->ids_tab + 2 * qi;
107
+ __m256 m1 = _mm256_set1_ps(C::neutral()), m2 = m1;
108
+ __m256i a1 = _mm256_set1_epi32(-1), a2 = a1;
109
+ __m256i current = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
110
+ size_t j = 0;
111
+ for (; j + 8 <= n; j += 8) {
112
+ const __m256 s = _mm256_loadu_ps(dis_tab_i + j);
113
+ const __m256 first = _mm256_cmp_ps(s, m1, _CMP_LT_OQ);
114
+ const __m256 second = _mm256_cmp_ps(s, m2, _CMP_LT_OQ);
115
+ m2 = _mm256_min_ps(_mm256_max_ps(m1, s), m2);
116
+ m1 = _mm256_min_ps(s, m1);
117
+ const __m256 offered = _mm256_blendv_ps(
118
+ _mm256_castsi256_ps(current),
119
+ _mm256_castsi256_ps(a1),
120
+ first);
121
+ a2 = _mm256_castps_si256(
122
+ _mm256_blendv_ps(_mm256_castsi256_ps(a2), offered, second));
123
+ a1 = _mm256_castps_si256(_mm256_blendv_ps(
124
+ _mm256_castsi256_ps(a1),
125
+ _mm256_castsi256_ps(current),
126
+ first));
127
+ current = _mm256_add_epi32(current, _mm256_set1_epi32(8));
128
+ }
129
+ alignas(32) float lane_dis[16];
130
+ alignas(32) int32_t lane_ids[16];
131
+ _mm256_store_ps(lane_dis, m1);
132
+ _mm256_store_ps(lane_dis + 8, m2);
133
+ _mm256_store_si256((__m256i*)lane_ids, a1);
134
+ _mm256_store_si256((__m256i*)(lane_ids + 8), a2);
135
+ for (int l = 0; l < 16; l++) {
136
+ if (lane_ids[l] >= 0) {
137
+ top2_insert<C>(lane_dis[l], TI(j0 + lane_ids[l]), dis2, ids2);
138
+ }
139
+ }
140
+ for (; j < n; j++) {
141
+ if (C::cmp(dis2[1], dis_tab_i[j])) {
142
+ top2_insert<C>(dis_tab_i[j], TI(j0 + j), dis2, ids2);
143
+ }
144
+ }
145
+ }
146
+ }
147
+
89
148
  } // namespace
90
149
 
91
150
  // Explicit specialisations for AVX2
92
151
 
152
+ template <>
153
+ void top2_add_results_tpl<CMax<float, int64_t>, false, SIMDLevel::AVX2>(
154
+ Top2BlockResultHandler<CMax<float, int64_t>, false>* self,
155
+ size_t j0,
156
+ size_t j1,
157
+ const float* dis_tab) {
158
+ top2_add_results_avx2<CMax<float, int64_t>>(self, j0, j1, dis_tab);
159
+ }
160
+
93
161
  template <>
94
162
  void top1_add_results_tpl<CMax<float, int64_t>, false, SIMDLevel::AVX2>(
95
163
  Top1BlockResultHandler<CMax<float, int64_t>, false>* self,
@@ -36,7 +36,8 @@ void top1_add_results_avx512(
36
36
  const __m512i vstep = _mm512_set_epi32(
37
37
  15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
38
38
 
39
- for (size_t qi = self->i0; qi < self->i1; qi++) {
39
+ #pragma omp parallel for if (self->i1 - self->i0 >= 16)
40
+ for (int64_t qi = self->i0; qi < static_cast<int64_t>(self->i1); qi++) {
40
41
  const float* dis_tab_i = dis_tab_in + (j1 - j0) * (qi - self->i0) - j0;
41
42
 
42
43
  // Hoist best_dis / best_idx into locals so the compiler keeps them in
@@ -508,7 +508,7 @@ EDENFlatCodesDistanceComputer* make_reference_distance_computer(
508
508
  return dc.release();
509
509
  }
510
510
 
511
- EDENFlatCodesDistanceComputer* make_optimized_distance_computer(
511
+ [[maybe_unused]] EDENFlatCodesDistanceComputer* make_optimized_distance_computer(
512
512
  MetricType metric_type,
513
513
  size_t d,
514
514
  size_t nb_bits,
@@ -63,14 +63,14 @@ struct IVFSQScannerIP : InvertedListScanner {
63
63
  IVFSQScannerIP(
64
64
  int d,
65
65
  const std::vector<float>& trained,
66
- size_t code_size,
67
- bool store_pairs,
68
- const IDSelector* sel,
69
- bool by_residual)
70
- : dc(d, trained), by_residual(by_residual), accu0(0) {
71
- this->store_pairs = store_pairs;
72
- this->sel = sel;
73
- this->code_size = code_size;
66
+ size_t code_size_in,
67
+ bool store_pairs_in,
68
+ const IDSelector* sel_in,
69
+ bool by_residual_in)
70
+ : dc(d, trained), by_residual(by_residual_in), accu0(0) {
71
+ this->store_pairs = store_pairs_in;
72
+ this->sel = sel_in;
73
+ this->code_size = code_size_in;
74
74
  this->keep_max = true;
75
75
  }
76
76
 
@@ -78,8 +78,8 @@ struct IVFSQScannerIP : InvertedListScanner {
78
78
  dc.set_query(query);
79
79
  }
80
80
 
81
- void set_list(idx_t list_no, float coarse_dis) override {
82
- this->list_no = list_no;
81
+ void set_list(idx_t list_no_in, float coarse_dis) override {
82
+ this->list_no = list_no_in;
83
83
  accu0 = by_residual ? coarse_dis : 0;
84
84
  }
85
85
 
@@ -132,19 +132,19 @@ struct IVFSQScannerL2 : InvertedListScanner {
132
132
  IVFSQScannerL2(
133
133
  int d,
134
134
  const std::vector<float>& trained,
135
- size_t code_size,
136
- const Index* quantizer,
137
- bool store_pairs,
138
- const IDSelector* sel,
139
- bool by_residual)
135
+ size_t code_size_in,
136
+ const Index* quantizer_in,
137
+ bool store_pairs_in,
138
+ const IDSelector* sel_in,
139
+ bool by_residual_in)
140
140
  : dc(d, trained),
141
- by_residual(by_residual),
142
- quantizer(quantizer),
141
+ by_residual(by_residual_in),
142
+ quantizer(quantizer_in),
143
143
  x(nullptr),
144
144
  tmp(d) {
145
- this->store_pairs = store_pairs;
146
- this->sel = sel;
147
- this->code_size = code_size;
145
+ this->store_pairs = store_pairs_in;
146
+ this->sel = sel_in;
147
+ this->code_size = code_size_in;
148
148
  }
149
149
 
150
150
  void set_query(const float* query) override {
@@ -154,10 +154,10 @@ struct IVFSQScannerL2 : InvertedListScanner {
154
154
  }
155
155
  }
156
156
 
157
- void set_list(idx_t list_no, float /*coarse_dis*/) override {
158
- this->list_no = list_no;
157
+ void set_list(idx_t list_no_in, float /*coarse_dis*/) override {
158
+ this->list_no = list_no_in;
159
159
  if (by_residual) {
160
- quantizer->compute_residual(x, tmp.data(), list_no);
160
+ quantizer->compute_residual(x, tmp.data(), list_no_in);
161
161
  dc.set_query(tmp.data());
162
162
  } else {
163
163
  dc.set_query(x);
@@ -219,9 +219,9 @@ struct IVFCoarseDistanceScanner : InvertedListScanner {
219
219
 
220
220
  IVFCoarseDistanceScanner(
221
221
  bool is_similarity,
222
- bool store_pairs,
223
- const IDSelector* sel)
224
- : InvertedListScanner(store_pairs, sel) {
222
+ bool store_pairs_in,
223
+ const IDSelector* sel_in)
224
+ : InvertedListScanner(store_pairs_in, sel_in) {
225
225
  code_size = 0;
226
226
  keep_max = is_similarity;
227
227
  }
@@ -182,12 +182,12 @@ struct QuantizerTemplate<
182
182
  Codec,
183
183
  QuantizerTemplateScaling::UNIFORM,
184
184
  SIMDLevel::NONE> {
185
- QuantizerTemplate(size_t d, const std::vector<float>& trained)
185
+ QuantizerTemplate(size_t d_in, const std::vector<float>& trained)
186
186
  : QuantizerTemplate<
187
187
  Codec,
188
188
  QuantizerTemplateScaling::UNIFORM,
189
- SIMDLevel::NONE>(d, trained) {
190
- assert(d % 8 == 0);
189
+ SIMDLevel::NONE>(d_in, trained) {
190
+ assert(d_in % 8 == 0);
191
191
  }
192
192
 
193
193
  FAISS_ALWAYS_INLINE simd8float32
@@ -213,12 +213,12 @@ struct QuantizerTemplate<
213
213
  Codec,
214
214
  QuantizerTemplateScaling::NON_UNIFORM,
215
215
  SIMDLevel::NONE> {
216
- QuantizerTemplate(size_t d, const std::vector<float>& trained)
216
+ QuantizerTemplate(size_t d_in, const std::vector<float>& trained)
217
217
  : QuantizerTemplate<
218
218
  Codec,
219
219
  QuantizerTemplateScaling::NON_UNIFORM,
220
- SIMDLevel::NONE>(d, trained) {
221
- assert(d % 8 == 0);
220
+ SIMDLevel::NONE>(d_in, trained) {
221
+ assert(d_in % 8 == 0);
222
222
  }
223
223
 
224
224
  FAISS_ALWAYS_INLINE simd8float32
@@ -245,9 +245,9 @@ struct QuantizerLloydMax<1, SIMDLevel::AVX2>
245
245
  : QuantizerLloydMaxBase<1, SIMDLevel::AVX2> {
246
246
  using Base = QuantizerLloydMaxBase<1, SIMDLevel::AVX2>;
247
247
 
248
- QuantizerLloydMax(size_t d, const std::vector<float>& trained)
249
- : Base(d, trained) {
250
- assert(d % 8 == 0);
248
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained)
249
+ : Base(d_in, trained) {
250
+ assert(d_in % 8 == 0);
251
251
  }
252
252
 
253
253
  FAISS_ALWAYS_INLINE simd8float32
@@ -284,9 +284,9 @@ struct QuantizerLloydMax<2, SIMDLevel::AVX2>
284
284
  : QuantizerLloydMaxBase<2, SIMDLevel::AVX2> {
285
285
  using Base = QuantizerLloydMaxBase<2, SIMDLevel::AVX2>;
286
286
 
287
- QuantizerLloydMax(size_t d, const std::vector<float>& trained)
288
- : Base(d, trained) {
289
- assert(d % 8 == 0);
287
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained)
288
+ : Base(d_in, trained) {
289
+ assert(d_in % 8 == 0);
290
290
  }
291
291
 
292
292
  FAISS_ALWAYS_INLINE simd8float32
@@ -344,9 +344,9 @@ struct QuantizerLloydMax<2, SIMDLevel::AVX2>
344
344
  : QuantizerLloydMaxBase<NBITS, SIMDLevel::AVX2> { \
345
345
  using Base = QuantizerLloydMaxBase<NBITS, SIMDLevel::AVX2>; \
346
346
  \
347
- QuantizerLloydMax(size_t d, const std::vector<float>& trained) \
348
- : Base(d, trained) { \
349
- assert(d % 8 == 0); \
347
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained) \
348
+ : Base(d_in, trained) { \
349
+ assert(d_in % 8 == 0); \
350
350
  } \
351
351
  \
352
352
  FAISS_ALWAYS_INLINE simd8float32 \
@@ -375,9 +375,9 @@ struct QuantizerLloydMax<8, SIMDLevel::AVX2>
375
375
  : QuantizerLloydMaxBase<8, SIMDLevel::AVX2> {
376
376
  using Base = QuantizerLloydMaxBase<8, SIMDLevel::AVX2>;
377
377
 
378
- QuantizerLloydMax(size_t d, const std::vector<float>& trained)
379
- : Base(d, trained) {
380
- assert(d % 8 == 0);
378
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained)
379
+ : Base(d_in, trained) {
380
+ assert(d_in % 8 == 0);
381
381
  }
382
382
 
383
383
  FAISS_ALWAYS_INLINE simd8float32
@@ -404,9 +404,9 @@ struct QuantizerLloydMax<8, SIMDLevel::AVX2>
404
404
 
405
405
  template <>
406
406
  struct QuantizerFP16<SIMDLevel::AVX2> : QuantizerFP16Base<SIMDLevel::AVX2> {
407
- QuantizerFP16(size_t d, const std::vector<float>& trained)
408
- : QuantizerFP16Base<SIMDLevel::AVX2>(d, trained) {
409
- assert(d % 8 == 0);
407
+ QuantizerFP16(size_t d_in, const std::vector<float>& trained)
408
+ : QuantizerFP16Base<SIMDLevel::AVX2>(d_in, trained) {
409
+ assert(d_in % 8 == 0);
410
410
  }
411
411
 
412
412
  FAISS_ALWAYS_INLINE simd8float32
@@ -422,9 +422,9 @@ struct QuantizerFP16<SIMDLevel::AVX2> : QuantizerFP16Base<SIMDLevel::AVX2> {
422
422
 
423
423
  template <>
424
424
  struct QuantizerBF16<SIMDLevel::AVX2> : QuantizerBF16Base<SIMDLevel::AVX2> {
425
- QuantizerBF16(size_t d, const std::vector<float>& trained)
426
- : QuantizerBF16Base<SIMDLevel::AVX2>(d, trained) {
427
- assert(d % 8 == 0);
425
+ QuantizerBF16(size_t d_in, const std::vector<float>& trained)
426
+ : QuantizerBF16Base<SIMDLevel::AVX2>(d_in, trained) {
427
+ assert(d_in % 8 == 0);
428
428
  }
429
429
 
430
430
  FAISS_ALWAYS_INLINE simd8float32
@@ -443,9 +443,9 @@ struct QuantizerBF16<SIMDLevel::AVX2> : QuantizerBF16Base<SIMDLevel::AVX2> {
443
443
  template <>
444
444
  struct Quantizer8bitDirect<SIMDLevel::AVX2>
445
445
  : Quantizer8bitDirectBase<SIMDLevel::AVX2> {
446
- Quantizer8bitDirect(size_t d, const std::vector<float>& trained)
447
- : Quantizer8bitDirectBase<SIMDLevel::AVX2>(d, trained) {
448
- assert(d % 8 == 0);
446
+ Quantizer8bitDirect(size_t d_in, const std::vector<float>& trained)
447
+ : Quantizer8bitDirectBase<SIMDLevel::AVX2>(d_in, trained) {
448
+ assert(d_in % 8 == 0);
449
449
  }
450
450
 
451
451
  FAISS_ALWAYS_INLINE simd8float32
@@ -463,9 +463,9 @@ struct Quantizer8bitDirect<SIMDLevel::AVX2>
463
463
  template <>
464
464
  struct Quantizer8bitDirectSigned<SIMDLevel::AVX2>
465
465
  : Quantizer8bitDirectSignedBase<SIMDLevel::AVX2> {
466
- Quantizer8bitDirectSigned(size_t d, const std::vector<float>& trained)
467
- : Quantizer8bitDirectSignedBase<SIMDLevel::AVX2>(d, trained) {
468
- assert(d % 8 == 0);
466
+ Quantizer8bitDirectSigned(size_t d_in, const std::vector<float>& trained)
467
+ : Quantizer8bitDirectSignedBase<SIMDLevel::AVX2>(d_in, trained) {
468
+ assert(d_in % 8 == 0);
469
469
  }
470
470
 
471
471
  FAISS_ALWAYS_INLINE simd8float32
@@ -490,7 +490,7 @@ struct SimilarityL2<SIMDLevel::AVX2> {
490
490
 
491
491
  const float *y, *yi;
492
492
 
493
- explicit SimilarityL2(const float* y) : y(y), yi(nullptr) {}
493
+ explicit SimilarityL2(const float* y_in) : y(y_in), yi(nullptr) {}
494
494
  simd8float32 accu8 = {};
495
495
 
496
496
  FAISS_ALWAYS_INLINE void begin_8() {
@@ -550,7 +550,7 @@ struct SimilarityIP<SIMDLevel::AVX2> {
550
550
 
551
551
  float accu;
552
552
 
553
- explicit SimilarityIP(const float* y) : y(y), yi(nullptr), accu(0) {}
553
+ explicit SimilarityIP(const float* y_in) : y(y_in), yi(nullptr), accu(0) {}
554
554
 
555
555
  simd8float32 accu8 = {};
556
556
 
@@ -834,7 +834,7 @@ struct DCTemplate<
834
834
  /// accumulator j of the code, so a code sums the same way for any N.
835
835
  template <size_t N>
836
836
  FAISS_ALWAYS_INLINE void accumulate(
837
- const uint8_t* const* codes,
837
+ const uint8_t* const* code_ptrs,
838
838
  __m128* sums) const {
839
839
  constexpr size_t n_acc = four_acc ? 4 : 1;
840
840
  __m256 acc[N][n_acc];
@@ -851,7 +851,9 @@ struct DCTemplate<
851
851
  const __m256 qa8 = _mm256_loadu_ps(qa.data() + i + 8 * j);
852
852
  for (size_t n = 0; n < N; n++) {
853
853
  acc[n][j] = _mm256_fmadd_ps(
854
- qa8, codes_8(codes[n] + i + 8 * j), acc[n][j]);
854
+ qa8,
855
+ codes_8(code_ptrs[n] + i + 8 * j),
856
+ acc[n][j]);
855
857
  }
856
858
  }
857
859
  }
@@ -859,8 +861,8 @@ struct DCTemplate<
859
861
  for (; i < d; i += 8) {
860
862
  const __m256 qa8 = _mm256_loadu_ps(qa.data() + i);
861
863
  for (size_t n = 0; n < N; n++) {
862
- acc[n][0] =
863
- _mm256_fmadd_ps(qa8, codes_8(codes[n] + i), acc[n][0]);
864
+ acc[n][0] = _mm256_fmadd_ps(
865
+ qa8, codes_8(code_ptrs[n] + i), acc[n][0]);
864
866
  }
865
867
  }
866
868
  for (size_t n = 0; n < N; n++) {
@@ -889,14 +891,14 @@ struct DCTemplate<
889
891
  float& dis1,
890
892
  float& dis2,
891
893
  float& dis3) const final {
892
- const uint8_t* codes[4] = {code_0, code_1, code_2, code_3};
894
+ const uint8_t* code_ptrs[4] = {code_0, code_1, code_2, code_3};
893
895
  __m128 sums[4];
894
896
  if constexpr (four_acc) {
895
897
  // 16 accumulators would take all 16 AVX2 registers.
896
- accumulate<2>(codes, sums);
897
- accumulate<2>(codes + 2, sums + 2);
898
+ accumulate<2>(code_ptrs, sums);
899
+ accumulate<2>(code_ptrs + 2, sums + 2);
898
900
  } else {
899
- accumulate<4>(codes, sums);
901
+ accumulate<4>(code_ptrs, sums);
900
902
  }
901
903
  alignas(16) float dis[4];
902
904
  _mm_store_ps(dis, reduce_4x4(sums[0], sums[1], sums[2], sums[3]));
@@ -928,8 +930,9 @@ struct DistanceComputerByte<Similarity, SIMDLevel::AVX2> : SQDistanceComputer {
928
930
  int d;
929
931
  std::vector<uint8_t> tmp;
930
932
 
931
- DistanceComputerByte(int d, const std::vector<float>&) : d(d), tmp(d) {
932
- FAISS_THROW_IF_NOT(d % 16 == 0);
933
+ DistanceComputerByte(int d_in, const std::vector<float>&)
934
+ : d(d_in), tmp(d_in) {
935
+ FAISS_THROW_IF_NOT(d_in % 16 == 0);
933
936
  }
934
937
 
935
938
  int compute_code_distance(const uint8_t* code1, const uint8_t* code2)
@@ -992,9 +995,9 @@ struct DistanceComputerByteSigned<Similarity, SIMDLevel::AVX2>
992
995
  int d;
993
996
  std::vector<uint8_t> tmp;
994
997
 
995
- DistanceComputerByteSigned(int d, const std::vector<float>&)
996
- : d(d), tmp(d) {
997
- FAISS_THROW_IF_NOT(d % 16 == 0);
998
+ DistanceComputerByteSigned(int d_in, const std::vector<float>&)
999
+ : d(d_in), tmp(d_in) {
1000
+ FAISS_THROW_IF_NOT(d_in % 16 == 0);
998
1001
  }
999
1002
 
1000
1003
  int compute_code_distance(const uint8_t* code1, const uint8_t* code2)
@@ -153,10 +153,10 @@ struct Codec6bit<THE_LEVEL_TO_DISPATCH> : Codec6bit<SIMDLevel::NONE> {
153
153
  // 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
154
154
  // 00 01 02 03
155
155
  const __m256i shuffle_mask = _mm256_setr_epi16(
156
- 0xFF00, 0x0100, 0x0201, 0xFF02,
157
- 0xFF03, 0x0403, 0x0504, 0xFF05,
158
- 0xFF06, 0x0706, 0x0807, 0xFF08,
159
- 0xFF09, 0x0A09, 0x0B0A, 0xFF0B);
156
+ short(0xFF00), 0x0100, 0x0201, short(0xFF02),
157
+ short(0xFF03), 0x0403, 0x0504, short(0xFF05),
158
+ short(0xFF06), 0x0706, 0x0807, short(0xFF08),
159
+ short(0xFF09), 0x0A09, 0x0B0A, short(0xFF0B));
160
160
  const __m256i shuffled = _mm256_shuffle_epi8(bit_6v_256, shuffle_mask);
161
161
 
162
162
  // 0: xxxxxxxx xx543210
@@ -198,12 +198,12 @@ struct QuantizerTemplate<
198
198
  Codec,
199
199
  scalar_quantizer::QuantizerTemplateScaling::UNIFORM,
200
200
  SIMDLevel::NONE> {
201
- QuantizerTemplate(size_t d, const std::vector<float>& trained)
201
+ QuantizerTemplate(size_t d_in, const std::vector<float>& trained)
202
202
  : QuantizerTemplate<
203
203
  Codec,
204
204
  scalar_quantizer::QuantizerTemplateScaling::UNIFORM,
205
- SIMDLevel::NONE>(d, trained) {
206
- assert(d % 16 == 0);
205
+ SIMDLevel::NONE>(d_in, trained) {
206
+ assert(d_in % 16 == 0);
207
207
  }
208
208
 
209
209
  FAISS_ALWAYS_INLINE simd16float32
@@ -229,12 +229,12 @@ struct QuantizerTemplate<
229
229
  Codec,
230
230
  scalar_quantizer::QuantizerTemplateScaling::NON_UNIFORM,
231
231
  SIMDLevel::NONE> {
232
- QuantizerTemplate(size_t d, const std::vector<float>& trained)
232
+ QuantizerTemplate(size_t d_in, const std::vector<float>& trained)
233
233
  : QuantizerTemplate<
234
234
  Codec,
235
235
  scalar_quantizer::QuantizerTemplateScaling::NON_UNIFORM,
236
- SIMDLevel::NONE>(d, trained) {
237
- assert(d % 16 == 0);
236
+ SIMDLevel::NONE>(d_in, trained) {
237
+ assert(d_in % 16 == 0);
238
238
  }
239
239
 
240
240
  FAISS_ALWAYS_INLINE simd16float32
@@ -258,9 +258,9 @@ struct QuantizerLloydMax<1, THE_LEVEL_TO_DISPATCH>
258
258
  : QuantizerLloydMaxBase<1, THE_LEVEL_TO_DISPATCH> {
259
259
  using Base = QuantizerLloydMaxBase<1, THE_LEVEL_TO_DISPATCH>;
260
260
 
261
- QuantizerLloydMax(size_t d, const std::vector<float>& trained)
262
- : Base(d, trained) {
263
- assert(d % 16 == 0);
261
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained)
262
+ : Base(d_in, trained) {
263
+ assert(d_in % 16 == 0);
264
264
  }
265
265
 
266
266
  FAISS_ALWAYS_INLINE simd16float32
@@ -297,9 +297,9 @@ struct QuantizerLloydMax<1, THE_LEVEL_TO_DISPATCH>
297
297
  : QuantizerLloydMaxBase<NBITS, THE_LEVEL_TO_DISPATCH> { \
298
298
  using Base = QuantizerLloydMaxBase<NBITS, THE_LEVEL_TO_DISPATCH>; \
299
299
  \
300
- QuantizerLloydMax(size_t d, const std::vector<float>& trained) \
301
- : Base(d, trained) { \
302
- assert(d % 16 == 0); \
300
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained) \
301
+ : Base(d_in, trained) { \
302
+ assert(d_in % 16 == 0); \
303
303
  } \
304
304
  \
305
305
  FAISS_ALWAYS_INLINE simd16float32 \
@@ -329,9 +329,9 @@ struct QuantizerLloydMax<8, THE_LEVEL_TO_DISPATCH>
329
329
  : QuantizerLloydMaxBase<8, THE_LEVEL_TO_DISPATCH> {
330
330
  using Base = QuantizerLloydMaxBase<8, THE_LEVEL_TO_DISPATCH>;
331
331
 
332
- QuantizerLloydMax(size_t d, const std::vector<float>& trained)
333
- : Base(d, trained) {
334
- assert(d % 16 == 0);
332
+ QuantizerLloydMax(size_t d_in, const std::vector<float>& trained)
333
+ : Base(d_in, trained) {
334
+ assert(d_in % 16 == 0);
335
335
  }
336
336
 
337
337
  FAISS_ALWAYS_INLINE simd16float32
@@ -416,9 +416,9 @@ struct QuantizerBF16<THE_LEVEL_TO_DISPATCH>
416
416
  template <>
417
417
  struct Quantizer8bitDirect<THE_LEVEL_TO_DISPATCH>
418
418
  : Quantizer8bitDirectBase<THE_LEVEL_TO_DISPATCH> {
419
- Quantizer8bitDirect(size_t d, const std::vector<float>& trained)
420
- : Quantizer8bitDirectBase<THE_LEVEL_TO_DISPATCH>(d, trained) {
421
- assert(d % 16 == 0);
419
+ Quantizer8bitDirect(size_t d_in, const std::vector<float>& trained)
420
+ : Quantizer8bitDirectBase<THE_LEVEL_TO_DISPATCH>(d_in, trained) {
421
+ assert(d_in % 16 == 0);
422
422
  }
423
423
 
424
424
  FAISS_ALWAYS_INLINE simd16float32
@@ -436,9 +436,11 @@ struct Quantizer8bitDirect<THE_LEVEL_TO_DISPATCH>
436
436
  template <>
437
437
  struct Quantizer8bitDirectSigned<THE_LEVEL_TO_DISPATCH>
438
438
  : Quantizer8bitDirectSignedBase<THE_LEVEL_TO_DISPATCH> {
439
- Quantizer8bitDirectSigned(size_t d, const std::vector<float>& trained)
440
- : Quantizer8bitDirectSignedBase<THE_LEVEL_TO_DISPATCH>(d, trained) {
441
- assert(d % 16 == 0);
439
+ Quantizer8bitDirectSigned(size_t d_in, const std::vector<float>& trained)
440
+ : Quantizer8bitDirectSignedBase<THE_LEVEL_TO_DISPATCH>(
441
+ d_in,
442
+ trained) {
443
+ assert(d_in % 16 == 0);
442
444
  }
443
445
 
444
446
  FAISS_ALWAYS_INLINE simd16float32
@@ -463,7 +465,7 @@ struct SimilarityL2<THE_LEVEL_TO_DISPATCH> {
463
465
 
464
466
  const float *y, *yi;
465
467
 
466
- explicit SimilarityL2(const float* y) : y(y), yi(nullptr) {}
468
+ explicit SimilarityL2(const float* y_in) : y(y_in), yi(nullptr) {}
467
469
 
468
470
  simd16float32 accu16;
469
471
 
@@ -522,7 +524,7 @@ struct SimilarityIP<THE_LEVEL_TO_DISPATCH> {
522
524
 
523
525
  const float *y, *yi;
524
526
 
525
- explicit SimilarityIP(const float* y) : y(y), yi(nullptr) {}
527
+ explicit SimilarityIP(const float* y_in) : y(y_in), yi(nullptr) {}
526
528
 
527
529
  simd16float32 accu16;
528
530
 
@@ -845,7 +847,7 @@ struct DCTemplate<
845
847
  /// accumulator j of the code, so a code sums the same way for any N.
846
848
  template <size_t N>
847
849
  FAISS_ALWAYS_INLINE void accumulate(
848
- const uint8_t* const* codes,
850
+ const uint8_t* const* code_ptrs,
849
851
  __m128* sums) const {
850
852
  constexpr size_t n_acc = four_acc ? 4 : 1;
851
853
  __m512 acc[N][n_acc];
@@ -863,7 +865,7 @@ struct DCTemplate<
863
865
  for (size_t n = 0; n < N; n++) {
864
866
  acc[n][j] = _mm512_fmadd_ps(
865
867
  qa16,
866
- codes_16(codes[n] + i + 16 * j),
868
+ codes_16(code_ptrs[n] + i + 16 * j),
867
869
  acc[n][j]);
868
870
  }
869
871
  }
@@ -873,7 +875,7 @@ struct DCTemplate<
873
875
  const __m512 qa16 = _mm512_loadu_ps(qa.data() + i);
874
876
  for (size_t n = 0; n < N; n++) {
875
877
  acc[n][0] = _mm512_fmadd_ps(
876
- qa16, codes_16(codes[n] + i), acc[n][0]);
878
+ qa16, codes_16(code_ptrs[n] + i), acc[n][0]);
877
879
  }
878
880
  }
879
881
  for (size_t n = 0; n < N; n++) {
@@ -902,9 +904,9 @@ struct DCTemplate<
902
904
  float& dis1,
903
905
  float& dis2,
904
906
  float& dis3) const final {
905
- const uint8_t* codes[4] = {code_0, code_1, code_2, code_3};
907
+ const uint8_t* code_ptrs[4] = {code_0, code_1, code_2, code_3};
906
908
  __m128 sums[4];
907
- accumulate<4>(codes, sums);
909
+ accumulate<4>(code_ptrs, sums);
908
910
  alignas(16) float dis[4];
909
911
  _mm_store_ps(dis, reduce_4x4(sums[0], sums[1], sums[2], sums[3]));
910
912
  dis0 = bias + dis[0];
@@ -27,7 +27,8 @@ struct DistanceComputerByte<Similarity, SIMDLevel::AVX512_SPR>
27
27
  int d;
28
28
  std::vector<uint8_t> tmp;
29
29
 
30
- DistanceComputerByte(int d, const std::vector<float>&) : d(d), tmp(d) {}
30
+ DistanceComputerByte(int d_in, const std::vector<float>&)
31
+ : d(d_in), tmp(d_in) {}
31
32
 
32
33
  int compute_code_distance(const uint8_t* code1, const uint8_t* code2)
33
34
  const {
@@ -141,8 +142,8 @@ struct DistanceComputerByteSigned<Similarity, SIMDLevel::AVX512_SPR>
141
142
  int d;
142
143
  std::vector<uint8_t> tmp;
143
144
 
144
- DistanceComputerByteSigned(int d, const std::vector<float>&)
145
- : d(d), tmp(d) {}
145
+ DistanceComputerByteSigned(int d_in, const std::vector<float>&)
146
+ : d(d_in), tmp(d_in) {}
146
147
 
147
148
  int compute_code_distance(const uint8_t* code1, const uint8_t* code2)
148
149
  const {
@@ -335,7 +336,8 @@ struct DCBF16_IP : SQDistanceComputer {
335
336
  size_t d;
336
337
  std::vector<uint16_t> query_bf16;
337
338
 
338
- DCBF16_IP(size_t d, const std::vector<float>&) : d(d), query_bf16(d) {}
339
+ DCBF16_IP(size_t d_in, const std::vector<float>&)
340
+ : d(d_in), query_bf16(d_in) {}
339
341
 
340
342
  void set_query(const float* x) final {
341
343
  q = x;
@@ -365,8 +367,8 @@ struct DCBF16_L2 : SQDistanceComputer {
365
367
  std::vector<uint16_t> query_bf16;
366
368
  float query_norm_sq;
367
369
 
368
- DCBF16_L2(size_t d, const std::vector<float>&)
369
- : d(d), query_bf16(d), query_norm_sq(0) {}
370
+ DCBF16_L2(size_t d_in, const std::vector<float>&)
371
+ : d(d_in), query_bf16(d_in), query_norm_sq(0) {}
370
372
 
371
373
  void set_query(const float* x) final {
372
374
  q = x;
@@ -21,7 +21,8 @@ struct DistanceComputerByte<Similarity, SIMDLevel::AVX512>
21
21
  int d;
22
22
  std::vector<uint8_t> tmp;
23
23
 
24
- DistanceComputerByte(int d, const std::vector<float>&) : d(d), tmp(d) {}
24
+ DistanceComputerByte(int d_in, const std::vector<float>&)
25
+ : d(d_in), tmp(d_in) {}
25
26
 
26
27
  int compute_code_distance(const uint8_t* code1, const uint8_t* code2)
27
28
  const {
@@ -88,8 +89,8 @@ struct DistanceComputerByteSigned<Similarity, SIMDLevel::AVX512>
88
89
  int d;
89
90
  std::vector<uint8_t> tmp;
90
91
 
91
- DistanceComputerByteSigned(int d, const std::vector<float>&)
92
- : d(d), tmp(d) {}
92
+ DistanceComputerByteSigned(int d_in, const std::vector<float>&)
93
+ : d(d_in), tmp(d_in) {}
93
94
 
94
95
  int compute_code_distance(const uint8_t* code1, const uint8_t* code2)
95
96
  const {