faiss 0.3.2 → 0.3.4

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 (295) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/LICENSE.txt +1 -1
  4. data/ext/faiss/extconf.rb +1 -1
  5. data/ext/faiss/index.cpp +10 -14
  6. data/ext/faiss/numo.hpp +957 -833
  7. data/lib/faiss/version.rb +1 -1
  8. data/vendor/faiss/faiss/AutoTune.cpp +2 -2
  9. data/vendor/faiss/faiss/AutoTune.h +2 -2
  10. data/vendor/faiss/faiss/Clustering.cpp +2 -2
  11. data/vendor/faiss/faiss/Clustering.h +2 -2
  12. data/vendor/faiss/faiss/IVFlib.cpp +2 -2
  13. data/vendor/faiss/faiss/IVFlib.h +2 -2
  14. data/vendor/faiss/faiss/Index.cpp +6 -2
  15. data/vendor/faiss/faiss/Index.h +10 -3
  16. data/vendor/faiss/faiss/Index2Layer.cpp +2 -2
  17. data/vendor/faiss/faiss/Index2Layer.h +2 -2
  18. data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +7 -7
  19. data/vendor/faiss/faiss/IndexAdditiveQuantizer.h +2 -2
  20. data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +14 -16
  21. data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +2 -2
  22. data/vendor/faiss/faiss/IndexBinary.cpp +13 -2
  23. data/vendor/faiss/faiss/IndexBinary.h +8 -2
  24. data/vendor/faiss/faiss/IndexBinaryFlat.cpp +2 -3
  25. data/vendor/faiss/faiss/IndexBinaryFlat.h +2 -2
  26. data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +2 -2
  27. data/vendor/faiss/faiss/IndexBinaryFromFloat.h +2 -2
  28. data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +2 -7
  29. data/vendor/faiss/faiss/IndexBinaryHNSW.h +2 -2
  30. data/vendor/faiss/faiss/IndexBinaryHash.cpp +2 -3
  31. data/vendor/faiss/faiss/IndexBinaryHash.h +2 -2
  32. data/vendor/faiss/faiss/IndexBinaryIVF.cpp +2 -2
  33. data/vendor/faiss/faiss/IndexBinaryIVF.h +2 -2
  34. data/vendor/faiss/faiss/IndexFastScan.cpp +10 -14
  35. data/vendor/faiss/faiss/IndexFastScan.h +11 -2
  36. data/vendor/faiss/faiss/IndexFlat.cpp +2 -3
  37. data/vendor/faiss/faiss/IndexFlat.h +2 -2
  38. data/vendor/faiss/faiss/IndexFlatCodes.cpp +11 -2
  39. data/vendor/faiss/faiss/IndexFlatCodes.h +5 -2
  40. data/vendor/faiss/faiss/IndexHNSW.cpp +13 -6
  41. data/vendor/faiss/faiss/IndexHNSW.h +2 -2
  42. data/vendor/faiss/faiss/IndexIDMap.cpp +19 -3
  43. data/vendor/faiss/faiss/IndexIDMap.h +5 -2
  44. data/vendor/faiss/faiss/IndexIVF.cpp +2 -3
  45. data/vendor/faiss/faiss/IndexIVF.h +5 -4
  46. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +6 -7
  47. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +2 -2
  48. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +3 -14
  49. data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +2 -4
  50. data/vendor/faiss/faiss/IndexIVFFastScan.cpp +71 -34
  51. data/vendor/faiss/faiss/IndexIVFFastScan.h +19 -2
  52. data/vendor/faiss/faiss/IndexIVFFlat.cpp +2 -2
  53. data/vendor/faiss/faiss/IndexIVFFlat.h +2 -2
  54. data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.cpp +2 -2
  55. data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.h +2 -2
  56. data/vendor/faiss/faiss/IndexIVFPQ.cpp +2 -3
  57. data/vendor/faiss/faiss/IndexIVFPQ.h +2 -2
  58. data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +7 -33
  59. data/vendor/faiss/faiss/IndexIVFPQFastScan.h +2 -4
  60. data/vendor/faiss/faiss/IndexIVFPQR.cpp +2 -2
  61. data/vendor/faiss/faiss/IndexIVFPQR.h +2 -2
  62. data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +2 -3
  63. data/vendor/faiss/faiss/IndexIVFSpectralHash.h +2 -2
  64. data/vendor/faiss/faiss/IndexLSH.cpp +2 -3
  65. data/vendor/faiss/faiss/IndexLSH.h +2 -2
  66. data/vendor/faiss/faiss/IndexLattice.cpp +2 -2
  67. data/vendor/faiss/faiss/IndexLattice.h +2 -2
  68. data/vendor/faiss/faiss/IndexNNDescent.cpp +2 -2
  69. data/vendor/faiss/faiss/IndexNNDescent.h +2 -2
  70. data/vendor/faiss/faiss/IndexNSG.cpp +2 -5
  71. data/vendor/faiss/faiss/IndexNSG.h +2 -2
  72. data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +2 -2
  73. data/vendor/faiss/faiss/IndexNeuralNetCodec.h +2 -2
  74. data/vendor/faiss/faiss/IndexPQ.cpp +26 -26
  75. data/vendor/faiss/faiss/IndexPQ.h +2 -2
  76. data/vendor/faiss/faiss/IndexPQFastScan.cpp +2 -5
  77. data/vendor/faiss/faiss/IndexPQFastScan.h +2 -11
  78. data/vendor/faiss/faiss/IndexPreTransform.cpp +2 -2
  79. data/vendor/faiss/faiss/IndexPreTransform.h +2 -2
  80. data/vendor/faiss/faiss/IndexRefine.cpp +41 -4
  81. data/vendor/faiss/faiss/IndexRefine.h +9 -2
  82. data/vendor/faiss/faiss/IndexReplicas.cpp +2 -2
  83. data/vendor/faiss/faiss/IndexReplicas.h +2 -2
  84. data/vendor/faiss/faiss/IndexRowwiseMinMax.cpp +2 -2
  85. data/vendor/faiss/faiss/IndexRowwiseMinMax.h +2 -2
  86. data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +2 -3
  87. data/vendor/faiss/faiss/IndexScalarQuantizer.h +2 -2
  88. data/vendor/faiss/faiss/IndexShards.cpp +2 -2
  89. data/vendor/faiss/faiss/IndexShards.h +2 -2
  90. data/vendor/faiss/faiss/IndexShardsIVF.cpp +2 -2
  91. data/vendor/faiss/faiss/IndexShardsIVF.h +2 -2
  92. data/vendor/faiss/faiss/MatrixStats.cpp +2 -2
  93. data/vendor/faiss/faiss/MatrixStats.h +2 -2
  94. data/vendor/faiss/faiss/MetaIndexes.cpp +2 -3
  95. data/vendor/faiss/faiss/MetaIndexes.h +2 -2
  96. data/vendor/faiss/faiss/MetricType.h +2 -2
  97. data/vendor/faiss/faiss/VectorTransform.cpp +2 -2
  98. data/vendor/faiss/faiss/VectorTransform.h +2 -2
  99. data/vendor/faiss/faiss/clone_index.cpp +2 -2
  100. data/vendor/faiss/faiss/clone_index.h +2 -2
  101. data/vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h +2 -2
  102. data/vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h +2 -2
  103. data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +2 -2
  104. data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +44 -4
  105. data/vendor/faiss/faiss/cppcontrib/factory_tools.h +7 -2
  106. data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +2 -2
  107. data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +2 -2
  108. data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h +2 -2
  109. data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMax-inl.h +2 -2
  110. data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMaxFP16-inl.h +2 -2
  111. data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h +2 -2
  112. data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h +2 -2
  113. data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-neon-inl.h +2 -2
  114. data/vendor/faiss/faiss/gpu/GpuAutoTune.cpp +2 -5
  115. data/vendor/faiss/faiss/gpu/GpuAutoTune.h +2 -2
  116. data/vendor/faiss/faiss/gpu/GpuCloner.cpp +13 -13
  117. data/vendor/faiss/faiss/gpu/GpuCloner.h +2 -2
  118. data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +6 -6
  119. data/vendor/faiss/faiss/gpu/GpuDistance.h +11 -7
  120. data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +2 -2
  121. data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +2 -2
  122. data/vendor/faiss/faiss/gpu/GpuIndex.h +8 -7
  123. data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -2
  124. data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +6 -3
  125. data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +2 -2
  126. data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +2 -2
  127. data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +2 -2
  128. data/vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h +3 -3
  129. data/vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h +2 -2
  130. data/vendor/faiss/faiss/gpu/GpuIndicesOptions.h +2 -2
  131. data/vendor/faiss/faiss/gpu/GpuResources.cpp +7 -2
  132. data/vendor/faiss/faiss/gpu/GpuResources.h +11 -4
  133. data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +51 -21
  134. data/vendor/faiss/faiss/gpu/StandardGpuResources.h +15 -5
  135. data/vendor/faiss/faiss/gpu/impl/IndexUtils.h +2 -2
  136. data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp +2 -2
  137. data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.h +2 -2
  138. data/vendor/faiss/faiss/gpu/impl/RemapIndices.cpp +2 -2
  139. data/vendor/faiss/faiss/gpu/impl/RemapIndices.h +2 -2
  140. data/vendor/faiss/faiss/gpu/perf/IndexWrapper-inl.h +2 -2
  141. data/vendor/faiss/faiss/gpu/perf/IndexWrapper.h +2 -2
  142. data/vendor/faiss/faiss/gpu/perf/PerfClustering.cpp +2 -2
  143. data/vendor/faiss/faiss/gpu/perf/PerfIVFPQAdd.cpp +2 -3
  144. data/vendor/faiss/faiss/gpu/perf/WriteIndex.cpp +2 -2
  145. data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +2 -2
  146. data/vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp +2 -2
  147. data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +54 -54
  148. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +80 -78
  149. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +51 -51
  150. data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFScalarQuantizer.cpp +2 -2
  151. data/vendor/faiss/faiss/gpu/test/TestGpuMemoryException.cpp +3 -3
  152. data/vendor/faiss/faiss/gpu/test/TestGpuResidualQuantizer.cpp +70 -0
  153. data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +74 -4
  154. data/vendor/faiss/faiss/gpu/test/TestUtils.h +2 -2
  155. data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +2 -2
  156. data/vendor/faiss/faiss/gpu/utils/{RaftUtils.h → CuvsUtils.h} +12 -11
  157. data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +2 -2
  158. data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +2 -2
  159. data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.h +2 -2
  160. data/vendor/faiss/faiss/gpu/utils/StaticUtils.h +2 -2
  161. data/vendor/faiss/faiss/gpu/utils/Timer.cpp +2 -2
  162. data/vendor/faiss/faiss/gpu/utils/Timer.h +2 -2
  163. data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +79 -11
  164. data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +17 -5
  165. data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +2 -2
  166. data/vendor/faiss/faiss/impl/AuxIndexStructures.h +2 -2
  167. data/vendor/faiss/faiss/impl/CodePacker.cpp +2 -2
  168. data/vendor/faiss/faiss/impl/CodePacker.h +2 -2
  169. data/vendor/faiss/faiss/impl/DistanceComputer.h +2 -2
  170. data/vendor/faiss/faiss/impl/FaissAssert.h +2 -2
  171. data/vendor/faiss/faiss/impl/FaissException.cpp +2 -2
  172. data/vendor/faiss/faiss/impl/FaissException.h +2 -3
  173. data/vendor/faiss/faiss/impl/HNSW.cpp +24 -19
  174. data/vendor/faiss/faiss/impl/HNSW.h +12 -2
  175. data/vendor/faiss/faiss/impl/IDSelector.cpp +2 -2
  176. data/vendor/faiss/faiss/impl/IDSelector.h +2 -2
  177. data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +2 -2
  178. data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +2 -2
  179. data/vendor/faiss/faiss/impl/LookupTableScaler.h +2 -2
  180. data/vendor/faiss/faiss/impl/NNDescent.cpp +2 -2
  181. data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
  182. data/vendor/faiss/faiss/impl/NSG.cpp +27 -21
  183. data/vendor/faiss/faiss/impl/NSG.h +20 -8
  184. data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +2 -2
  185. data/vendor/faiss/faiss/impl/PolysemousTraining.h +2 -2
  186. data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +2 -4
  187. data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +2 -2
  188. data/vendor/faiss/faiss/impl/ProductQuantizer-inl.h +2 -2
  189. data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +2 -2
  190. data/vendor/faiss/faiss/impl/ProductQuantizer.h +2 -2
  191. data/vendor/faiss/faiss/impl/Quantizer.h +2 -2
  192. data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +2 -36
  193. data/vendor/faiss/faiss/impl/ResidualQuantizer.h +3 -13
  194. data/vendor/faiss/faiss/impl/ResultHandler.h +2 -2
  195. data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +2 -2
  196. data/vendor/faiss/faiss/impl/ScalarQuantizer.h +2 -2
  197. data/vendor/faiss/faiss/impl/ThreadedIndex-inl.h +2 -2
  198. data/vendor/faiss/faiss/impl/ThreadedIndex.h +2 -2
  199. data/vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h +2 -2
  200. data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +2 -2
  201. data/vendor/faiss/faiss/impl/code_distance/code_distance-generic.h +2 -2
  202. data/vendor/faiss/faiss/impl/code_distance/code_distance-sve.h +440 -0
  203. data/vendor/faiss/faiss/impl/code_distance/code_distance.h +55 -2
  204. data/vendor/faiss/faiss/impl/index_read.cpp +2 -5
  205. data/vendor/faiss/faiss/impl/index_read_utils.h +2 -2
  206. data/vendor/faiss/faiss/impl/index_write.cpp +2 -6
  207. data/vendor/faiss/faiss/impl/io.cpp +2 -2
  208. data/vendor/faiss/faiss/impl/io.h +2 -2
  209. data/vendor/faiss/faiss/impl/io_macros.h +2 -9
  210. data/vendor/faiss/faiss/impl/kmeans1d.cpp +2 -3
  211. data/vendor/faiss/faiss/impl/kmeans1d.h +2 -2
  212. data/vendor/faiss/faiss/impl/lattice_Zn.cpp +2 -3
  213. data/vendor/faiss/faiss/impl/lattice_Zn.h +2 -2
  214. data/vendor/faiss/faiss/impl/platform_macros.h +12 -2
  215. data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +2 -2
  216. data/vendor/faiss/faiss/impl/pq4_fast_scan.h +20 -2
  217. data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +2 -2
  218. data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +2 -2
  219. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +3 -3
  220. data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +2 -2
  221. data/vendor/faiss/faiss/impl/simd_result_handlers.h +18 -18
  222. data/vendor/faiss/faiss/index_factory.cpp +20 -21
  223. data/vendor/faiss/faiss/index_factory.h +2 -2
  224. data/vendor/faiss/faiss/index_io.h +2 -2
  225. data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +2 -2
  226. data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +2 -2
  227. data/vendor/faiss/faiss/invlists/DirectMap.cpp +2 -2
  228. data/vendor/faiss/faiss/invlists/DirectMap.h +2 -2
  229. data/vendor/faiss/faiss/invlists/InvertedLists.cpp +2 -2
  230. data/vendor/faiss/faiss/invlists/InvertedLists.h +2 -2
  231. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +2 -2
  232. data/vendor/faiss/faiss/invlists/InvertedListsIOHook.h +2 -2
  233. data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +2 -3
  234. data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +2 -2
  235. data/vendor/faiss/faiss/python/python_callbacks.cpp +2 -2
  236. data/vendor/faiss/faiss/python/python_callbacks.h +2 -2
  237. data/vendor/faiss/faiss/utils/AlignedTable.h +5 -3
  238. data/vendor/faiss/faiss/utils/Heap.cpp +2 -2
  239. data/vendor/faiss/faiss/utils/Heap.h +2 -2
  240. data/vendor/faiss/faiss/utils/NeuralNet.cpp +11 -7
  241. data/vendor/faiss/faiss/utils/NeuralNet.h +2 -2
  242. data/vendor/faiss/faiss/utils/WorkerThread.cpp +2 -2
  243. data/vendor/faiss/faiss/utils/WorkerThread.h +2 -2
  244. data/vendor/faiss/faiss/utils/approx_topk/approx_topk.h +2 -2
  245. data/vendor/faiss/faiss/utils/approx_topk/avx2-inl.h +2 -2
  246. data/vendor/faiss/faiss/utils/approx_topk/generic.h +2 -2
  247. data/vendor/faiss/faiss/utils/approx_topk/mode.h +2 -2
  248. data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +2 -2
  249. data/vendor/faiss/faiss/utils/bf16.h +2 -2
  250. data/vendor/faiss/faiss/utils/distances.cpp +191 -2
  251. data/vendor/faiss/faiss/utils/distances.h +3 -3
  252. data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +2 -2
  253. data/vendor/faiss/faiss/utils/distances_fused/avx512.h +2 -2
  254. data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +2 -2
  255. data/vendor/faiss/faiss/utils/distances_fused/distances_fused.h +2 -2
  256. data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +2 -2
  257. data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.h +2 -2
  258. data/vendor/faiss/faiss/utils/distances_simd.cpp +502 -3
  259. data/vendor/faiss/faiss/utils/extra_distances-inl.h +2 -2
  260. data/vendor/faiss/faiss/utils/extra_distances.cpp +2 -3
  261. data/vendor/faiss/faiss/utils/extra_distances.h +2 -2
  262. data/vendor/faiss/faiss/utils/fp16-arm.h +2 -2
  263. data/vendor/faiss/faiss/utils/fp16-fp16c.h +2 -2
  264. data/vendor/faiss/faiss/utils/fp16-inl.h +2 -2
  265. data/vendor/faiss/faiss/utils/fp16.h +2 -2
  266. data/vendor/faiss/faiss/utils/hamming-inl.h +2 -2
  267. data/vendor/faiss/faiss/utils/hamming.cpp +2 -3
  268. data/vendor/faiss/faiss/utils/hamming.h +2 -2
  269. data/vendor/faiss/faiss/utils/hamming_distance/avx2-inl.h +2 -2
  270. data/vendor/faiss/faiss/utils/hamming_distance/avx512-inl.h +490 -0
  271. data/vendor/faiss/faiss/utils/hamming_distance/common.h +2 -2
  272. data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +2 -2
  273. data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +5 -2
  274. data/vendor/faiss/faiss/utils/hamming_distance/neon-inl.h +5 -5
  275. data/vendor/faiss/faiss/utils/ordered_key_value.h +2 -2
  276. data/vendor/faiss/faiss/utils/partitioning.cpp +2 -2
  277. data/vendor/faiss/faiss/utils/partitioning.h +2 -2
  278. data/vendor/faiss/faiss/utils/prefetch.h +2 -2
  279. data/vendor/faiss/faiss/utils/quantize_lut.cpp +2 -2
  280. data/vendor/faiss/faiss/utils/quantize_lut.h +2 -2
  281. data/vendor/faiss/faiss/utils/random.cpp +2 -2
  282. data/vendor/faiss/faiss/utils/random.h +2 -2
  283. data/vendor/faiss/faiss/utils/simdlib.h +2 -2
  284. data/vendor/faiss/faiss/utils/simdlib_avx2.h +2 -2
  285. data/vendor/faiss/faiss/utils/simdlib_avx512.h +2 -2
  286. data/vendor/faiss/faiss/utils/simdlib_emulated.h +2 -2
  287. data/vendor/faiss/faiss/utils/simdlib_neon.h +2 -2
  288. data/vendor/faiss/faiss/utils/simdlib_ppc64.h +2 -2
  289. data/vendor/faiss/faiss/utils/sorting.cpp +2 -2
  290. data/vendor/faiss/faiss/utils/sorting.h +2 -2
  291. data/vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h +2 -2
  292. data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +2 -2
  293. data/vendor/faiss/faiss/utils/utils.cpp +7 -7
  294. data/vendor/faiss/faiss/utils/utils.h +4 -3
  295. metadata +9 -10
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -77,6 +77,59 @@ inline void distance_four_codes(
77
77
 
78
78
  } // namespace faiss
