faiss 0.6.0 → 0.6.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/faiss/extconf.rb +2 -1
- data/ext/faiss/{index_rb.cpp → index.cpp} +1 -1
- data/ext/faiss/index_binary.cpp +1 -1
- data/ext/faiss/kmeans.cpp +1 -1
- data/ext/faiss/pca_matrix.cpp +1 -1
- data/ext/faiss/product_quantizer.cpp +1 -1
- data/ext/faiss/{utils_rb.cpp → utils.cpp} +1 -1
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +93 -80
- data/vendor/faiss/faiss/Clustering.cpp +39 -240
- data/vendor/faiss/faiss/Clustering.h +6 -0
- data/vendor/faiss/faiss/IVFlib.cpp +41 -21
- data/vendor/faiss/faiss/Index.cpp +6 -5
- data/vendor/faiss/faiss/Index.h +5 -5
- data/vendor/faiss/faiss/Index2Layer.cpp +37 -53
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +49 -37
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +36 -34
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +4 -1
- data/vendor/faiss/faiss/IndexBinary.cpp +5 -3
- data/vendor/faiss/faiss/IndexBinary.h +4 -4
- data/vendor/faiss/faiss/IndexBinaryFlat.cpp +1 -1
- data/vendor/faiss/faiss/IndexBinaryFlat.h +1 -1
- data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +4 -4
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +84 -92
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +9 -3
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +45 -236
- data/vendor/faiss/faiss/IndexBinaryHash.h +6 -6
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +87 -415
- data/vendor/faiss/faiss/IndexFastScan.cpp +72 -109
- data/vendor/faiss/faiss/IndexFastScan.h +25 -23
- data/vendor/faiss/faiss/IndexFlat.cpp +27 -20
- data/vendor/faiss/faiss/IndexFlat.h +21 -18
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +42 -19
- data/vendor/faiss/faiss/IndexHNSW.cpp +283 -145
- data/vendor/faiss/faiss/IndexHNSW.h +16 -2
- data/vendor/faiss/faiss/IndexIDMap.cpp +25 -21
- data/vendor/faiss/faiss/IndexIDMap.h +9 -7
- data/vendor/faiss/faiss/IndexIVF.cpp +465 -362
- data/vendor/faiss/faiss/IndexIVF.h +33 -12
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +77 -74
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +96 -93
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +4 -1
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +357 -238
- data/vendor/faiss/faiss/IndexIVFFastScan.h +42 -41
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +36 -68
- data/vendor/faiss/faiss/IndexIVFFlat.h +32 -0
- data/vendor/faiss/faiss/IndexIVFFlatPanorama.cpp +53 -30
- data/vendor/faiss/faiss/IndexIVFFlatPanorama.h +3 -1
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.cpp +18 -15
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +71 -843
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +151 -121
- data/vendor/faiss/faiss/IndexIVFPQFastScan.h +3 -0
- data/vendor/faiss/faiss/IndexIVFPQR.cpp +21 -17
- data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +26 -39
- data/vendor/faiss/faiss/IndexIVFRaBitQ.h +2 -1
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +475 -476
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +248 -93
- data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +41 -127
- data/vendor/faiss/faiss/IndexIVFSpectralHash.h +1 -1
- data/vendor/faiss/faiss/IndexLSH.cpp +36 -19
- data/vendor/faiss/faiss/IndexLattice.cpp +13 -13
- data/vendor/faiss/faiss/IndexNNDescent.cpp +36 -21
- data/vendor/faiss/faiss/IndexNNDescent.h +2 -2
- data/vendor/faiss/faiss/IndexNSG.cpp +39 -23
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +31 -11
- data/vendor/faiss/faiss/IndexPQ.cpp +128 -221
- data/vendor/faiss/faiss/IndexPQ.h +3 -2
- data/vendor/faiss/faiss/IndexPQFastScan.cpp +20 -14
- data/vendor/faiss/faiss/IndexPQFastScan.h +3 -0
- data/vendor/faiss/faiss/IndexPreTransform.cpp +25 -18
- data/vendor/faiss/faiss/IndexPreTransform.h +1 -1
- data/vendor/faiss/faiss/IndexRaBitQ.cpp +11 -36
- data/vendor/faiss/faiss/IndexRaBitQ.h +2 -1
- data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +41 -277
- data/vendor/faiss/faiss/IndexRaBitQFastScan.h +183 -27
- data/vendor/faiss/faiss/IndexRefine.cpp +30 -25
- data/vendor/faiss/faiss/IndexRefine.h +4 -4
- data/vendor/faiss/faiss/IndexReplicas.cpp +6 -6
- data/vendor/faiss/faiss/IndexRowwiseMinMax.cpp +15 -14
- data/vendor/faiss/faiss/IndexRowwiseMinMax.h +1 -1
- data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +82 -14
- data/vendor/faiss/faiss/IndexShards.cpp +10 -9
- data/vendor/faiss/faiss/IndexShardsIVF.cpp +21 -15
- data/vendor/faiss/faiss/MatrixStats.cpp +5 -4
- data/vendor/faiss/faiss/MetaIndexes.cpp +19 -17
- data/vendor/faiss/faiss/MetaIndexes.h +1 -1
- data/vendor/faiss/faiss/MetricType.h +14 -7
- data/vendor/faiss/faiss/SuperKMeans.cpp +656 -0
- data/vendor/faiss/faiss/SuperKMeans.h +97 -0
- data/vendor/faiss/faiss/VectorTransform.cpp +237 -149
- data/vendor/faiss/faiss/VectorTransform.h +16 -16
- data/vendor/faiss/faiss/build.cpp +23 -0
- data/vendor/faiss/faiss/build.h +15 -0
- data/vendor/faiss/faiss/clone_index.cpp +48 -47
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +47 -47
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +11 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h +38 -38
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h +11 -0
- data/vendor/faiss/faiss/factory_tools.cpp +5 -0
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +6 -5
- data/vendor/faiss/faiss/gpu/GpuResources.h +1 -1
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +9 -9
- data/vendor/faiss/faiss/gpu/StandardGpuResources.h +4 -3
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +46 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +56 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +78 -1
- data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +72 -0
- data/vendor/faiss/faiss/gpu/test/TestUtils.h +23 -0
- data/vendor/faiss/faiss/gpu/utils/CuvsFilterConvert.h +1 -1
- data/vendor/faiss/faiss/gpu/utils/CuvsUtils.h +21 -10
- data/vendor/faiss/faiss/gpu_metal/GpuIndexFlat.h +22 -0
- data/vendor/faiss/faiss/gpu_metal/MetalCloner.h +35 -0
- data/vendor/faiss/faiss/gpu_metal/MetalFlatKernels.h +40 -0
- data/vendor/faiss/faiss/gpu_metal/MetalIndex.h +51 -0
- data/vendor/faiss/faiss/gpu_metal/MetalIndexFlat.h +65 -0
- data/vendor/faiss/faiss/gpu_metal/MetalKernels.h +66 -0
- data/vendor/faiss/faiss/gpu_metal/MetalResources.h +79 -0
- data/vendor/faiss/faiss/gpu_metal/StandardMetalResources.h +35 -0
- data/vendor/faiss/faiss/impl/AdSampling.cpp +103 -0
- data/vendor/faiss/faiss/impl/AdSampling.h +35 -0
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +29 -25
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +1 -0
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +10 -9
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +3 -0
- data/vendor/faiss/faiss/impl/ClusteringHelpers.cpp +244 -0
- data/vendor/faiss/faiss/impl/ClusteringHelpers.h +94 -0
- data/vendor/faiss/faiss/impl/ClusteringInitialization.cpp +16 -16
- data/vendor/faiss/faiss/impl/CodePacker.cpp +3 -3
- data/vendor/faiss/faiss/impl/CodePackerRaBitQ.cpp +1 -1
- data/vendor/faiss/faiss/impl/DistanceComputer.h +8 -8
- data/vendor/faiss/faiss/impl/FaissAssert.h +6 -3
- data/vendor/faiss/faiss/impl/FaissException.h +50 -3
- data/vendor/faiss/faiss/impl/HNSW.cpp +92 -317
- data/vendor/faiss/faiss/impl/HNSW.h +13 -34
- data/vendor/faiss/faiss/impl/IDSelector.cpp +15 -11
- data/vendor/faiss/faiss/impl/IDSelector.h +8 -8
- data/vendor/faiss/faiss/impl/InvertedListScannerStats.h +26 -0
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +82 -77
- data/vendor/faiss/faiss/impl/NNDescent.cpp +62 -25
- data/vendor/faiss/faiss/impl/NNDescent.h +6 -2
- data/vendor/faiss/faiss/impl/NSG.cpp +38 -21
- data/vendor/faiss/faiss/impl/NSG.h +4 -4
- data/vendor/faiss/faiss/impl/Panorama.cpp +23 -6
- data/vendor/faiss/faiss/impl/Panorama.h +258 -87
- data/vendor/faiss/faiss/impl/PdxLayout.cpp +93 -0
- data/vendor/faiss/faiss/impl/PdxLayout.h +41 -0
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +46 -32
- data/vendor/faiss/faiss/impl/PolysemousTraining.h +3 -3
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +35 -35
- data/vendor/faiss/faiss/impl/ProductQuantizer-inl.h +21 -16
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +30 -23
- data/vendor/faiss/faiss/impl/Quantizer.h +2 -2
- data/vendor/faiss/faiss/impl/RaBitQUtils.cpp +55 -49
- data/vendor/faiss/faiss/impl/RaBitQUtils.h +65 -0
- data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +296 -283
- data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +26 -23
- data/vendor/faiss/faiss/impl/ResidualQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/ResultHandler.h +99 -75
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +52 -4
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +27 -1
- data/vendor/faiss/faiss/impl/ThreadedIndex-inl.h +14 -11
- data/vendor/faiss/faiss/impl/VisitedTable.h +7 -0
- data/vendor/faiss/faiss/impl/approx_topk/approx_topk.h +276 -0
- data/vendor/faiss/faiss/impl/approx_topk/avx2.cpp +68 -0
- data/vendor/faiss/faiss/{utils → impl}/approx_topk/generic.h +15 -8
- data/vendor/faiss/faiss/impl/approx_topk/neon.cpp +68 -0
- data/vendor/faiss/faiss/impl/approx_topk/rq_beam_search_tab-inl.h +169 -0
- data/vendor/faiss/faiss/impl/approx_topk/rq_beam_search_tab.h +117 -0
- data/vendor/faiss/faiss/impl/approx_topk/simdlib256-inl.h +146 -0
- data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryHNSW_impl.h +73 -0
- data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryHash_impl.h +270 -0
- data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryIVF_impl.h +460 -0
- data/vendor/faiss/faiss/impl/binary_hamming/IndexIVFSpectralHash_impl.h +159 -0
- data/vendor/faiss/faiss/impl/binary_hamming/IndexPQ_impl.h +92 -0
- data/vendor/faiss/faiss/impl/binary_hamming/avx2.cpp +26 -0
- data/vendor/faiss/faiss/impl/binary_hamming/avx512.cpp +26 -0
- data/vendor/faiss/faiss/impl/binary_hamming/dispatch.h +143 -0
- data/vendor/faiss/faiss/impl/binary_hamming/neon.cpp +26 -0
- data/vendor/faiss/faiss/impl/binary_hamming/rvv.cpp +26 -0
- data/vendor/faiss/faiss/impl/expanded_scanners.h +8 -3
- data/vendor/faiss/faiss/impl/{FastScanDistancePostProcessing.h → fast_scan/FastScanDistancePostProcessing.h} +13 -6
- data/vendor/faiss/faiss/impl/{LookupTableScaler.h → fast_scan/LookupTableScaler.h} +16 -5
- data/vendor/faiss/faiss/impl/fast_scan/accumulate_loops.h +237 -0
- data/vendor/faiss/faiss/impl/fast_scan/accumulate_loops_512.h +185 -0
- data/vendor/faiss/faiss/impl/fast_scan/decompose_qbs.h +229 -0
- data/vendor/faiss/faiss/impl/fast_scan/dispatching.h +268 -0
- data/vendor/faiss/faiss/impl/{pq4_fast_scan.cpp → fast_scan/fast_scan.cpp} +169 -2
- data/vendor/faiss/faiss/impl/fast_scan/fast_scan.h +341 -0
- data/vendor/faiss/faiss/impl/fast_scan/impl-avx2.cpp +36 -0
- data/vendor/faiss/faiss/impl/fast_scan/impl-avx512.cpp +40 -0
- data/vendor/faiss/faiss/impl/fast_scan/impl-neon.cpp +120 -0
- data/vendor/faiss/faiss/impl/fast_scan/impl-riscv.cpp +104 -0
- data/vendor/faiss/faiss/impl/fast_scan/kernels_simd256.h +213 -0
- data/vendor/faiss/faiss/impl/{pq4_fast_scan_search_qbs.cpp → fast_scan/kernels_simd512.h} +26 -356
- data/vendor/faiss/faiss/impl/fast_scan/rabitq_dispatching.h +90 -0
- data/vendor/faiss/faiss/impl/fast_scan/rabitq_result_handler.h +108 -0
- data/vendor/faiss/faiss/impl/{simd_result_handlers.h → fast_scan/simd_result_handlers.h} +282 -134
- data/vendor/faiss/faiss/impl/hnsw/LockVector.cpp +54 -0
- data/vendor/faiss/faiss/impl/hnsw/LockVector.h +64 -0
- data/vendor/faiss/faiss/impl/hnsw/MinimaxHeap.cpp +91 -0
- data/vendor/faiss/faiss/impl/hnsw/MinimaxHeap.h +64 -0
- data/vendor/faiss/faiss/impl/hnsw/avx2.cpp +104 -0
- data/vendor/faiss/faiss/impl/hnsw/avx512.cpp +111 -0
- data/vendor/faiss/faiss/impl/index_read.cpp +1132 -45
- data/vendor/faiss/faiss/impl/index_read_utils.h +1 -1
- data/vendor/faiss/faiss/impl/index_write.cpp +95 -13
- data/vendor/faiss/faiss/impl/io.cpp +6 -6
- data/vendor/faiss/faiss/impl/io_macros.h +33 -16
- data/vendor/faiss/faiss/impl/kmeans1d.cpp +10 -10
- data/vendor/faiss/faiss/impl/lattice_Zn.cpp +37 -23
- data/vendor/faiss/faiss/impl/lattice_Zn.h +6 -6
- data/vendor/faiss/faiss/impl/mapped_io.cpp +6 -6
- data/vendor/faiss/faiss/impl/platform_macros.h +11 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQScanner_impl.h +549 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQ_QueryTables.cpp +245 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQ_QueryTables.h +105 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/PQDistanceComputer_impl.h +106 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/avx2.cpp +21 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/avx512.cpp +21 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/neon.cpp +21 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/{pq_code_distance-avx2.cpp → pq_code_distance-avx2.h} +9 -13
- data/vendor/faiss/faiss/impl/pq_code_distance/{pq_code_distance-avx512.cpp → pq_code_distance-avx512.h} +9 -57
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.cpp +29 -111
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.h +96 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-inl.h +238 -5
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-sve.cpp +5 -7
- data/vendor/faiss/faiss/impl/pq_code_distance/rvv.cpp +68 -0
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +311 -477
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +1 -1
- data/vendor/faiss/faiss/impl/scalar_quantizer/codecs.h +1 -1
- data/vendor/faiss/faiss/impl/scalar_quantizer/distance_computers.h +3 -2
- data/vendor/faiss/faiss/impl/scalar_quantizer/quantizers.h +102 -11
- data/vendor/faiss/faiss/impl/scalar_quantizer/scanners.h +27 -1
- data/vendor/faiss/faiss/impl/scalar_quantizer/similarities.h +3 -3
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx2.cpp +148 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512.cpp +167 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-dispatch.h +59 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-neon.cpp +163 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-rvv.cpp +311 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/training.cpp +192 -8
- data/vendor/faiss/faiss/impl/scalar_quantizer/training.h +12 -0
- data/vendor/faiss/faiss/impl/simd_dispatch.h +100 -66
- data/vendor/faiss/faiss/impl/simdlib/simdlib.h +57 -0
- data/vendor/faiss/faiss/{utils → impl/simdlib}/simdlib_avx2.h +264 -172
- data/vendor/faiss/faiss/impl/simdlib/simdlib_avx512.h +414 -0
- data/vendor/faiss/faiss/impl/simdlib/simdlib_dispatch.h +44 -0
- data/vendor/faiss/faiss/{utils → impl/simdlib}/simdlib_emulated.h +231 -166
- data/vendor/faiss/faiss/{utils → impl/simdlib}/simdlib_neon.h +270 -218
- data/vendor/faiss/faiss/{utils → impl/simdlib}/simdlib_ppc64.h +201 -160
- data/vendor/faiss/faiss/impl/svs_io.cpp +12 -3
- data/vendor/faiss/faiss/impl/svs_io.h +8 -2
- data/vendor/faiss/faiss/index_factory.cpp +86 -18
- data/vendor/faiss/faiss/index_io.h +24 -0
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +66 -16
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +24 -14
- data/vendor/faiss/faiss/invlists/DirectMap.h +4 -3
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +157 -73
- data/vendor/faiss/faiss/invlists/InvertedLists.h +86 -23
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +4 -4
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +13 -13
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +1 -1
- data/vendor/faiss/faiss/svs/IndexSVSFaissUtils.h +1 -1
- data/vendor/faiss/faiss/svs/IndexSVSFlat.cpp +2 -2
- data/vendor/faiss/faiss/svs/IndexSVSIVF.cpp +350 -0
- data/vendor/faiss/faiss/svs/IndexSVSIVF.h +128 -0
- data/vendor/faiss/faiss/svs/IndexSVSIVFLVQ.cpp +40 -0
- data/vendor/faiss/faiss/svs/IndexSVSIVFLVQ.h +43 -0
- data/vendor/faiss/faiss/svs/IndexSVSIVFLeanVec.cpp +225 -0
- data/vendor/faiss/faiss/svs/IndexSVSIVFLeanVec.h +71 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamana.cpp +25 -1
- data/vendor/faiss/faiss/svs/IndexSVSVamana.h +18 -2
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLVQ.h +1 -1
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.cpp +12 -3
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.h +7 -2
- data/vendor/faiss/faiss/utils/Heap.cpp +10 -10
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +47 -36
- data/vendor/faiss/faiss/utils/NeuralNet.h +1 -1
- data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +10 -4
- data/vendor/faiss/faiss/utils/distances.cpp +390 -560
- data/vendor/faiss/faiss/utils/distances.h +20 -1
- data/vendor/faiss/faiss/utils/distances_dispatch.h +117 -37
- data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +8 -7
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +33 -14
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.h +12 -1
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +16 -293
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based_neon.cpp +57 -0
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_kernel-inl.h +290 -0
- data/vendor/faiss/faiss/utils/distances_simd.cpp +5 -177
- data/vendor/faiss/faiss/utils/extra_distances.cpp +9 -8
- data/vendor/faiss/faiss/utils/extra_distances.h +32 -6
- data/vendor/faiss/faiss/utils/hamming-inl.h +13 -11
- data/vendor/faiss/faiss/utils/hamming.cpp +66 -517
- data/vendor/faiss/faiss/utils/hamming.h +92 -2
- data/vendor/faiss/faiss/utils/hamming_distance/common.h +287 -10
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx2.cpp +15 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx512.cpp +15 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-avx2.h +142 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-avx512.h +234 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-generic.h +368 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-neon.h +322 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-rvv.h +39 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer.h +146 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_impl.h +481 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_neon.cpp +15 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_rvv.cpp +15 -0
- data/vendor/faiss/faiss/utils/partitioning.cpp +66 -987
- data/vendor/faiss/faiss/utils/partitioning.h +31 -0
- data/vendor/faiss/faiss/utils/popcount.h +29 -0
- data/vendor/faiss/faiss/utils/pq_code_distance.h +2 -2
- data/vendor/faiss/faiss/utils/prefetch.h +2 -2
- data/vendor/faiss/faiss/utils/quantize_lut.cpp +30 -30
- data/vendor/faiss/faiss/utils/quantize_lut.h +1 -1
- data/vendor/faiss/faiss/utils/rabitq_simd.h +57 -536
- data/vendor/faiss/faiss/utils/random.cpp +6 -6
- data/vendor/faiss/faiss/utils/simd_impl/IVFFlatScanner-inl.h +51 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_aarch64.cpp +5 -1
- data/vendor/faiss/faiss/utils/simd_impl/distances_arm_sve.cpp +213 -4
- data/vendor/faiss/faiss/utils/simd_impl/distances_autovec-inl.h +163 -10
- data/vendor/faiss/faiss/utils/simd_impl/distances_avx2.cpp +250 -4
- data/vendor/faiss/faiss/utils/simd_impl/distances_avx512.cpp +7 -4
- data/vendor/faiss/faiss/utils/simd_impl/distances_rvv.cpp +189 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_simdlib256.h +195 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_sse-inl.h +2 -1
- data/vendor/faiss/faiss/utils/{distances_fused/simdlib_based.h → simd_impl/exhaustive_L2sqr_blas_cmax.h} +5 -10
- data/vendor/faiss/faiss/utils/simd_impl/hamming_impl.h +481 -0
- data/vendor/faiss/faiss/utils/simd_impl/partitioning_avx2.cpp +14 -0
- data/vendor/faiss/faiss/utils/simd_impl/partitioning_neon.cpp +14 -0
- data/vendor/faiss/faiss/utils/simd_impl/partitioning_simdlib256.h +1085 -0
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx2.cpp +355 -0
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx512.cpp +477 -0
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_neon.cpp +55 -0
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_rvv.cpp +55 -0
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_dispatch.h +32 -0
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels.h +43 -0
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_avx2.cpp +57 -0
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_avx512.cpp +45 -0
- data/vendor/faiss/faiss/utils/simd_levels.cpp +17 -5
- data/vendor/faiss/faiss/utils/simd_levels.h +93 -1
- data/vendor/faiss/faiss/utils/sorting.cpp +48 -36
- data/vendor/faiss/faiss/utils/utils.cpp +5 -5
- data/vendor/faiss/faiss/utils/utils.h +3 -3
- metadata +119 -34
- data/vendor/faiss/faiss/impl/RaBitQStats.cpp +0 -29
- data/vendor/faiss/faiss/impl/RaBitQStats.h +0 -56
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +0 -224
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +0 -230
- data/vendor/faiss/faiss/utils/approx_topk/approx_topk.h +0 -84
- data/vendor/faiss/faiss/utils/approx_topk/avx2-inl.h +0 -196
- data/vendor/faiss/faiss/utils/approx_topk/mode.h +0 -34
- data/vendor/faiss/faiss/utils/distances_fused/avx512.h +0 -36
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +0 -235
- data/vendor/faiss/faiss/utils/hamming_distance/avx2-inl.h +0 -462
- data/vendor/faiss/faiss/utils/hamming_distance/avx512-inl.h +0 -490
- data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +0 -449
- data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +0 -87
- data/vendor/faiss/faiss/utils/hamming_distance/neon-inl.h +0 -524
- data/vendor/faiss/faiss/utils/simdlib.h +0 -42
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +0 -365
- /data/ext/faiss/{utils_rb.h → utils.h} +0 -0
|
@@ -28,6 +28,24 @@ struct InvertedListsIterator {
|
|
|
28
28
|
virtual bool is_available() const = 0;
|
|
29
29
|
virtual void next() = 0;
|
|
30
30
|
virtual std::pair<idx_t, const uint8_t*> get_id_and_codes() = 0;
|
|
31
|
+
|
|
32
|
+
/// When true, iterate_codes will invoke on_distance_computed() and
|
|
33
|
+
/// on_heap_changed() via virtual dispatch. When false (the default),
|
|
34
|
+
/// iterate_codes skips the callbacks entirely — the guard branch is
|
|
35
|
+
/// perfectly predicted and costs ~0 cycles, so non-callback users
|
|
36
|
+
/// pay no overhead. Derived classes that override the callbacks
|
|
37
|
+
/// should set this to true in their constructor.
|
|
38
|
+
bool has_search_callbacks_ = false;
|
|
39
|
+
|
|
40
|
+
/// Called from iterate_codes after distance computation for the vector
|
|
41
|
+
/// returned by the most recent get_id_and_codes(). Default: no-op.
|
|
42
|
+
/// Only invoked when has_search_callbacks_ is true.
|
|
43
|
+
virtual void on_distance_computed(idx_t /* vid */, float /* distance */) {}
|
|
44
|
+
|
|
45
|
+
/// Called from iterate_codes when a vector replaces the current worst
|
|
46
|
+
/// in the top-K heap. evicted_id is the displaced entry. Default: no-op.
|
|
47
|
+
/// Only invoked when has_search_callbacks_ is true.
|
|
48
|
+
virtual void on_heap_changed(idx_t /* new_id */, idx_t /* evicted_id */) {}
|
|
31
49
|
};
|
|
32
50
|
|
|
33
51
|
/** Table of inverted lists
|
|
@@ -44,7 +62,7 @@ struct InvertedLists {
|
|
|
44
62
|
/// request to use iterator rather than get_codes / get_ids
|
|
45
63
|
bool use_iterator = false;
|
|
46
64
|
|
|
47
|
-
InvertedLists(size_t
|
|
65
|
+
InvertedLists(size_t nlist_, size_t code_size_);
|
|
48
66
|
|
|
49
67
|
virtual ~InvertedLists();
|
|
50
68
|
|
|
@@ -87,7 +105,7 @@ struct InvertedLists {
|
|
|
87
105
|
|
|
88
106
|
/// prepare the following lists (default does nothing)
|
|
89
107
|
/// a list can be -1 hence the signed long
|
|
90
|
-
virtual void prefetch_lists(const idx_t* list_nos, int
|
|
108
|
+
virtual void prefetch_lists(const idx_t* list_nos, int nlist_in) const;
|
|
91
109
|
|
|
92
110
|
/*****************************************
|
|
93
111
|
* Iterator interface (with context) */
|
|
@@ -203,8 +221,8 @@ struct InvertedLists {
|
|
|
203
221
|
const idx_t* ids;
|
|
204
222
|
size_t list_no;
|
|
205
223
|
|
|
206
|
-
ScopedIds(const InvertedLists*
|
|
207
|
-
: il(
|
|
224
|
+
ScopedIds(const InvertedLists* il_, size_t list_no_)
|
|
225
|
+
: il(il_), ids(il_->get_ids(list_no_)), list_no(list_no_) {}
|
|
208
226
|
|
|
209
227
|
const idx_t* get() {
|
|
210
228
|
return ids;
|
|
@@ -224,13 +242,13 @@ struct InvertedLists {
|
|
|
224
242
|
const uint8_t* codes;
|
|
225
243
|
size_t list_no;
|
|
226
244
|
|
|
227
|
-
ScopedCodes(const InvertedLists*
|
|
228
|
-
: il(
|
|
245
|
+
ScopedCodes(const InvertedLists* il_, size_t list_no_)
|
|
246
|
+
: il(il_), codes(il_->get_codes(list_no_)), list_no(list_no_) {}
|
|
229
247
|
|
|
230
|
-
ScopedCodes(const InvertedLists*
|
|
231
|
-
: il(
|
|
232
|
-
codes(
|
|
233
|
-
list_no(
|
|
248
|
+
ScopedCodes(const InvertedLists* il_, size_t list_no_, size_t offset)
|
|
249
|
+
: il(il_),
|
|
250
|
+
codes(il_->get_single_code(list_no_, offset)),
|
|
251
|
+
list_no(list_no_) {}
|
|
234
252
|
|
|
235
253
|
const uint8_t* get() {
|
|
236
254
|
return codes;
|
|
@@ -247,7 +265,7 @@ struct ArrayInvertedLists : InvertedLists {
|
|
|
247
265
|
std::vector<MaybeOwnedVector<uint8_t>> codes; // binary codes, size nlist
|
|
248
266
|
std::vector<MaybeOwnedVector<idx_t>> ids; ///< Inverted lists for indexes
|
|
249
267
|
|
|
250
|
-
ArrayInvertedLists(size_t
|
|
268
|
+
ArrayInvertedLists(size_t nlist_in, size_t code_size_in);
|
|
251
269
|
|
|
252
270
|
size_t list_size(size_t list_no) const override;
|
|
253
271
|
const uint8_t* get_codes(size_t list_no) const override;
|
|
@@ -280,13 +298,16 @@ struct ArrayInvertedLists : InvertedLists {
|
|
|
280
298
|
/// Level-oriented storage as defined in the IVFFlat section of Panorama
|
|
281
299
|
/// (https://www.arxiv.org/pdf/2510.00566).
|
|
282
300
|
struct ArrayInvertedListsPanorama : ArrayInvertedLists {
|
|
283
|
-
static constexpr size_t kBatchSize = 128;
|
|
284
301
|
std::vector<MaybeOwnedVector<float>> cum_sums;
|
|
285
302
|
const size_t n_levels;
|
|
286
303
|
const size_t level_width; // in code units
|
|
287
304
|
Panorama pano;
|
|
288
305
|
|
|
289
|
-
ArrayInvertedListsPanorama(
|
|
306
|
+
ArrayInvertedListsPanorama(
|
|
307
|
+
size_t nlist_in,
|
|
308
|
+
size_t code_size_in,
|
|
309
|
+
size_t n_levels_in,
|
|
310
|
+
size_t batch_size = Panorama::kDefaultBatchSize);
|
|
290
311
|
|
|
291
312
|
const float* get_cum_sums(size_t list_no) const;
|
|
292
313
|
|
|
@@ -319,7 +340,7 @@ struct ArrayInvertedListsPanorama : ArrayInvertedLists {
|
|
|
319
340
|
const override;
|
|
320
341
|
|
|
321
342
|
/// Frees codes returned by `get_single_code`.
|
|
322
|
-
void release_codes(size_t list_no, const uint8_t*
|
|
343
|
+
void release_codes(size_t list_no, const uint8_t* codes_in) const override;
|
|
323
344
|
};
|
|
324
345
|
|
|
325
346
|
/*****************************************************************
|
|
@@ -331,8 +352,8 @@ struct ArrayInvertedListsPanorama : ArrayInvertedLists {
|
|
|
331
352
|
|
|
332
353
|
/// invlists that fail for all write functions
|
|
333
354
|
struct ReadOnlyInvertedLists : InvertedLists {
|
|
334
|
-
ReadOnlyInvertedLists(size_t
|
|
335
|
-
: InvertedLists(
|
|
355
|
+
ReadOnlyInvertedLists(size_t nlist_, size_t code_size_)
|
|
356
|
+
: InvertedLists(nlist_, code_size_) {}
|
|
336
357
|
|
|
337
358
|
size_t add_entries(
|
|
338
359
|
size_t list_no,
|
|
@@ -361,7 +382,7 @@ struct HStackInvertedLists : ReadOnlyInvertedLists {
|
|
|
361
382
|
const uint8_t* get_codes(size_t list_no) const override;
|
|
362
383
|
const idx_t* get_ids(size_t list_no) const override;
|
|
363
384
|
|
|
364
|
-
void prefetch_lists(const idx_t* list_nos, int
|
|
385
|
+
void prefetch_lists(const idx_t* list_nos, int nlist_in) const override;
|
|
365
386
|
|
|
366
387
|
void release_codes(size_t list_no, const uint8_t* codes) const override;
|
|
367
388
|
void release_ids(size_t list_no, const idx_t* ids) const override;
|
|
@@ -379,7 +400,7 @@ struct SliceInvertedLists : ReadOnlyInvertedLists {
|
|
|
379
400
|
const InvertedLists* il;
|
|
380
401
|
idx_t i0, i1;
|
|
381
402
|
|
|
382
|
-
SliceInvertedLists(const InvertedLists*
|
|
403
|
+
SliceInvertedLists(const InvertedLists* il_, idx_t i0_, idx_t i1_);
|
|
383
404
|
|
|
384
405
|
size_t list_size(size_t list_no) const override;
|
|
385
406
|
const uint8_t* get_codes(size_t list_no) const override;
|
|
@@ -393,7 +414,7 @@ struct SliceInvertedLists : ReadOnlyInvertedLists {
|
|
|
393
414
|
const uint8_t* get_single_code(size_t list_no, size_t offset)
|
|
394
415
|
const override;
|
|
395
416
|
|
|
396
|
-
void prefetch_lists(const idx_t* list_nos, int
|
|
417
|
+
void prefetch_lists(const idx_t* list_nos, int nlist_in) const override;
|
|
397
418
|
};
|
|
398
419
|
|
|
399
420
|
struct VStackInvertedLists : ReadOnlyInvertedLists {
|
|
@@ -415,7 +436,7 @@ struct VStackInvertedLists : ReadOnlyInvertedLists {
|
|
|
415
436
|
const uint8_t* get_single_code(size_t list_no, size_t offset)
|
|
416
437
|
const override;
|
|
417
438
|
|
|
418
|
-
void prefetch_lists(const idx_t* list_nos, int
|
|
439
|
+
void prefetch_lists(const idx_t* list_nos, int nlist_in) const override;
|
|
419
440
|
};
|
|
420
441
|
|
|
421
442
|
/** use the first inverted lists if they are non-empty otherwise use the second
|
|
@@ -427,7 +448,9 @@ struct MaskedInvertedLists : ReadOnlyInvertedLists {
|
|
|
427
448
|
const InvertedLists* il0;
|
|
428
449
|
const InvertedLists* il1;
|
|
429
450
|
|
|
430
|
-
MaskedInvertedLists(
|
|
451
|
+
MaskedInvertedLists(
|
|
452
|
+
const InvertedLists* il0_in,
|
|
453
|
+
const InvertedLists* il1_in);
|
|
431
454
|
|
|
432
455
|
size_t list_size(size_t list_no) const override;
|
|
433
456
|
const uint8_t* get_codes(size_t list_no) const override;
|
|
@@ -441,7 +464,7 @@ struct MaskedInvertedLists : ReadOnlyInvertedLists {
|
|
|
441
464
|
const uint8_t* get_single_code(size_t list_no, size_t offset)
|
|
442
465
|
const override;
|
|
443
466
|
|
|
444
|
-
void prefetch_lists(const idx_t* list_nos, int
|
|
467
|
+
void prefetch_lists(const idx_t* list_nos, int nlist_in) const override;
|
|
445
468
|
};
|
|
446
469
|
|
|
447
470
|
/** if the inverted list in il is smaller than maxsize then return it,
|
|
@@ -450,7 +473,7 @@ struct StopWordsInvertedLists : ReadOnlyInvertedLists {
|
|
|
450
473
|
const InvertedLists* il0;
|
|
451
474
|
size_t maxsize;
|
|
452
475
|
|
|
453
|
-
StopWordsInvertedLists(const InvertedLists*
|
|
476
|
+
StopWordsInvertedLists(const InvertedLists* il0_in, size_t maxsize_in);
|
|
454
477
|
|
|
455
478
|
size_t list_size(size_t list_no) const override;
|
|
456
479
|
const uint8_t* get_codes(size_t list_no) const override;
|
|
@@ -461,10 +484,50 @@ struct StopWordsInvertedLists : ReadOnlyInvertedLists {
|
|
|
461
484
|
|
|
462
485
|
idx_t get_single_id(size_t list_no, size_t offset) const override;
|
|
463
486
|
|
|
487
|
+
const uint8_t* get_single_code(size_t list_no, size_t offset)
|
|
488
|
+
const override;
|
|
489
|
+
|
|
490
|
+
void prefetch_lists(const idx_t* list_nos, int nlist_in) const override;
|
|
491
|
+
};
|
|
492
|
+
|
|
493
|
+
/** Cap list sizes to maxsize for searching, while allowing writes.
|
|
494
|
+
* Unlike StopWordsInvertedLists which skips large lists entirely,
|
|
495
|
+
* this caps each list to maxsize entries (partial scan). */
|
|
496
|
+
struct CappedInvertedLists : InvertedLists {
|
|
497
|
+
InvertedLists* il0;
|
|
498
|
+
size_t maxsize;
|
|
499
|
+
|
|
500
|
+
CappedInvertedLists(InvertedLists* il, size_t maxsize);
|
|
501
|
+
|
|
502
|
+
size_t list_size(size_t list_no) const override;
|
|
503
|
+
size_t real_list_size(size_t list_no) const;
|
|
504
|
+
|
|
505
|
+
const uint8_t* get_codes(size_t list_no) const override;
|
|
506
|
+
const idx_t* get_ids(size_t list_no) const override;
|
|
507
|
+
|
|
508
|
+
void release_codes(size_t list_no, const uint8_t* codes) const override;
|
|
509
|
+
void release_ids(size_t list_no, const idx_t* ids) const override;
|
|
510
|
+
|
|
511
|
+
idx_t get_single_id(size_t list_no, size_t offset) const override;
|
|
464
512
|
const uint8_t* get_single_code(size_t list_no, size_t offset)
|
|
465
513
|
const override;
|
|
466
514
|
|
|
467
515
|
void prefetch_lists(const idx_t* list_nos, int nlist) const override;
|
|
516
|
+
|
|
517
|
+
size_t add_entries(
|
|
518
|
+
size_t list_no,
|
|
519
|
+
size_t n_entry,
|
|
520
|
+
const idx_t* ids,
|
|
521
|
+
const uint8_t* code) override;
|
|
522
|
+
|
|
523
|
+
void update_entries(
|
|
524
|
+
size_t list_no,
|
|
525
|
+
size_t offset,
|
|
526
|
+
size_t n_entry,
|
|
527
|
+
const idx_t* ids,
|
|
528
|
+
const uint8_t* code) override;
|
|
529
|
+
|
|
530
|
+
void resize(size_t list_no, size_t new_size) override;
|
|
468
531
|
};
|
|
469
532
|
|
|
470
533
|
} // namespace faiss
|
|
@@ -24,9 +24,9 @@ namespace faiss {
|
|
|
24
24
|
**********************************************************/
|
|
25
25
|
|
|
26
26
|
InvertedListsIOHook::InvertedListsIOHook(
|
|
27
|
-
const std::string&
|
|
28
|
-
const std::string&
|
|
29
|
-
: key(
|
|
27
|
+
const std::string& key_in,
|
|
28
|
+
const std::string& classname_in)
|
|
29
|
+
: key(key_in), classname(classname_in) {}
|
|
30
30
|
|
|
31
31
|
namespace {
|
|
32
32
|
|
|
@@ -52,7 +52,7 @@ static IOHookTable InvertedListsIOHook_table;
|
|
|
52
52
|
|
|
53
53
|
InvertedListsIOHook* InvertedListsIOHook::lookup(int h) {
|
|
54
54
|
for (const auto& callback : InvertedListsIOHook_table) {
|
|
55
|
-
if (h == fourcc(callback->key)) {
|
|
55
|
+
if (static_cast<uint32_t>(h) == fourcc(callback->key)) {
|
|
56
56
|
return callback;
|
|
57
57
|
}
|
|
58
58
|
}
|
|
@@ -111,7 +111,7 @@ struct LockLevels {
|
|
|
111
111
|
level3_in_use = true;
|
|
112
112
|
// wait until there are no level1 holders anymore except the
|
|
113
113
|
// ones that are waiting on level2 (we are holding lock2)
|
|
114
|
-
while (level1_holders.size() > n_level2) {
|
|
114
|
+
while (level1_holders.size() > static_cast<size_t>(n_level2)) {
|
|
115
115
|
pthread_cond_wait(&level3_cv, &mutex1);
|
|
116
116
|
}
|
|
117
117
|
// don't release the lock!
|
|
@@ -161,7 +161,7 @@ struct OnDiskInvertedLists::OngoingPrefetch {
|
|
|
161
161
|
cs += idx[i];
|
|
162
162
|
}
|
|
163
163
|
const idx_t* codes8 = (const idx_t*)codes;
|
|
164
|
-
|
|
164
|
+
size_t n8 = n * od->code_size / 8;
|
|
165
165
|
|
|
166
166
|
for (size_t i = 0; i < n8; i++) {
|
|
167
167
|
cs += codes8[i];
|
|
@@ -187,7 +187,7 @@ struct OnDiskInvertedLists::OngoingPrefetch {
|
|
|
187
187
|
|
|
188
188
|
const OnDiskInvertedLists* od;
|
|
189
189
|
|
|
190
|
-
explicit OngoingPrefetch(const OnDiskInvertedLists*
|
|
190
|
+
explicit OngoingPrefetch(const OnDiskInvertedLists* od_in) : od(od_in) {
|
|
191
191
|
pthread_mutex_init(&mutex, nullptr);
|
|
192
192
|
pthread_mutex_init(&list_ids_mutex, nullptr);
|
|
193
193
|
cur_list = 0;
|
|
@@ -206,7 +206,7 @@ struct OnDiskInvertedLists::OngoingPrefetch {
|
|
|
206
206
|
idx_t get_next_list() {
|
|
207
207
|
idx_t list_no = -1;
|
|
208
208
|
pthread_mutex_lock(&list_ids_mutex);
|
|
209
|
-
if (cur_list >= 0 && cur_list < list_ids.size()) {
|
|
209
|
+
if (cur_list >= 0 && static_cast<size_t>(cur_list) < list_ids.size()) {
|
|
210
210
|
list_no = list_ids[cur_list++];
|
|
211
211
|
}
|
|
212
212
|
pthread_mutex_unlock(&list_ids_mutex);
|
|
@@ -341,17 +341,17 @@ void OnDiskInvertedLists::update_totsize(size_t new_size) {
|
|
|
341
341
|
|
|
342
342
|
OnDiskOneList::OnDiskOneList() : size(0), capacity(0), offset(INVALID_OFFSET) {}
|
|
343
343
|
|
|
344
|
-
OnDiskInvertedLists::Slot::Slot(size_t
|
|
345
|
-
: offset(
|
|
344
|
+
OnDiskInvertedLists::Slot::Slot(size_t offset_in, size_t capacity_in)
|
|
345
|
+
: offset(offset_in), capacity(capacity_in) {}
|
|
346
346
|
|
|
347
347
|
OnDiskInvertedLists::Slot::Slot() : offset(0), capacity(0) {}
|
|
348
348
|
|
|
349
349
|
OnDiskInvertedLists::OnDiskInvertedLists(
|
|
350
|
-
size_t
|
|
351
|
-
size_t
|
|
352
|
-
const char*
|
|
353
|
-
: InvertedLists(
|
|
354
|
-
filename(
|
|
350
|
+
size_t nlist_in,
|
|
351
|
+
size_t code_size_in,
|
|
352
|
+
const char* filename_in)
|
|
353
|
+
: InvertedLists(nlist_in, code_size_in),
|
|
354
|
+
filename(filename_in),
|
|
355
355
|
totsize(0),
|
|
356
356
|
ptr(nullptr),
|
|
357
357
|
read_only(false),
|
|
@@ -607,7 +607,7 @@ size_t OnDiskInvertedLists::merge_from_multiple(
|
|
|
607
607
|
double t0 = getmillisecs(), last_t = t0;
|
|
608
608
|
|
|
609
609
|
#pragma omp parallel for
|
|
610
|
-
for (
|
|
610
|
+
for (int64_t j = 0; j < static_cast<int64_t>(nlist); j++) {
|
|
611
611
|
List& l = lists[j];
|
|
612
612
|
for (int i = 0; i < n_il; i++) {
|
|
613
613
|
const InvertedLists* il = ils[i];
|
|
@@ -660,7 +660,7 @@ size_t OnDiskInvertedLists::merge_from_1(
|
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
void OnDiskInvertedLists::crop_invlists(size_t l0, size_t l1) {
|
|
663
|
-
FAISS_THROW_IF_NOT(
|
|
663
|
+
FAISS_THROW_IF_NOT(l0 <= l1 && l1 <= nlist);
|
|
664
664
|
|
|
665
665
|
std::vector<List> new_lists(l1 - l0);
|
|
666
666
|
memcpy(new_lists.data(), &lists[l0], (l1 - l0) * sizeof(List));
|
|
@@ -113,7 +113,7 @@ struct OnDiskInvertedLists : InvertedLists {
|
|
|
113
113
|
/// restrict the inverted lists to l0:l1 without touching the mmapped region
|
|
114
114
|
void crop_invlists(size_t l0, size_t l1);
|
|
115
115
|
|
|
116
|
-
void prefetch_lists(const idx_t* list_nos, int
|
|
116
|
+
void prefetch_lists(const idx_t* list_nos, int nlist_in) const override;
|
|
117
117
|
|
|
118
118
|
~OnDiskInvertedLists() override;
|
|
119
119
|
|
|
@@ -54,7 +54,7 @@ inline svs_runtime::MetricType to_svs_metric(faiss::MetricType metric) {
|
|
|
54
54
|
case METRIC_L2:
|
|
55
55
|
return svs_runtime::MetricType::L2;
|
|
56
56
|
default:
|
|
57
|
-
|
|
57
|
+
FAISS_THROW_MSG("not supported SVS distance");
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -107,11 +107,11 @@ void IndexSVSFlat::serialize_impl(std::ostream& out) const {
|
|
|
107
107
|
void IndexSVSFlat::deserialize_impl(std::istream& in) {
|
|
108
108
|
FAISS_THROW_IF_MSG(impl, "Cannot deserialize: SVS index already loaded.");
|
|
109
109
|
auto metric = to_svs_metric(metric_type);
|
|
110
|
-
auto status =
|
|
110
|
+
auto status = svs_runtime::FlatIndex::load(&impl, in, metric);
|
|
111
111
|
if (!status.ok()) {
|
|
112
112
|
FAISS_THROW_MSG(status.message());
|
|
113
113
|
}
|
|
114
|
-
|
|
114
|
+
FAISS_THROW_IF_NOT_MSG(impl, "Failed to load SVS Flat index.");
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
} // namespace faiss
|