faiss 0.6.4 → 0.6.5

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 (228) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/ext/faiss/extconf.rb +1 -1
  4. data/lib/faiss/version.rb +1 -1
  5. data/vendor/faiss/faiss/AutoTune.cpp +175 -0
  6. data/vendor/faiss/faiss/Clustering.cpp +150 -60
  7. data/vendor/faiss/faiss/Clustering.h +29 -0
  8. data/vendor/faiss/faiss/IVFlib.cpp +99 -0
  9. data/vendor/faiss/faiss/IVFlib.h +15 -0
  10. data/vendor/faiss/faiss/Index.cpp +44 -0
  11. data/vendor/faiss/faiss/Index.h +19 -14
  12. data/vendor/faiss/faiss/IndexBinary.cpp +8 -0
  13. data/vendor/faiss/faiss/IndexBinary.h +8 -0
  14. data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +82 -4
  15. data/vendor/faiss/faiss/IndexBinaryHNSW.h +19 -0
  16. data/vendor/faiss/faiss/IndexBinaryIVF.cpp +34 -0
  17. data/vendor/faiss/faiss/IndexFastScan.cpp +33 -17
  18. data/vendor/faiss/faiss/IndexFastScan.h +6 -3
  19. data/vendor/faiss/faiss/IndexFlat.cpp +56 -0
  20. data/vendor/faiss/faiss/IndexFlat.h +31 -0
  21. data/vendor/faiss/faiss/IndexFlatCodes.cpp +6 -1
  22. data/vendor/faiss/faiss/IndexHNSW.cpp +456 -10
  23. data/vendor/faiss/faiss/IndexHNSW.h +38 -0
  24. data/vendor/faiss/faiss/IndexIDMap.cpp +32 -0
  25. data/vendor/faiss/faiss/IndexIDMap.h +7 -0
  26. data/vendor/faiss/faiss/IndexIVF.cpp +281 -31
  27. data/vendor/faiss/faiss/IndexIVF.h +53 -1
  28. data/vendor/faiss/faiss/IndexIVFFastScan.cpp +46 -14
  29. data/vendor/faiss/faiss/IndexIVFFastScan.h +4 -2
  30. data/vendor/faiss/faiss/IndexIVFFlat.cpp +33 -0
  31. data/vendor/faiss/faiss/IndexIVFFlat.h +16 -0
  32. data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +1 -0
  33. data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +3 -20
  34. data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +50 -14
  35. data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +5 -2
  36. data/vendor/faiss/faiss/IndexIVFSQFastScan.cpp +855 -0
  37. data/vendor/faiss/faiss/IndexIVFSQFastScan.h +145 -0
  38. data/vendor/faiss/faiss/IndexNNDescent.cpp +0 -3
  39. data/vendor/faiss/faiss/IndexPiPNN.cpp +201 -0
  40. data/vendor/faiss/faiss/IndexPiPNN.h +83 -0
  41. data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +6 -3
  42. data/vendor/faiss/faiss/IndexRaBitQFastScan.h +10 -4
  43. data/vendor/faiss/faiss/IndexReplicas.cpp +20 -0
  44. data/vendor/faiss/faiss/IndexReplicas.h +9 -0
  45. data/vendor/faiss/faiss/IndexSQFastScan.cpp +648 -0
  46. data/vendor/faiss/faiss/IndexSQFastScan.h +129 -0
  47. data/vendor/faiss/faiss/IndexShards.cpp +10 -0
  48. data/vendor/faiss/faiss/IndexShards.h +5 -0
  49. data/vendor/faiss/faiss/SuperKMeans.cpp +57 -15
  50. data/vendor/faiss/faiss/SuperKMeans.h +9 -4
  51. data/vendor/faiss/faiss/VectorTransform.cpp +3 -2
  52. data/vendor/faiss/faiss/clone_index.cpp +24 -0
  53. data/vendor/faiss/faiss/gpu/Dataset.h +112 -0
  54. data/vendor/faiss/faiss/gpu/GpuCloner.cpp +16 -13
  55. data/vendor/faiss/faiss/gpu/GpuCloner.h +4 -0
  56. data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +3 -0
  57. data/vendor/faiss/faiss/gpu/GpuIndex.h +4 -13
  58. data/vendor/faiss/faiss/gpu/GpuIndexBinaryCagra.h +26 -13
  59. data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +45 -22
  60. data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +11 -0
  61. data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +6 -0
  62. data/vendor/faiss/faiss/gpu/test/TestGpuDatasetHeader.cpp +18 -0
  63. data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +215 -0
  64. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +98 -0
  65. data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +11 -0
  66. data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +1 -1
  67. data/vendor/faiss/faiss/gpu_metal/MetalCloner.h +11 -0
  68. data/vendor/faiss/faiss/gpu_metal/MetalDistance.h +92 -0
  69. data/vendor/faiss/faiss/gpu_metal/MetalIndex.h +4 -0
  70. data/vendor/faiss/faiss/gpu_metal/MetalIndexBinaryFlat.h +69 -0
  71. data/vendor/faiss/faiss/gpu_metal/MetalIndexIVFPQ.h +38 -0
  72. data/vendor/faiss/faiss/gpu_metal/MetalKernels.h +106 -0
  73. data/vendor/faiss/faiss/gpu_metal/MetalPythonBridge.h +10 -0
  74. data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +2 -0
  75. data/vendor/faiss/faiss/impl/AuxIndexStructures.h +1 -6
  76. data/vendor/faiss/faiss/impl/ClusteringHelpers.cpp +134 -45
  77. data/vendor/faiss/faiss/impl/ClusteringHelpers.h +36 -0
  78. data/vendor/faiss/faiss/impl/ClusteringInitialization.cpp +286 -136
  79. data/vendor/faiss/faiss/impl/DistanceComputer.cpp +63 -0
  80. data/vendor/faiss/faiss/impl/DistanceComputer.h +3 -29
  81. data/vendor/faiss/faiss/impl/HNSW.cpp +46 -10
  82. data/vendor/faiss/faiss/impl/HNSW.h +72 -0
  83. data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +6 -19
  84. data/vendor/faiss/faiss/impl/NNDescent.cpp +2 -1
  85. data/vendor/faiss/faiss/impl/NSG.cpp +3 -2
  86. data/vendor/faiss/faiss/impl/Panorama.h +3 -2
  87. data/vendor/faiss/faiss/impl/PiPNN.cpp +822 -0
  88. data/vendor/faiss/faiss/impl/PiPNN.h +122 -0
  89. data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +54 -11
  90. data/vendor/faiss/faiss/impl/RaBitQUtils.h +1 -1
  91. data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +81 -57
  92. data/vendor/faiss/faiss/impl/RaBitQuantizer.h +15 -0
  93. data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +29 -0
  94. data/vendor/faiss/faiss/impl/ScalarQuantizer.h +1 -6
  95. data/vendor/faiss/faiss/impl/approx_topk/avx2.cpp +0 -4
  96. data/vendor/faiss/faiss/impl/approx_topk/neon.cpp +0 -4
  97. data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryHash_impl.h +5 -2
  98. data/vendor/faiss/faiss/impl/binary_hamming/avx2.cpp +0 -4
  99. data/vendor/faiss/faiss/impl/binary_hamming/avx512.cpp +0 -4
  100. data/vendor/faiss/faiss/impl/binary_hamming/neon.cpp +0 -4
  101. data/vendor/faiss/faiss/impl/binary_hamming/rvv.cpp +0 -4
  102. data/vendor/faiss/faiss/impl/expanded_scanners.h +88 -0
  103. data/vendor/faiss/faiss/impl/fast_scan/FastScanDistancePostProcessing.h +4 -0
  104. data/vendor/faiss/faiss/impl/fast_scan/accumulate_loops.h +61 -64
  105. data/vendor/faiss/faiss/impl/fast_scan/accumulate_loops_512.h +13 -14
  106. data/vendor/faiss/faiss/impl/fast_scan/decompose_qbs.h +17 -129
  107. data/vendor/faiss/faiss/impl/fast_scan/dispatching.h +25 -19
  108. data/vendor/faiss/faiss/impl/fast_scan/fast_scan.cpp +5 -0
  109. data/vendor/faiss/faiss/impl/fast_scan/impl-avx2.cpp +0 -4
  110. data/vendor/faiss/faiss/impl/fast_scan/impl-avx512.cpp +0 -4
  111. data/vendor/faiss/faiss/impl/fast_scan/impl-neon.cpp +0 -88
  112. data/vendor/faiss/faiss/impl/fast_scan/impl-riscv.cpp +0 -4
  113. data/vendor/faiss/faiss/impl/fast_scan/kernels_neon.h +155 -0
  114. data/vendor/faiss/faiss/impl/fast_scan/kernels_simd256.h +22 -1
  115. data/vendor/faiss/faiss/impl/fast_scan/kernels_simd512.h +3 -2
  116. data/vendor/faiss/faiss/impl/fast_scan/simd_result_handlers.h +41 -23
  117. data/vendor/faiss/faiss/impl/hnsw/avx2.cpp +0 -4
  118. data/vendor/faiss/faiss/impl/hnsw/avx512.cpp +0 -4
  119. data/vendor/faiss/faiss/impl/index_read.cpp +172 -0
  120. data/vendor/faiss/faiss/impl/index_write.cpp +95 -0
  121. data/vendor/faiss/faiss/impl/pipnn/HashPrune.cpp +159 -0
  122. data/vendor/faiss/faiss/impl/pipnn/HashPrune.h +69 -0
  123. data/vendor/faiss/faiss/impl/pipnn/Partition.cpp +587 -0
  124. data/vendor/faiss/faiss/impl/pipnn/Partition.h +93 -0
  125. data/vendor/faiss/faiss/impl/pipnn/kernels.cpp +326 -0
  126. data/vendor/faiss/faiss/impl/pipnn/kernels.h +92 -0
  127. data/vendor/faiss/faiss/impl/platform_macros.h +45 -0
  128. data/vendor/faiss/faiss/impl/polysemous_training/avx512.cpp +0 -4
  129. data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQScanner_impl.h +79 -4
  130. data/vendor/faiss/faiss/impl/pq_code_distance/PQDistanceComputer_impl.h +6 -0
  131. data/vendor/faiss/faiss/impl/pq_code_distance/avx2.cpp +0 -4
  132. data/vendor/faiss/faiss/impl/pq_code_distance/avx512.cpp +0 -4
  133. data/vendor/faiss/faiss/impl/pq_code_distance/neon.cpp +0 -4
  134. data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-avx2.h +4 -0
  135. data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-avx512.h +4 -1
  136. data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.cpp +19 -0
  137. data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.h +6 -6
  138. data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-inl.h +131 -6
  139. data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-sve.cpp +0 -4
  140. data/vendor/faiss/faiss/impl/pq_code_distance/pq_rvv_kernel.h +89 -0
  141. data/vendor/faiss/faiss/impl/pq_code_distance/pq_scan_impl.h +21 -10
  142. data/vendor/faiss/faiss/impl/pq_code_distance/rvv.cpp +45 -18
  143. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +2 -1
  144. data/vendor/faiss/faiss/impl/result_handler/avx2.cpp +0 -4
  145. data/vendor/faiss/faiss/impl/result_handler/avx512.cpp +0 -4
  146. data/vendor/faiss/faiss/impl/scalar_quantizer/EDENQuantizer-avx2.cpp +0 -4
  147. data/vendor/faiss/faiss/impl/scalar_quantizer/EDENQuantizer-avx512.cpp +0 -4
  148. data/vendor/faiss/faiss/impl/scalar_quantizer/distance_computers.h +5 -1
  149. data/vendor/faiss/faiss/impl/scalar_quantizer/quantizers.h +28 -52
  150. data/vendor/faiss/faiss/impl/scalar_quantizer/scanners.h +59 -11
  151. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx2.cpp +226 -77
  152. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512-impl.h +482 -103
  153. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512-spr.cpp +2 -149
  154. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512.cpp +3 -698
  155. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-dispatch.h +66 -57
  156. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-neon.cpp +101 -96
  157. data/vendor/faiss/faiss/impl/scalar_quantizer/sq-rvv.cpp +3185 -144
  158. data/vendor/faiss/faiss/impl/scalar_quantizer/sq8_coefficients.h +48 -0
  159. data/vendor/faiss/faiss/impl/scalar_quantizer/sq8_rvv_kernel.h +546 -0
  160. data/vendor/faiss/faiss/impl/scalar_quantizer/training.cpp +2 -2
  161. data/vendor/faiss/faiss/impl/simd_dispatch.h +7 -0
  162. data/vendor/faiss/faiss/impl/simdlib/simdlib_avx2.h +14 -0
  163. data/vendor/faiss/faiss/impl/simdlib/simdlib_dispatch.h +7 -8
  164. data/vendor/faiss/faiss/impl/sq_fastscan_utils.h +232 -0
  165. data/vendor/faiss/faiss/index_factory.cpp +76 -0
  166. data/vendor/faiss/faiss/invlists/InvertedLists.cpp +3 -1
  167. data/vendor/faiss/faiss/svs/IndexSVSVamana.h +3 -2
  168. data/vendor/faiss/faiss/utils/AlignedTable.h +6 -1
  169. data/vendor/faiss/faiss/utils/Heap.cpp +4 -3
  170. data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +16 -5
  171. data/vendor/faiss/faiss/utils/bf16.h +36 -0
  172. data/vendor/faiss/faiss/utils/distances.cpp +226 -15
  173. data/vendor/faiss/faiss/utils/distances.h +34 -0
  174. data/vendor/faiss/faiss/utils/distances_dispatch.h +6 -4
  175. data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +2 -5
  176. data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +0 -14
  177. data/vendor/faiss/faiss/utils/distances_fused/rvv.cpp +25 -0
  178. data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +0 -4
  179. data/vendor/faiss/faiss/utils/distances_fused/simdlib_based_neon.cpp +0 -4
  180. data/vendor/faiss/faiss/utils/distances_fused/simdlib_kernel-inl.h +2 -1
  181. data/vendor/faiss/faiss/utils/distances_simd.cpp +9 -0
  182. data/vendor/faiss/faiss/utils/fp16-fp16c.h +4 -0
  183. data/vendor/faiss/faiss/utils/fp16-inl.h +26 -52
  184. data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx2.cpp +0 -4
  185. data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx512.cpp +0 -4
  186. data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx512_vpopcnt.cpp +0 -4
  187. data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-avx512.h +33 -5
  188. data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-avx512_vpopcnt.h +15 -30
  189. data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-neon.h +0 -4
  190. data/vendor/faiss/faiss/utils/hamming_distance/hamming_impl.h +2 -1
  191. data/vendor/faiss/faiss/utils/hamming_distance/hamming_neon.cpp +0 -4
  192. data/vendor/faiss/faiss/utils/hamming_distance/hamming_rvv.cpp +0 -4
  193. data/vendor/faiss/faiss/utils/pq_code_distance.h +8 -4
  194. data/vendor/faiss/faiss/utils/prefetch.h +1 -26
  195. data/vendor/faiss/faiss/utils/quantize_lut.cpp +26 -27
  196. data/vendor/faiss/faiss/utils/quantize_lut.h +11 -0
  197. data/vendor/faiss/faiss/utils/rabitq_simd.h +51 -16
  198. data/vendor/faiss/faiss/utils/simd_impl/distances_aarch64.cpp +9 -4
  199. data/vendor/faiss/faiss/utils/simd_impl/distances_arm_sve.cpp +37 -5
  200. data/vendor/faiss/faiss/utils/simd_impl/distances_avx2.cpp +64 -5
  201. data/vendor/faiss/faiss/utils/simd_impl/distances_avx512.cpp +64 -5
  202. data/vendor/faiss/faiss/utils/simd_impl/distances_rvv.cpp +353 -71
  203. data/vendor/faiss/faiss/utils/simd_impl/distances_rvv_kernel.h +68 -0
  204. data/vendor/faiss/faiss/utils/simd_impl/exhaustive_L2sqr_blas_cmax.h +93 -0
  205. data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels.h +76 -0
  206. data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels_avx2.cpp +52 -0
  207. data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels_avx512.cpp +52 -0
  208. data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels_neon.cpp +48 -0
  209. data/vendor/faiss/faiss/utils/simd_impl/masked_sum-avx2.h +44 -0
  210. data/vendor/faiss/faiss/utils/simd_impl/masked_sum-avx512.h +43 -0
  211. data/vendor/faiss/faiss/utils/simd_impl/masked_sum.h +38 -0
  212. data/vendor/faiss/faiss/utils/simd_impl/partitioning_avx2.cpp +0 -4
  213. data/vendor/faiss/faiss/utils/simd_impl/partitioning_neon.cpp +0 -4
  214. data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx2.cpp +54 -15
  215. data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx512.cpp +38 -21
  216. data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx512_vpopcnt.cpp +51 -14
  217. data/vendor/faiss/faiss/utils/simd_impl/rabitq_neon.cpp +297 -10
  218. data/vendor/faiss/faiss/utils/simd_impl/rabitq_rvv.cpp +0 -4
  219. data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_avx2.cpp +0 -4
  220. data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_avx512.cpp +0 -4
  221. data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_sve.cpp +0 -4
  222. data/vendor/faiss/faiss/utils/simd_levels.cpp +19 -3
  223. data/vendor/faiss/faiss/utils/simd_levels.h +74 -1
  224. data/vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h +0 -4
  225. data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +0 -4
  226. data/vendor/faiss/faiss/utils/utils.cpp +80 -0
  227. data/vendor/faiss/faiss/utils/utils.h +24 -0
  228. metadata +33 -1