79
79
 
80
+ #elif defined(__ARM_FEATURE_SVE)
81
+
82
+ #include <faiss/impl/code_distance/code_distance-sve.h>
83
+
84
+ namespace faiss {
85
+
86
+ template <typename PQDecoderT>
87
+ inline float distance_single_code(
88
+ // the product quantizer
89
+ const size_t M,
90
+ // number of bits per quantization index
91
+ const size_t nbits,
92
+ // precomputed distances, layout (M, ksub)
93
+ const float* sim_table,
94
+ // the code
95
+ const uint8_t* code) {
96
+ return distance_single_code_sve<PQDecoderT>(M, nbits, sim_table, code);
97
+ }
98
+
99
+ template <typename PQDecoderT>
100
+ inline void distance_four_codes(
101
+ // the product quantizer
102
+ const size_t M,
103
+ // number of bits per quantization index
104
+ const size_t nbits,
105
+ // precomputed distances, layout (M, ksub)
106
+ const float* sim_table,
107
+ // codes
108
+ const uint8_t* __restrict code0,
109
+ const uint8_t* __restrict code1,
110
+ const uint8_t* __restrict code2,
111
+ const uint8_t* __restrict code3,
112
+ // computed distances
113
+ float& result0,
114
+ float& result1,
115
+ float& result2,
116
+ float& result3) {
117
+ distance_four_codes_sve<PQDecoderT>(
118
+ M,
119
+ nbits,
120
+ sim_table,
121
+ code0,
122
+ code1,
123
+ code2,
124
+ code3,
125
+ result0,
126
+ result1,
127
+ result2,
128
+ result3);
129
+ }
130
+
131
+ } // namespace faiss
132
+
80
133
  #else
81
134
 
82
135
  #include <faiss/impl/code_distance/code_distance-generic.h>
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -13,9 +13,6 @@
13
13
  #include <cstdio>
14
14
  #include <cstdlib>
15
15
 
16
- #include <sys/stat.h>
17
- #include <sys/types.h>
18
-
19
16
  #include <faiss/impl/FaissAssert.h>
20
17
  #include <faiss/impl/io.h>
21
18
  #include <faiss/impl/io_macros.h>
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -13,13 +13,9 @@
13
13
  #include <cstdio>
14
14
  #include <cstdlib>
15
15
 
16
- #include <sys/stat.h>
17
- #include <sys/types.h>
18
-
19
16
  #include <faiss/invlists/InvertedListsIOHook.h>
20
17
 
21
18
  #include <faiss/impl/FaissAssert.h>
22
- #include <faiss/impl/io.h>
23
19
  #include <faiss/impl/io_macros.h>
24
20
  #include <faiss/utils/hamming.h>
25
21
 
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -45,13 +45,6 @@
45
45
  READANDCHECK((vec).data(), size); \
46
46
  }
47
47
 
48
- #define READSTRING(s) \
49
- { \
50
- size_t size = (s).size(); \
51
- WRITEANDCHECK(&size, 1); \
52
- WRITEANDCHECK((s).c_str(), size); \
53
- }
54
-
55
48
  #define WRITEANDCHECK(ptr, n) \