@@ -18,7 +18,10 @@ namespace pq_code_distance {
18
18
  // the AVX2 version, which is somewhat unexpected.
19
19
  // This version is kept for completeness.
20
20
  //
21
- // TODO: test for AMD CPUs.
21
+ // On AMD Zen 4/5 (SIMDConfig::scalar_gather) the scalar kernel is up to 48%
22
+ // faster at M >= 16. Below M = 16 this kernel has no gather and its loop is
23
+ // as fast or faster, so it is kept there. The callers select the scalar
24
+ // kernel with use_scalar_8bit_kernel().
22
25
 
23
26
  // NOLINTNEXTLINE(facebook-hte-MisplacedTemplateSpecialization)
24
27
  template <>
@@ -40,11 +40,16 @@ void pq_scan_8bit(
40
40
  });
41
41
  }
42
42
 
43
+ // NONE: only the files of level SL may instantiate PQCodeDistanceScalar8<SL>.
43
44
  float pq_code_distance_8bit_single(
44
45
  size_t M,
45
46
  const float* sim_table,
46
47
  const uint8_t* code) {
47
48
  return with_simd_level_with_sve([&]<SIMDLevel SL>() {
49
+ if (use_scalar_8bit_kernel<SL>(M)) {
50
+ return PQCodeDistanceScalar8<SIMDLevel::NONE>::distance_single_code(
51
+ M, sim_table, code);
52
+ }
48
53
  return pq_code_distance_8bit_single_impl<SL>(M, sim_table, code);
49
54
  });
50
55
  }