56
49
  { \
57
50
  size_t ret = (*f)(ptr, sizeof(*(ptr)), n); \
@@ -1,12 +1,11 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
8
  #include <algorithm>
9
- #include <cstdint>
10
9
  #include <cstring>
11
10
  #include <functional>
12
11
  #include <numeric>
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -16,7 +16,6 @@
16
16
 
17
17
  #include <algorithm>
18
18
  #include <queue>
19
- #include <unordered_map>
20
19
  #include <unordered_set>
21
20
 
22
21
  #include <faiss/impl/platform_macros.h>
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -39,6 +39,7 @@
39
39
  // redefine the GCC intrinsics with Windows equivalents
40
40
 
41
41
  #include <intrin.h>
42
+ #include <limits.h>
42
43
 
43
44
  #ifndef __clang__
44
45
  inline int __builtin_ctzll(uint64_t x) {
@@ -59,7 +60,16 @@ inline int __builtin_ctz(unsigned long x) {
59
60
 
60
61
  #ifndef __clang__
61
62
  inline int __builtin_clzll(uint64_t x) {
63
+ #if defined(_M_X64) || defined(__x86_64__)
62
64
  return (int)__lzcnt64(x);
65
+ #elif defined(_M_ARM64)
66
+ unsigned long index;
67
+ int count = sizeof(uint64_t) * CHAR_BIT;
68
+ if (_BitScanReverse64(&index, x)) {
69
+ count = count - 1 - index;
70
+ }
71
+ return count;
72
+ #endif
63
73
  }
64
74
  #endif
65
75
 
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -189,4 +189,22 @@ void pq4_accumulate_loop_qbs(
189
189
  SIMDResultHandler& res,
190
190
  const NormTableScaler* scaler = nullptr);
191
191
 
192
+ /** Wrapper of pq4_accumulate_loop_qbs using simple StoreResultHandler
193
+ * and DummyScaler
194
+ *
195
+ * @param nq number of queries
196
+ * @param ntotal2 number of database elements (multiple of 32)
197
+ * @param nsq number of sub-quantizers (muliple of 2)
198
+ * @param codes packed codes array
199
+ * @param LUT packed look-up table
200
+ * @param accu array to store the results
201
+ */
202
+ void accumulate_to_mem(
203
+ int nq,
204
+ size_t ntotal2,
205
+ int nsq,
206
+ const uint8_t* codes,
207
+ const uint8_t* LUT,
208
+ uint16_t* accu);
209
+
192
210
  } // namespace faiss
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -809,7 +809,7 @@ void refine_beam_LUT_mp(
809
809
  rq.codebook_offsets.data(),
810
810
  query_cp + rq.codebook_offsets[m],
811
811
  rq.total_codebook_size,
812
- rq.cent_norms.data() + rq.codebook_offsets[m],
812
+ rq.centroid_norms.data() + rq.codebook_offsets[m],
813
813
  m,
814
814
  codes_ptr,
815
815
  distances_ptr,
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -368,10 +368,10 @@ struct HeapHandler : ResultHandlerCompare<C, with_id_map> {
368
368
  auto real_idx = this->adjust_id(b, j);
369
369
  lt_mask -= 1 << j;
370
370
  if (this->sel->is_member(real_idx)) {
371
- T dis = d32tab[j];
372
- if (C::cmp(heap_dis[0], dis)) {
371
+ T dis_2 = d32tab[j];
372
+ if (C::cmp(heap_dis[0], dis_2)) {
373
373
  heap_replace_top<C>(
374
- k, heap_dis, heap_ids, dis, real_idx);
374
+ k, heap_dis, heap_ids, dis_2, real_idx);
375
375
  }
376
376
  }
377
377
  }
@@ -380,10 +380,10 @@ struct HeapHandler : ResultHandlerCompare<C, with_id_map> {
380
380
  // find first non-zero
381
381
  int j = __builtin_ctz(lt_mask);
382
382
  lt_mask -= 1 << j;
383
- T dis = d32tab[j];
384
- if (C::cmp(heap_dis[0], dis)) {
383
+ T dis_2 = d32tab[j];
384
+ if (C::cmp(heap_dis[0], dis_2)) {
385
385
  int64_t idx = this->adjust_id(b, j);
386
- heap_replace_top<C>(k, heap_dis, heap_ids, dis, idx);
386
+ heap_replace_top<C>(k, heap_dis, heap_ids, dis_2, idx);
387
387
  }
388
388
  }
389
389
  }
@@ -480,8 +480,8 @@ struct ReservoirHandler : ResultHandlerCompare<C, with_id_map> {
480
480
  auto real_idx = this->adjust_id(b, j);
481
481
  lt_mask -= 1 << j;
482
482
  if (this->sel->is_member(real_idx)) {
483
- T dis = d32tab[j];
484
- res.add(dis, real_idx);
483
+ T dis_2 = d32tab[j];
484
+ res.add(dis_2, real_idx);
485
485
  }
486
486
  }
487
487
  } else {
@@ -489,8 +489,8 @@ struct ReservoirHandler : ResultHandlerCompare<C, with_id_map> {
489
489
  // find first non-zero
490
490
  int j = __builtin_ctz(lt_mask);
491
491
  lt_mask -= 1 << j;
492
- T dis = d32tab[j];
493
- res.add(dis, this->adjust_id(b, j));
492
+ T dis_2 = d32tab[j];
493
+ res.add(dis_2, this->adjust_id(b, j));
494
494
  }
495
495
  }
496
496
  }
@@ -719,10 +719,10 @@ void dispatch_SIMDResultHandler_fixedCW(
719
719
  Types... args) {
720
720
  if (auto resh = dynamic_cast<SingleResultHandler<C, W>*>(&res)) {
721
721
  consumer.template f<SingleResultHandler<C, W>>(*resh, args...);
722
- } else if (auto resh = dynamic_cast<HeapHandler<C, W>*>(&res)) {
723
- consumer.template f<HeapHandler<C, W>>(*resh, args...);
724
- } else if (auto resh = dynamic_cast<ReservoirHandler<C, W>*>(&res)) {
725
- consumer.template f<ReservoirHandler<C, W>>(*resh, args...);
722
+ } else if (auto resh_2 = dynamic_cast<HeapHandler<C, W>*>(&res)) {
723
+ consumer.template f<HeapHandler<C, W>>(*resh_2, args...);
724
+ } else if (auto resh_2 = dynamic_cast<ReservoirHandler<C, W>*>(&res)) {
725
+ consumer.template f<ReservoirHandler<C, W>>(*resh_2, args...);
726
726
  } else { // generic handler -- will not be inlined
727
727
  FAISS_THROW_IF_NOT_FMT(
728
728
  simd_result_handlers_accept_virtual,
@@ -752,8 +752,8 @@ void dispatch_SIMDResultHandler(
752
752
  if (res.sizeof_ids == 0) {
753
753
  if (auto resh = dynamic_cast<StoreResultHandler*>(&res)) {
754
754
  consumer.template f<StoreResultHandler>(*resh, args...);
755
- } else if (auto resh = dynamic_cast<DummyResultHandler*>(&res)) {
756
- consumer.template f<DummyResultHandler>(*resh, args...);
755
+ } else if (auto resh_2 = dynamic_cast<DummyResultHandler*>(&res)) {
756
+ consumer.template f<DummyResultHandler>(*resh_2, args...);
757
757
  } else { // generic path
758
758
  FAISS_THROW_IF_NOT_FMT(
759
759
  simd_result_handlers_accept_virtual,
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -20,7 +20,6 @@
20
20
 
21
21
  #include <faiss/impl/FaissAssert.h>
22
22
  #include <faiss/utils/random.h>
23
- #include <faiss/utils/utils.h>
24
23
 
25
24
  #include <faiss/Index2Layer.h>
26
25
  #include <faiss/IndexAdditiveQuantizer.h>
@@ -679,6 +678,24 @@ std::unique_ptr<Index> index_factory_sub(
679
678
  // for the current match
680
679
  std::smatch sm;
681
680
 
681
+ // IndexIDMap -- it turns out is was used both as a prefix and a suffix, so
682
+ // support both
683
+ if (re_match(description, "(.+),IDMap2", sm) ||
684
+ re_match(description, "IDMap2,(.+)", sm)) {
685
+ IndexIDMap2* idmap2 = new IndexIDMap2(
686
+ index_factory_sub(d, sm[1].str(), metric).release());
687
+ idmap2->own_fields = true;
688
+ return std::unique_ptr<Index>(idmap2);
689
+ }
690
+
691
+ if (re_match(description, "(.+),IDMap", sm) ||
692
+ re_match(description, "IDMap,(.+)", sm)) {
693
+ IndexIDMap* idmap = new IndexIDMap(
694
+ index_factory_sub(d, sm[1].str(), metric).release());
695
+ idmap->own_fields = true;
696
+ return std::unique_ptr<Index>(idmap);
697
+ }
698
+
682
699
  // handle refines
683
700
  if (re_match(description, "(.+),RFlat", sm) ||
684
701
  re_match(description, "(.+),Refine\\((.+)\\)", sm)) {
@@ -755,24 +772,6 @@ std::unique_ptr<Index> index_factory_sub(
755
772
  d);
756
773
  }
757
774
 
758
- // IndexIDMap -- it turns out is was used both as a prefix and a suffix, so
759
- // support both
760
- if (re_match(description, "(.+),IDMap2", sm) ||
761
- re_match(description, "IDMap2,(.+)", sm)) {
762
- IndexIDMap2* idmap2 = new IndexIDMap2(
763
- index_factory_sub(d, sm[1].str(), metric).release());
764
- idmap2->own_fields = true;
765
- return std::unique_ptr<Index>(idmap2);
766
- }
767
-
768
- if (re_match(description, "(.+),IDMap", sm) ||
769
- re_match(description, "IDMap,(.+)", sm)) {
770
- IndexIDMap* idmap = new IndexIDMap(
771
- index_factory_sub(d, sm[1].str(), metric).release());
772
- idmap->own_fields = true;
773
- return std::unique_ptr<Index>(idmap);
774
- }
775
-
776
775
  { // handle basic index types
777
776
  Index* index = parse_other_indexes(description, d, metric);
778
777
  if (index) {
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -15,7 +15,6 @@
15
15
 
16
16
  #include <sys/mman.h>
17
17
  #include <sys/stat.h>
18
- #include <sys/types.h>
19
18
  #include <unistd.h>
20
19
 
21
20
  #include <faiss/impl/FaissAssert.h>
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -63,7 +63,9 @@ struct AlignedTableTightAlloc {
63
63
  }
64
64
 
65
65
  void clear() {
66
- memset(ptr, 0, nbytes());
66
+ if (numel > 0) {
67
+ memset(ptr, 0, nbytes());
68
+ }
67
69
  }
68
70
  size_t size() const {
69
71
  return numel;
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -1,5 +1,5 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
3
  *
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.