@@ -61,6 +66,20 @@ void pq_code_distance_8bit_four(
61
66
  float& result2,
62
67
  float& result3) {
63
68
  with_simd_level_with_sve([&]<SIMDLevel SL>() {
69
+ if (use_scalar_8bit_kernel<SL>(M)) {
70
+ PQCodeDistanceScalar8<SIMDLevel::NONE>::distance_four_codes(
71
+ M,
72
+ sim_table,
73
+ code0,
74
+ code1,
75
+ code2,
76
+ code3,
77
+ result0,
78
+ result1,
79
+ result2,
80
+ result3);
81
+ return;
82
+ }
64
83
  pq_code_distance_8bit_four_impl<SL>(
65
84
  M,
66
85
  sim_table,
@@ -20,8 +20,8 @@ inline float pq_code_distance_8bit_single_impl<SIMDLevel::NONE>(
20
20
  size_t M,
21
21
  const float* sim_table,
22
22
  const uint8_t* code) {
23
- return PQCodeDistanceScalar<PQDecoder8>::distance_single_code(
24
- M, 8, sim_table, code);
23
+ return PQCodeDistanceScalar<PQDecoder8, SIMDLevel::NONE>::
24
+ distance_single_code(M, 8, sim_table, code);
25
25
  }
26
26
 
27
27
  // NOLINTNEXTLINE(facebook-hte-MisplacedTemplateSpecialization)
@@ -37,7 +37,7 @@ inline void pq_code_distance_8bit_four_impl<SIMDLevel::NONE>(
37
37
  float& result1,
38
38
  float& result2,
39
39
  float& result3) {
40
- PQCodeDistanceScalar<PQDecoder8>::distance_four_codes(
40
+ PQCodeDistanceScalar<PQDecoder8, SIMDLevel::NONE>::distance_four_codes(
41
41
  M,
42
42
  8,
43
43
  sim_table,
@@ -60,8 +60,8 @@ inline float pq_code_distance_8bit_single_impl<SIMDLevel::ARM_NEON>(
60
60
  size_t M,
61
61
  const float* sim_table,
62
62
  const uint8_t* code) {
63
- return PQCodeDistanceScalar<PQDecoder8>::distance_single_code(
64
- M, 8, sim_table, code);
63
+ return PQCodeDistanceScalar<PQDecoder8, SIMDLevel::ARM_NEON>::
64
+ distance_single_code(M, 8, sim_table, code);
65
65
  }
66
66
 
67
67
  // NOLINTNEXTLINE(facebook-hte-MisplacedTemplateSpecialization)
@@ -77,7 +77,7 @@ inline void pq_code_distance_8bit_four_impl<SIMDLevel::ARM_NEON>(
77
77
  float& result1,
78
78
  float& result2,
79
79
  float& result3) {
80
- PQCodeDistanceScalar<PQDecoder8>::distance_four_codes(
80
+ PQCodeDistanceScalar<PQDecoder8, SIMDLevel::ARM_NEON>::distance_four_codes(
81
81
  M,
82
82
  8,
83
83
  sim_table,
@@ -23,6 +23,7 @@
23
23
  #include <faiss/impl/ProductQuantizer.h>
24
24
  #include <faiss/impl/platform_macros.h>
25
25
  #include <faiss/impl/simd_dispatch.h>
26
+ #include <faiss/utils/simd_levels.h>
26
27
 
27
28
  namespace faiss {
28
29
  namespace pq_code_distance {
@@ -62,10 +63,14 @@ namespace pq_code_distance {
62
63
  *********************************************************************/
63
64
 
64
65
  /// Scalar PQ code distance implementation.
65
- /// Templated only on decoder type, independent of SIMD level.
66
66
  /// Used directly by non-PQDecoder8 decoders (PQDecoder16,
67
67
  /// PQDecoderGeneric) and as fallback for PQDecoder8 at NONE/NEON.
68
- template <typename PQDecoderT>
68
+ // SL keeps each SIMD-level TU's instantiation a distinct symbol. Without it
69
+ // the linker merges them and may keep one compiled with -mavx512*, which
70
+ // then runs on the AVX2 path and raises SIGILL on CPUs without AVX512.
71
+ // The default keeps callers outside faiss that name only the decoder (e.g.
72
+ // unicorn/features/encoders/PQFSTable.h) compiling; faiss passes SL itself.
73
+ template <typename PQDecoderT, SIMDLevel SL = SIMDLevel::NONE>
69
74
  struct PQCodeDistanceScalar {
70
75
  using PQDecoder = PQDecoderT;
71
76
 
@@ -124,6 +129,125 @@ struct PQCodeDistanceScalar {
124
129
  }
125
130
  };
126
131
 
132
+ /// 8-bit scalar kernel with four partial sums (one running sum serializes on
133
+ /// add latency). Used instead of the gather kernels where
134
+ /// SIMDConfig::scalar_gather is set. Both functions use the same per-code
135
+ /// summation order (partial sum m % 4, tail into the first), so single-code
136
+ /// and four-code results are bit-identical. SL as in PQCodeDistanceScalar.
137
+ template <SIMDLevel SL>
138
+ struct PQCodeDistanceScalar8 {
139
+ static constexpr size_t ksub = 256;
140
+
141
+ static float distance_single_code(
142
+ size_t M,
143
+ const float* tab,
144
+ const uint8_t* code) {
145
+ float a[4] = {};
146
+ size_t m = 0;
147
+ for (; m + 4 <= M; m += 4, tab += 4 * ksub) {
148
+ for (size_t j = 0; j < 4; j++) {
149
+ a[j] += tab[j * ksub + code[m + j]];
150
+ }
151
+ }
152
+ for (; m < M; m++, tab += ksub) {
153
+ a[0] += tab[code[m]];
154
+ }
155
+ return (a[0] + a[1]) + (a[2] + a[3]);
156
+ }
157
+
158
+ static void distance_four_codes(
159
+ size_t M,
160
+ const float* tab,
161
+ const uint8_t* __restrict code0,
162
+ const uint8_t* __restrict code1,
163
+ const uint8_t* __restrict code2,
164
+ const uint8_t* __restrict code3,
165
+ float& result0,
166
+ float& result1,
167
+ float& result2,
168
+ float& result3) {
169
+ const uint8_t* codes[4] = {code0, code1, code2, code3};
170
+ float a[4][4] = {};
171
+ size_t m = 0;
172
+ for (; m + 4 <= M; m += 4, tab += 4 * ksub) {
173
+ for (size_t j = 0; j < 4; j++) {
174
+ for (size_t c = 0; c < 4; c++) {
175
+ a[c][j] += tab[j * ksub + codes[c][m + j]];
176
+ }
177
+ }
178
+ }
179
+ for (; m < M; m++, tab += ksub) {
180
+ for (size_t c = 0; c < 4; c++) {
181
+ a[c][0] += tab[codes[c][m]];
182
+ }
183
+ }
184
+ float* out[4] = {&result0, &result1, &result2, &result3};
185
+ for (size_t c = 0; c < 4; c++) {
186
+ *out[c] = (a[c][0] + a[c][1]) + (a[c][2] + a[c][3]);
187
+ }
188
+ }
189
+ };
190
+
191
+ /// SIMDConfig::scalar_gather is set and the gather kernel of level SL is
192
+ /// slower than PQCodeDistanceScalar8: the AVX2 kernel at any M, the AVX-512
193
+ /// kernel at M >= 16. The callers check this once per scan, not per code.
194
+ template <SIMDLevel SL>
195
+ inline bool use_scalar_8bit_kernel(size_t M) {
196
+ if constexpr (SL == SIMDLevel::AVX2) {
197
+ return SIMDConfig::scalar_gather;
198
+ } else if constexpr (SL == SIMDLevel::AVX512) {
199
+ return SIMDConfig::scalar_gather && M >= 16;
200
+ } else {
201
+ return false;
202
+ }
203
+ }
204
+
205
+ template <SIMDLevel SL>
206
+ constexpr bool has_scalar_8bit_kernel() {
207
+ return SL == SIMDLevel::AVX2 || SL == SIMDLevel::AVX512;
208
+ }
209
+
210
+ /// PQCodeDistance interface of PQCodeDistanceScalar8.
211
+ template <SIMDLevel SL>
212
+ struct PQCodeDistanceScalar8Dist {
213
+ using PQDecoder = PQDecoder8;
214
+ static constexpr SIMDLevel simd_level = SL;
215
+
216
+ static float distance_single_code(
217
+ size_t M,
218
+ size_t /* nbits */,
219
+ const float* sim_table,
220
+ const uint8_t* code) {
221
+ return PQCodeDistanceScalar8<SL>::distance_single_code(
222
+ M, sim_table, code);
223
+ }
224
+
225
+ static void distance_four_codes(
226
+ size_t M,
227
+ size_t /* nbits */,
228
+ const float* sim_table,
229
+ const uint8_t* __restrict code0,
230
+ const uint8_t* __restrict code1,
231
+ const uint8_t* __restrict code2,
232
+ const uint8_t* __restrict code3,
233
+ float& result0,
234
+ float& result1,
235
+ float& result2,
236
+ float& result3) {
237
+ PQCodeDistanceScalar8<SL>::distance_four_codes(
238
+ M,
239
+ sim_table,
240
+ code0,
241
+ code1,
242
+ code2,
243
+ code3,
244
+ result0,
245
+ result1,
246
+ result2,
247
+ result3);
248
+ }
249
+ };
250
+
127
251
  /*********************************************************************
128
252
  * Dispatch bridge — function templates for PQDecoder8 SIMD dispatch.
129
253
  *
@@ -168,7 +292,7 @@ struct PQCodeDistance {
168
292
  if constexpr (std::is_same_v<PQDecoderT, PQDecoder8>) {
169
293
  return pq_code_distance_8bit_single_impl<SL>(M, sim_table, code);
170
294
  } else {
171
- return PQCodeDistanceScalar<PQDecoderT>::distance_single_code(
295
+ return PQCodeDistanceScalar<PQDecoderT, SL>::distance_single_code(
172
296
  M, nbits, sim_table, code);
173
297
  }
174
298
  }
@@ -198,7 +322,7 @@ struct PQCodeDistance {
198
322
  result2,
199
323
  result3);
200
324
  } else {
201
- PQCodeDistanceScalar<PQDecoderT>::distance_four_codes(
325
+ PQCodeDistanceScalar<PQDecoderT, SL>::distance_four_codes(
202
326
  M,
203
327
  nbits,
204
328
  sim_table,
@@ -250,8 +374,9 @@ FAISS_API void pq_code_distance_8bit_four(
250
374
  *
251
375
  * Scans all ncodes PQ codes against a precomputed distance table,
252
376
  * maintaining a k-nearest-neighbor heap. Uses the SIMD PQ distance
253
- * kernels (AVX2 gathers, etc.) for the inner loop, with the SIMD
254
- * gathers inlined into the scan loop in each per-SIMD TU.
377
+ * kernels (AVX2 gathers, etc.), or PQCodeDistanceScalar8 where
378
+ * use_scalar_8bit_kernel() selects it, inlined into the scan loop in
379
+ * each per-SIMD TU.
255
380
  *
256
381
  * Definitions are in pq_scan_impl.h (per-SIMD TUs) and
257
382
  * pq_code_distance-generic.cpp (dispatch wrapper).
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #ifdef COMPILE_SIMD_ARM_SVE
9
-
10
8
  #include <arm_sve.h>
11
9
 
12
10
  #include <faiss/impl/pq_code_distance/pq_code_distance-inl.h>
@@ -351,5 +349,3 @@ void pq_code_distance_8bit_four_impl<SIMDLevel::ARM_SVE>(
351
349
  // NOLINTNEXTLINE(facebook-hte-InlineHeader)
352
350
  #include <faiss/impl/pq_code_distance/pq_scan_impl.h>
353
351
  #undef THE_SIMD_LEVEL
354
-
355
- #endif // COMPILE_SIMD_ARM_SVE
@@ -0,0 +1,89 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ #pragma once
9
+
10
+ /* 8-bit product-quantizer code distance for RISC-V Vector.
11
+ *
12
+ * Free-standing (no exceptions, heap or threads), so a freestanding RISC-V
13
+ * target can compile it. pq_code_distance/rvv.cpp calls it; no Buck target
14
+ * here builds that RISC-V CPU path.
15
+ *
16
+ * PQDecoder8 fixes nbits = 8, so ksub = 256 and the scalar loop is
17
+ *
18
+ * for (m = 0; m < M; m++) result += sim_table[m * 256 + code[m]];
19
+ *
20
+ * That is a gather, not a contiguous read. RVV issues one vluxei32 per strip:
21
+ * build the element offset m * 256 + code[m] across the lanes, scale it to
22
+ * bytes, then index sim_table.
23
+ *
24
+ * The offset stays inside uint32 while M * 256 * 4 bytes does. At M = 1024
25
+ * that is 1 MiB, so no PQ shape in Faiss overflows it.
26
+ *
27
+ * The accumulator is LMUL 4, as in utils/simd_impl/distances_rvv_kernel.h.
28
+ * The lanes add the M terms in a different order than the scalar loop, so
29
+ * the last bits can differ.
30
+ */
31
+
32
+ #include <cstddef>
33
+ #include <cstdint>
34
+
35
+ #include <riscv_vector.h>
36
+
37
+ namespace faiss {
38
+ namespace pq_rvv_kernel {
39
+
40
+ /// Element offsets into sim_table for subquantizers [m, m + vl).
41
+ inline vuint32m4_t row_offsets(size_t m, size_t vl) {
42
+ // (m + lane) * 256
43
+ vuint32m4_t row = __riscv_vadd_vx_u32m4(__riscv_vid_v_u32m4(vl), m, vl);
44
+ return __riscv_vsll_vx_u32m4(row, 8, vl);
45
+ }
46
+
47
+ /// Byte offsets for one code, given the precomputed row offsets.
48
+ inline vuint32m4_t byte_offsets(
49
+ vuint32m4_t row_off,
50
+ const uint8_t* code,
51
+ size_t m,
52
+ size_t vl) {
53
+ vuint8m1_t cb = __riscv_vle8_v_u8m1(code + m, vl);
54
+ vuint32m4_t idx = __riscv_vzext_vf4_u32m4(cb, vl);
55
+ // (row + code) * sizeof(float)
56
+ return __riscv_vsll_vx_u32m4(
57
+ __riscv_vadd_vv_u32m4(row_off, idx, vl), 2, vl);
58
+ }
59
+
60
+ inline float reduce(vfloat32m4_t acc, size_t vlmax) {
61
+ vfloat32m1_t zero = __riscv_vfmv_v_f_f32m1(0.0f, 1);
62
+ vfloat32m1_t sum = __riscv_vfredusum_vs_f32m4_f32m1(acc, zero, vlmax);
63
+ return __riscv_vfmv_f_s_f32m1_f32(sum);
64
+ }
65
+
66
+ /// Distance between a query and one 8-bit PQ code.
67
+ /// @param sim_table M * 256 floats, laid out (M, ksub)
68
+ inline float distance_8bit(
69
+ size_t M,
70
+ const float* sim_table,
71
+ const uint8_t* code) {
72
+ const size_t vlmax = __riscv_vsetvlmax_e32m4();
73
+ vfloat32m4_t acc = __riscv_vfmv_v_f_f32m4(0.0f, vlmax);
74
+
75
+ size_t m = 0;
76
+ while (m < M) {
77
+ const size_t vl = __riscv_vsetvl_e32m4(M - m);
78
+ vuint32m4_t off = byte_offsets(row_offsets(m, vl), code, m, vl);
79
+ vfloat32m4_t v = __riscv_vluxei32_v_f32m4(sim_table, off, vl);
80
+ // Tail-undisturbed: lanes past vl keep earlier partial sums, and the
81
+ // final reduction covers vlmax.
82
+ acc = __riscv_vfadd_vv_f32m4_tu(acc, acc, v, vl);
83
+ m += vl;
84
+ }
85
+ return reduce(acc, vlmax);
86
+ }
87
+
88
+ } // namespace pq_rvv_kernel
89
+ } // namespace faiss
@@ -19,7 +19,7 @@ namespace pq_code_distance {
19
19
 
20
20
  namespace {
21
21
 
22
- template <class C>
22
+ template <class C, class PQCodeDist>
23
23
  void pq_scan_8bit_at_level(
24
24
  size_t M,
25
25
  const float* dis_table,
@@ -33,8 +33,9 @@ void pq_scan_8bit_at_level(
33
33
  size_t j = 0;
34
34
  for (; j + 3 < ncodes; j += 4) {
35
35
  float d0, d1, d2, d3;
36
- pq_code_distance_8bit_four_impl<THE_SIMD_LEVEL>( // NOLINT(facebook-modularize-issue-check)
36
+ PQCodeDist::distance_four_codes(
37
37
  M,
38
+ 8,
38
39
  dis_table,
39
40
  codes + j * code_size,
40
41
  codes + (j + 1) * code_size,
@@ -60,8 +61,8 @@ void pq_scan_8bit_at_level(
60
61
  }
61
62
 
62
63
  for (; j < ncodes; j++) {
63
- float dis = pq_code_distance_8bit_single_impl<THE_SIMD_LEVEL>( // NOLINT(facebook-modularize-issue-check)
64
- M, dis_table, codes + j * code_size);
64
+ float dis = PQCodeDist::distance_single_code(
65
+ M, 8, dis_table, codes + j * code_size);
65
66
  if (C::cmp(heap_dis[0], dis)) {
66
67
  heap_replace_top<C>(k, heap_dis, heap_ids, dis, j);
67
68
  }
@@ -92,13 +93,23 @@ void pq_scan_8bit_impl<THE_SIMD_LEVEL>(
92
93
  float* heap_dis,
93
94
  int64_t* heap_ids,
94
95
  bool max_heap) {
95
- if (max_heap) {
96
- pq_scan_8bit_at_level<CMax<float, int64_t>>(
97
- M, dis_table, codes, ncodes, k, heap_dis, heap_ids);
98
- } else {
99
- pq_scan_8bit_at_level<CMin<float, int64_t>>(
100
- M, dis_table, codes, ncodes, k, heap_dis, heap_ids);
96
+ auto scan = [&]<class PQCodeDist>() {
97
+ if (max_heap) {
98
+ pq_scan_8bit_at_level<CMax<float, int64_t>, PQCodeDist>(
99
+ M, dis_table, codes, ncodes, k, heap_dis, heap_ids);
100
+ } else {
101
+ pq_scan_8bit_at_level<CMin<float, int64_t>, PQCodeDist>(
102
+ M, dis_table, codes, ncodes, k, heap_dis, heap_ids);
103
+ }
104
+ };
105
+ if constexpr (has_scalar_8bit_kernel<THE_SIMD_LEVEL>()) {
106
+ if (use_scalar_8bit_kernel<THE_SIMD_LEVEL>(M)) {
107
+ scan.template
108
+ operator()<PQCodeDistanceScalar8Dist<THE_SIMD_LEVEL>>();
109
+ return;
110
+ }
101
111
  }
112
+ scan.template operator()<PQCodeDistance<PQDecoder8, THE_SIMD_LEVEL>>();
102
113
  }
103
114
 
104
115
  } // namespace pq_code_distance
@@ -5,14 +5,15 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #ifdef COMPILE_SIMD_RISCV_RVV
8
+ #include <riscv_vector.h>
9
9
 
10
10
  #include <faiss/impl/pq_code_distance/pq_code_distance-inl.h>
11
+ #include <faiss/impl/pq_code_distance/pq_rvv_kernel.h>
11
12
 
12
13
  namespace faiss {
13
14
  namespace pq_code_distance {
14
15
 
15
- // RISCV_RVV: no RVV-optimized PQ code distance exists yet. Use scalar.
16
+ // The kernel lives in pq_rvv_kernel.h. See that header for the gather layout.
16
17
 
17
18
  // NOLINTNEXTLINE(facebook-hte-MisplacedTemplateSpecialization)
18
19
  template <>
@@ -20,8 +21,7 @@ float pq_code_distance_8bit_single_impl<SIMDLevel::RISCV_RVV>(
20
21
  size_t M,
21
22
  const float* sim_table,
22
23
  const uint8_t* code) {
23
- return PQCodeDistanceScalar<PQDecoder8>::distance_single_code(
24
- M, 8, sim_table, code);
24
+ return pq_rvv_kernel::distance_8bit(M, sim_table, code);
25
25
  }
26
26
 
27
27
  // NOLINTNEXTLINE(facebook-hte-MisplacedTemplateSpecialization)
@@ -37,18 +37,47 @@ void pq_code_distance_8bit_four_impl<SIMDLevel::RISCV_RVV>(
37
37
  float& result1,
38
38
  float& result2,
39
39
  float& result3) {
40
- PQCodeDistanceScalar<PQDecoder8>::distance_four_codes(
41
- M,
42
- 8,
43
- sim_table,
44
- code0,
45
- code1,
46
- code2,
47
- code3,
48
- result0,
49
- result1,
50
- result2,
51
- result3);
40
+ const size_t vlmax = __riscv_vsetvlmax_e32m4();
41
+ vfloat32m4_t acc0 = __riscv_vfmv_v_f_f32m4(0.0f, vlmax);
42
+ vfloat32m4_t acc1 = __riscv_vfmv_v_f_f32m4(0.0f, vlmax);
43
+ vfloat32m4_t acc2 = __riscv_vfmv_v_f_f32m4(0.0f, vlmax);
44
+ vfloat32m4_t acc3 = __riscv_vfmv_v_f_f32m4(0.0f, vlmax);
45
+
46
+ size_t m = 0;
47
+ while (m < M) {
48
+ const size_t vl = __riscv_vsetvl_e32m4(M - m);
49
+ // The row term is the same for all four codes, so compute it once.
50
+ vuint32m4_t row_off = pq_rvv_kernel::row_offsets(m, vl);
51
+
52
+ vfloat32m4_t v0 = __riscv_vluxei32_v_f32m4(
53
+ sim_table,
54
+ pq_rvv_kernel::byte_offsets(row_off, code0, m, vl),
55
+ vl);
56
+ vfloat32m4_t v1 = __riscv_vluxei32_v_f32m4(
57
+ sim_table,
58
+ pq_rvv_kernel::byte_offsets(row_off, code1, m, vl),
59
+ vl);
60
+ vfloat32m4_t v2 = __riscv_vluxei32_v_f32m4(
61
+ sim_table,
62
+ pq_rvv_kernel::byte_offsets(row_off, code2, m, vl),
63
+ vl);
64
+ vfloat32m4_t v3 = __riscv_vluxei32_v_f32m4(
65
+ sim_table,
66
+ pq_rvv_kernel::byte_offsets(row_off, code3, m, vl),
67
+ vl);
68
+
69
+ acc0 = __riscv_vfadd_vv_f32m4_tu(acc0, acc0, v0, vl);
70
+ acc1 = __riscv_vfadd_vv_f32m4_tu(acc1, acc1, v1, vl);
71
+ acc2 = __riscv_vfadd_vv_f32m4_tu(acc2, acc2, v2, vl);
72
+ acc3 = __riscv_vfadd_vv_f32m4_tu(acc3, acc3, v3, vl);
73
+
74
+ m += vl;
75
+ }
76
+
77
+ result0 = pq_rvv_kernel::reduce(acc0, vlmax);
78
+ result1 = pq_rvv_kernel::reduce(acc1, vlmax);
79
+ result2 = pq_rvv_kernel::reduce(acc2, vlmax);
80
+ result3 = pq_rvv_kernel::reduce(acc3, vlmax);
52
81
  }
53
82
 
54
83
  } // namespace pq_code_distance
@@ -66,5 +95,3 @@ void pq_code_distance_8bit_four_impl<SIMDLevel::RISCV_RVV>(
66
95
  #include <faiss/impl/pq_code_distance/IVFPQScanner_impl.h>
67
96
 
68
97
  #undef THE_SIMD_LEVEL
69
-
70
- #endif // COMPILE_SIMD_RISCV_RVV
@@ -17,6 +17,7 @@
17
17
 
18
18
  #include <faiss/impl/approx_topk/approx_topk.h>
19
19
  #include <faiss/impl/approx_topk/rq_beam_search_tab.h>
20
+ #include <faiss/impl/platform_macros.h>
20
21
 
21
22
  extern "C" {
22
23
 
@@ -367,7 +368,7 @@ void beam_search_encode_step_tab(
367
368
 
368
369
  // Resolve SIMD level once, not per iteration of the n-parallel loop.
369
370
  with_simd_level_256bit([&]<SIMDLevel SL>() {
370
- #pragma omp parallel for if (n > 100) schedule(dynamic)
371
+ #pragma omp parallel for if (n > 100) schedule(FAISS_OMP_DYNAMIC)
371
372
  for (int64_t i = 0; i < static_cast<int64_t>(n); i++) {
372
373
  std::vector<float> cent_distances(beam_size * K);
373
374
  std::vector<float> cd_common(K);
@@ -8,8 +8,6 @@
8
8
  // AVX2 specialisation of Top1 add_results (8-wide branchless argmin/argmax).
9
9
  // Reservoir stays on the NONE path — VPCOMPRESSPS requires AVX512F.
10
10
 
11
- #ifdef COMPILE_SIMD_AVX2
12
-
13
11
  #include <faiss/impl/ResultHandler.h>
14
12
 
15
13
  #include <immintrin.h>
@@ -129,5 +127,3 @@ void top1_add_results_tpl<CMin<float, int64_t>, true, SIMDLevel::AVX2>(
129
127
  }
130
128
 
131
129
  } // namespace faiss
132
-
133
- #endif // COMPILE_SIMD_AVX2
@@ -11,8 +11,6 @@
11
11
  // Reservoir: VPCOMPRESSPS / VPCOMPRESSD bulk-insert of passing elements,
12
12
  // eliminating the per-element threshold branch entirely.
13
13
 
14
- #ifdef COMPILE_SIMD_AVX512
15
-
16
14
  #include <faiss/impl/ResultHandler.h>
17
15
  #include <faiss/utils/popcount.h>
18
16
 
@@ -277,5 +275,3 @@ void reservoir_add_results_tpl<CMin<float, int64_t>, true, SIMDLevel::AVX512>(
277
275
  }
278
276
 
279
277
  } // namespace faiss
280
-
281
- #endif // COMPILE_SIMD_AVX512
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #ifdef COMPILE_SIMD_AVX2
9
-
10
8
  #include <faiss/impl/EDENQuantizer.h>
11
9
  #include <faiss/impl/simdlib/simdlib_avx2.h>
12
10
 
@@ -68,5 +66,3 @@ void compute_code_dot_lut_batch_8_avx2(
68
66
  } // namespace eden_distance
69
67
 
70
68
  } // namespace faiss
71
-
72
- #endif
@@ -5,8 +5,6 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- #ifdef COMPILE_SIMD_AVX512
9
-
10
8
  #include <faiss/impl/EDENQuantizer.h>
11
9
  #include <faiss/impl/simdlib/simdlib_avx2.h>
12
10
  #include <faiss/impl/simdlib/simdlib_avx512.h>
@@ -224,5 +222,3 @@ void compute_code_dot_lut_batch_16_avx512(
224
222
  } // namespace eden_distance
225
223
 
226
224
  } // namespace faiss
227
-
228
- #endif
@@ -22,7 +22,11 @@ using SQDistanceComputer = ScalarQuantizer::SQDistanceComputer;
22
22
  * code-to-vector or code-to-code comparisons
23
23
  *******************************************************************/
24
24
 
25
- template <class Quantizer, class Similarity, SIMDLevel SL>
25
+ template <
26
+ class Quantizer,
27
+ class Similarity,
28
+ SIMDLevel SL,
29
+ bool four_acc = false>
26
30
  struct DCTemplate : SQDistanceComputer {};
27
31
 
28
32
  template <class Quantizer, class Similarity>