faiss 0.6.4 → 0.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/ext/faiss/extconf.rb +2 -1
- data/ext/faiss/index.cpp +42 -0
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +175 -0
- data/vendor/faiss/faiss/Clustering.cpp +150 -60
- data/vendor/faiss/faiss/Clustering.h +29 -0
- data/vendor/faiss/faiss/IVFlib.cpp +147 -51
- data/vendor/faiss/faiss/IVFlib.h +21 -2
- data/vendor/faiss/faiss/Index.cpp +44 -0
- data/vendor/faiss/faiss/Index.h +18 -13
- data/vendor/faiss/faiss/IndexBinary.cpp +8 -0
- data/vendor/faiss/faiss/IndexBinary.h +8 -0
- data/vendor/faiss/faiss/IndexBinaryFlat.cpp +1 -0
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +85 -4
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +19 -0
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +40 -11
- data/vendor/faiss/faiss/IndexFastScan.cpp +34 -18
- data/vendor/faiss/faiss/IndexFastScan.h +6 -3
- data/vendor/faiss/faiss/IndexFlat.cpp +57 -1
- data/vendor/faiss/faiss/IndexFlat.h +31 -0
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +6 -1
- data/vendor/faiss/faiss/IndexHNSW.cpp +461 -13
- data/vendor/faiss/faiss/IndexHNSW.h +40 -5
- data/vendor/faiss/faiss/IndexIDMap.cpp +45 -0
- data/vendor/faiss/faiss/IndexIDMap.h +15 -3
- data/vendor/faiss/faiss/IndexIVF.cpp +349 -68
- data/vendor/faiss/faiss/IndexIVF.h +90 -2
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +51 -29
- data/vendor/faiss/faiss/IndexIVFFastScan.h +4 -2
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +33 -0
- data/vendor/faiss/faiss/IndexIVFFlat.h +22 -6
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +2 -1
- data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +3 -20
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +78 -58
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +7 -13
- data/vendor/faiss/faiss/IndexIVFRaBitQSSD.cpp +1694 -0
- data/vendor/faiss/faiss/IndexIVFRaBitQSSD.h +288 -0
- data/vendor/faiss/faiss/IndexIVFSQFastScan.cpp +860 -0
- data/vendor/faiss/faiss/IndexIVFSQFastScan.h +145 -0
- data/vendor/faiss/faiss/IndexNNDescent.cpp +21 -3
- data/vendor/faiss/faiss/IndexPiPNN.cpp +201 -0
- data/vendor/faiss/faiss/IndexPiPNN.h +83 -0
- data/vendor/faiss/faiss/IndexRaBitQ.cpp +189 -41
- data/vendor/faiss/faiss/IndexRaBitQ.h +5 -0
- data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +7 -4
- data/vendor/faiss/faiss/IndexRaBitQFastScan.h +12 -6
- data/vendor/faiss/faiss/IndexReplicas.cpp +20 -0
- data/vendor/faiss/faiss/IndexReplicas.h +9 -0
- data/vendor/faiss/faiss/IndexSQFastScan.cpp +648 -0
- data/vendor/faiss/faiss/IndexSQFastScan.h +129 -0
- data/vendor/faiss/faiss/IndexShards.cpp +10 -0
- data/vendor/faiss/faiss/IndexShards.h +5 -0
- data/vendor/faiss/faiss/SuperKMeans.cpp +59 -17
- data/vendor/faiss/faiss/SuperKMeans.h +9 -4
- data/vendor/faiss/faiss/VectorTransform.cpp +159 -11
- data/vendor/faiss/faiss/VectorTransform.h +24 -1
- data/vendor/faiss/faiss/clone_index.cpp +24 -0
- data/vendor/faiss/faiss/factory_tools.cpp +19 -1
- data/vendor/faiss/faiss/gpu/Dataset.h +164 -0
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +16 -13
- data/vendor/faiss/faiss/gpu/GpuCloner.h +4 -0
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +3 -0
- data/vendor/faiss/faiss/gpu/GpuIndex.h +4 -13
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryCagra.h +32 -13
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +51 -22
- data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +11 -0
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +6 -0
- data/vendor/faiss/faiss/gpu/impl/optimal_kmeans/GpuOptimalKMeans.h +184 -0
- data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +12 -4
- data/vendor/faiss/faiss/gpu/test/TestGpuDatasetHeader.cpp +18 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +215 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +98 -0
- data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +6 -5
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +11 -0
- data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +1 -1
- data/vendor/faiss/faiss/gpu_metal/GpuIndexFlat.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/MetalCloner.h +12 -1
- data/vendor/faiss/faiss/gpu_metal/MetalDistance.h +93 -1
- data/vendor/faiss/faiss/gpu_metal/MetalFlatKernels.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/MetalIndex.h +5 -1
- data/vendor/faiss/faiss/gpu_metal/MetalIndexBinaryFlat.h +69 -0
- data/vendor/faiss/faiss/gpu_metal/MetalIndexFlat.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/MetalIndexIVFFlat.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/MetalIndexIVFPQ.h +39 -1
- data/vendor/faiss/faiss/gpu_metal/MetalKernels.h +107 -1
- data/vendor/faiss/faiss/gpu_metal/MetalPythonBridge.h +11 -1
- data/vendor/faiss/faiss/gpu_metal/MetalResources.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/StandardMetalResources.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/impl/MetalIVFFlat.h +1 -1
- data/vendor/faiss/faiss/gpu_metal/impl/MetalIVFPQ.h +1 -1
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +3 -1
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +1 -6
- data/vendor/faiss/faiss/impl/ClusteringHelpers.cpp +134 -45
- data/vendor/faiss/faiss/impl/ClusteringHelpers.h +36 -0
- data/vendor/faiss/faiss/impl/ClusteringInitialization.cpp +267 -136
- data/vendor/faiss/faiss/impl/ClusteringInitialization.h +0 -15
- data/vendor/faiss/faiss/impl/CodePacker.cpp +2 -2
- data/vendor/faiss/faiss/impl/CodePackerRaBitQ.cpp +2 -2
- data/vendor/faiss/faiss/impl/DeterministicNNDescent.cpp +2167 -0
- data/vendor/faiss/faiss/impl/DeterministicNNDescent.h +301 -0
- data/vendor/faiss/faiss/impl/DistanceComputer.cpp +63 -0
- data/vendor/faiss/faiss/impl/DistanceComputer.h +3 -29
- data/vendor/faiss/faiss/impl/HNSW.cpp +48 -12
- data/vendor/faiss/faiss/impl/HNSW.h +74 -2
- data/vendor/faiss/faiss/impl/IDSelector.h +5 -4
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +6 -19
- data/vendor/faiss/faiss/impl/NNDescent.cpp +2 -1
- data/vendor/faiss/faiss/impl/NNDescent.h +4 -0
- data/vendor/faiss/faiss/impl/NSG.cpp +3 -2
- data/vendor/faiss/faiss/impl/Panorama.h +3 -2
- data/vendor/faiss/faiss/impl/PiPNN.cpp +824 -0
- data/vendor/faiss/faiss/impl/PiPNN.h +122 -0
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +1 -1
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +54 -11
- data/vendor/faiss/faiss/impl/RaBitQUtils.cpp +0 -2
- data/vendor/faiss/faiss/impl/RaBitQUtils.h +30 -1
- data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +91 -66
- data/vendor/faiss/faiss/impl/RaBitQuantizer.h +15 -0
- data/vendor/faiss/faiss/impl/ResultHandler.h +116 -0
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +29 -0
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +1 -6
- data/vendor/faiss/faiss/impl/approx_topk/avx2.cpp +0 -4
- data/vendor/faiss/faiss/impl/approx_topk/neon.cpp +0 -4
- data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryHash_impl.h +5 -2
- data/vendor/faiss/faiss/impl/binary_hamming/IndexBinaryIVF_impl.h +1 -3
- data/vendor/faiss/faiss/impl/binary_hamming/avx2.cpp +0 -4
- data/vendor/faiss/faiss/impl/binary_hamming/avx512.cpp +0 -4
- data/vendor/faiss/faiss/impl/binary_hamming/neon.cpp +0 -4
- data/vendor/faiss/faiss/impl/binary_hamming/rvv.cpp +0 -4
- data/vendor/faiss/faiss/impl/expanded_scanners.h +93 -0
- data/vendor/faiss/faiss/impl/fast_scan/FastScanDistancePostProcessing.h +4 -0
- data/vendor/faiss/faiss/impl/fast_scan/accumulate_loops.h +61 -64
- data/vendor/faiss/faiss/impl/fast_scan/accumulate_loops_512.h +13 -14
- data/vendor/faiss/faiss/impl/fast_scan/decompose_qbs.h +17 -129
- data/vendor/faiss/faiss/impl/fast_scan/dispatching.h +25 -19
- data/vendor/faiss/faiss/impl/fast_scan/fast_scan.cpp +73 -6
- data/vendor/faiss/faiss/impl/fast_scan/fast_scan.h +43 -0
- data/vendor/faiss/faiss/impl/fast_scan/impl-avx2.cpp +15 -4
- data/vendor/faiss/faiss/impl/fast_scan/impl-avx512.cpp +115 -4
- data/vendor/faiss/faiss/impl/fast_scan/impl-neon.cpp +10 -85
- data/vendor/faiss/faiss/impl/fast_scan/impl-riscv.cpp +0 -4
- data/vendor/faiss/faiss/impl/fast_scan/kernels_neon.h +155 -0
- data/vendor/faiss/faiss/impl/fast_scan/kernels_simd256.h +106 -1
- data/vendor/faiss/faiss/impl/fast_scan/kernels_simd512.h +3 -6
- data/vendor/faiss/faiss/impl/fast_scan/rabitq_result_handler.h +0 -1
- data/vendor/faiss/faiss/impl/fast_scan/simd_result_handlers.h +105 -78
- data/vendor/faiss/faiss/impl/hnsw/LockVector.h +1 -2
- data/vendor/faiss/faiss/impl/hnsw/avx2.cpp +0 -4
- data/vendor/faiss/faiss/impl/hnsw/avx512.cpp +0 -4
- data/vendor/faiss/faiss/impl/index_read.cpp +318 -9
- data/vendor/faiss/faiss/impl/index_write.cpp +124 -5
- data/vendor/faiss/faiss/impl/io.cpp +1 -0
- data/vendor/faiss/faiss/impl/io_macros.h +2 -2
- data/vendor/faiss/faiss/impl/mapped_io.cpp +3 -1
- data/vendor/faiss/faiss/impl/maybe_owned_vector.h +78 -41
- data/vendor/faiss/faiss/impl/nndescent/gram-avx2.cpp +121 -0
- data/vendor/faiss/faiss/impl/nndescent/gram-avx512.cpp +124 -0
- data/vendor/faiss/faiss/impl/nndescent/gram-neon.cpp +114 -0
- data/vendor/faiss/faiss/impl/nndescent/gram.h +66 -0
- data/vendor/faiss/faiss/impl/optimal_kmeans/BlockCombiner-avx512.cpp +431 -0
- data/vendor/faiss/faiss/impl/optimal_kmeans/BlockCombiner-inl.h +1157 -0
- data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeans.cpp +282 -0
- data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeans.h +226 -0
- data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeansCompressed.cpp +1567 -0
- data/vendor/faiss/faiss/impl/optimal_kmeans/OptimalKMeansCompressed.h +281 -0
- data/vendor/faiss/faiss/impl/pipnn/HashPrune.cpp +159 -0
- data/vendor/faiss/faiss/impl/pipnn/HashPrune.h +69 -0
- data/vendor/faiss/faiss/impl/pipnn/Partition.cpp +587 -0
- data/vendor/faiss/faiss/impl/pipnn/Partition.h +93 -0
- data/vendor/faiss/faiss/impl/pipnn/kernels.cpp +326 -0
- data/vendor/faiss/faiss/impl/pipnn/kernels.h +92 -0
- data/vendor/faiss/faiss/impl/platform_macros.h +91 -27
- data/vendor/faiss/faiss/impl/polysemous_training/avx512.cpp +0 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQScanner_impl.h +84 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/IVFPQ_QueryTables.cpp +17 -17
- data/vendor/faiss/faiss/impl/pq_code_distance/PQDistanceComputer_impl.h +6 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/avx2.cpp +0 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/avx512.cpp +0 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/neon.cpp +0 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-avx2.h +4 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-avx512.h +4 -1
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.cpp +19 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.h +6 -6
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-inl.h +131 -6
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-sve.cpp +0 -4
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_rvv_kernel.h +89 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_scan_impl.h +21 -10
- data/vendor/faiss/faiss/impl/pq_code_distance/rvv.cpp +45 -18
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +2 -1
- data/vendor/faiss/faiss/impl/result_handler/ResultHandler.cpp +68 -1
- data/vendor/faiss/faiss/impl/result_handler/avx2.cpp +70 -6
- data/vendor/faiss/faiss/impl/result_handler/avx512.cpp +2 -5
- data/vendor/faiss/faiss/impl/scalar_quantizer/EDENQuantizer-avx2.cpp +0 -4
- data/vendor/faiss/faiss/impl/scalar_quantizer/EDENQuantizer-avx512.cpp +0 -4
- data/vendor/faiss/faiss/impl/scalar_quantizer/EDENQuantizer.cpp +1 -1
- data/vendor/faiss/faiss/impl/scalar_quantizer/distance_computers.h +5 -1
- data/vendor/faiss/faiss/impl/scalar_quantizer/quantizers.h +28 -52
- data/vendor/faiss/faiss/impl/scalar_quantizer/scanners.h +85 -37
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx2.cpp +262 -110
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512-impl.h +503 -122
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512-spr.cpp +10 -155
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512.cpp +7 -701
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-dispatch.h +66 -57
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-neon.cpp +133 -127
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-rvv.cpp +3185 -144
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq8_coefficients.h +48 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq8_rvv_kernel.h +546 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/training.cpp +2 -2
- data/vendor/faiss/faiss/impl/simd_dispatch.h +7 -0
- data/vendor/faiss/faiss/impl/simdlib/simdlib_avx2.h +14 -0
- data/vendor/faiss/faiss/impl/simdlib/simdlib_avx512.h +20 -20
- data/vendor/faiss/faiss/impl/simdlib/simdlib_dispatch.h +7 -8
- data/vendor/faiss/faiss/impl/simdlib/simdlib_neon.h +4 -4
- data/vendor/faiss/faiss/impl/sq_fastscan_utils.h +232 -0
- data/vendor/faiss/faiss/impl/zerocopy_io.cpp +2 -1
- data/vendor/faiss/faiss/index_factory.cpp +106 -6
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +1 -1
- data/vendor/faiss/faiss/invlists/DiskIOBackend.cpp +121 -0
- data/vendor/faiss/faiss/invlists/DiskIOBackend.h +71 -0
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +15 -10
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +26 -0
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.h +5 -0
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +9 -24
- data/vendor/faiss/faiss/invlists/RaBitQSSDInvertedLists.cpp +751 -0
- data/vendor/faiss/faiss/invlists/RaBitQSSDInvertedLists.h +224 -0
- data/vendor/faiss/faiss/svs/IndexSVSFaissUtils.h +2 -7
- data/vendor/faiss/faiss/svs/IndexSVSFlat.cpp +1 -1
- data/vendor/faiss/faiss/svs/IndexSVSIVF.cpp +2 -2
- data/vendor/faiss/faiss/svs/IndexSVSVamana.cpp +4 -4
- data/vendor/faiss/faiss/svs/IndexSVSVamana.h +3 -2
- data/vendor/faiss/faiss/utils/AlignedTable.h +6 -1
- data/vendor/faiss/faiss/utils/Heap.cpp +4 -3
- data/vendor/faiss/faiss/utils/WorkerThread.h +0 -1
- data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +16 -5
- data/vendor/faiss/faiss/utils/bf16.h +36 -0
- data/vendor/faiss/faiss/utils/distances.cpp +466 -43
- data/vendor/faiss/faiss/utils/distances.h +179 -2
- data/vendor/faiss/faiss/utils/distances_dispatch.h +6 -4
- data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +2 -5
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +0 -14
- data/vendor/faiss/faiss/utils/distances_fused/rvv.cpp +25 -0
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +0 -4
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based_neon.cpp +0 -4
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_kernel-inl.h +2 -1
- data/vendor/faiss/faiss/utils/distances_simd.cpp +9 -0
- data/vendor/faiss/faiss/utils/extra_distances.h +2 -1
- data/vendor/faiss/faiss/utils/fp16-fp16c.h +4 -0
- data/vendor/faiss/faiss/utils/fp16-inl.h +26 -52
- data/vendor/faiss/faiss/utils/hamming-inl.h +3 -0
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx2.cpp +0 -4
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx512.cpp +0 -4
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_avx512_vpopcnt.cpp +0 -4
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-avx512.h +33 -5
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-avx512_vpopcnt.h +15 -30
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_computer-neon.h +0 -4
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_impl.h +2 -1
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_neon.cpp +0 -4
- data/vendor/faiss/faiss/utils/hamming_distance/hamming_rvv.cpp +0 -4
- data/vendor/faiss/faiss/utils/partitioning.cpp +2 -2
- data/vendor/faiss/faiss/utils/pq_code_distance.h +8 -4
- data/vendor/faiss/faiss/utils/prefetch.h +1 -26
- data/vendor/faiss/faiss/utils/quantize_lut.cpp +26 -27
- data/vendor/faiss/faiss/utils/quantize_lut.h +11 -0
- data/vendor/faiss/faiss/utils/rabitq_simd.h +171 -22
- data/vendor/faiss/faiss/utils/simd_impl/distances_aarch64.cpp +9 -4
- data/vendor/faiss/faiss/utils/simd_impl/distances_arm_sve.cpp +81 -9
- data/vendor/faiss/faiss/utils/simd_impl/distances_autovec-inl.h +7 -3
- data/vendor/faiss/faiss/utils/simd_impl/distances_avx2.cpp +108 -9
- data/vendor/faiss/faiss/utils/simd_impl/distances_avx512.cpp +111 -12
- data/vendor/faiss/faiss/utils/simd_impl/distances_rvv.cpp +353 -71
- data/vendor/faiss/faiss/utils/simd_impl/distances_rvv_kernel.h +68 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_simdlib256.h +3 -3
- data/vendor/faiss/faiss/utils/simd_impl/exhaustive_L2sqr_blas_cmax.h +106 -0
- data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels.h +76 -0
- data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels_avx2.cpp +52 -0
- data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels_avx512.cpp +52 -0
- data/vendor/faiss/faiss/utils/simd_impl/fp16_kernels_neon.cpp +48 -0
- data/vendor/faiss/faiss/utils/simd_impl/masked_sum-avx2.h +44 -0
- data/vendor/faiss/faiss/utils/simd_impl/masked_sum-avx512.h +43 -0
- data/vendor/faiss/faiss/utils/simd_impl/masked_sum.h +38 -0
- data/vendor/faiss/faiss/utils/simd_impl/partitioning_avx2.cpp +0 -4
- data/vendor/faiss/faiss/utils/simd_impl/partitioning_neon.cpp +0 -4
- data/vendor/faiss/faiss/utils/simd_impl/partitioning_simdlib256.h +16 -15
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx2.cpp +185 -51
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx512.cpp +194 -66
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_avx512_vpopcnt.cpp +51 -14
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_neon.cpp +297 -10
- data/vendor/faiss/faiss/utils/simd_impl/rabitq_rvv.cpp +0 -4
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_avx2.cpp +0 -4
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_avx512.cpp +0 -4
- data/vendor/faiss/faiss/utils/simd_impl/super_kmeans_kernels_sve.cpp +0 -4
- data/vendor/faiss/faiss/utils/simd_levels.cpp +22 -6
- data/vendor/faiss/faiss/utils/simd_levels.h +74 -1
- data/vendor/faiss/faiss/utils/sorting.cpp +6 -5
- data/vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h +0 -4
- data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +0 -4
- data/vendor/faiss/faiss/utils/utils.cpp +84 -0
- data/vendor/faiss/faiss/utils/utils.h +24 -0
- metadata +52 -1
|
@@ -758,28 +758,29 @@ size_t fvec_L2sqr_ny_nearest_y_transposed<SIMDLevel::ARM_SVE>(
|
|
|
758
758
|
return current_min_idx;
|
|
759
759
|
}
|
|
760
760
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
761
|
+
namespace {
|
|
762
|
+
|
|
763
|
+
template <class QueryTiles>
|
|
764
|
+
void exhaustive_L2sqr_blas_cmax_sve(
|
|
765
|
+
QueryTiles& queries,
|
|
764
766
|
const float* y,
|
|
765
767
|
size_t d,
|
|
766
768
|
size_t nx,
|
|
767
769
|
size_t ny,
|
|
768
770
|
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
769
|
-
const float* y_norms
|
|
771
|
+
const float* y_norms,
|
|
772
|
+
size_t bs_x,
|
|
773
|
+
size_t bs_y) {
|
|
770
774
|
// BLAS does not like empty matrices
|
|
771
775
|
if (nx == 0 || ny == 0)
|
|
772
776
|
return;
|
|
773
777
|
|
|
774
|
-
/* block sizes */
|
|
775
|
-
const size_t bs_x = distance_compute_blas_query_bs;
|
|
776
|
-
const size_t bs_y = distance_compute_blas_database_bs;
|
|
777
778
|
// const size_t bs_x = 16, bs_y = 16;
|
|
778
779
|
std::unique_ptr<float[]> ip_block(new float[bs_x * bs_y]);
|
|
779
780
|
std::unique_ptr<float[]> x_norms(new float[nx]);
|
|
780
781
|
std::unique_ptr<float[]> del2;
|
|
781
782
|
|
|
782
|
-
|
|
783
|
+
queries.prepare_norms(nx, x_norms.get());
|
|
783
784
|
|
|
784
785
|
const size_t lanes = svcntw();
|
|
785
786
|
|
|
@@ -795,6 +796,8 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::ARM_SVE>(
|
|
|
795
796
|
if (i1 > nx)
|
|
796
797
|
i1 = nx;
|
|
797
798
|
|
|
799
|
+
const float* xt = queries.tile(i0, i1, x_norms.get());
|
|
800
|
+
|
|
798
801
|
res.begin_multiple(i0, i1);
|
|
799
802
|
|
|
800
803
|
for (size_t j0 = 0; j0 < ny; j0 += bs_y) {
|
|
@@ -813,7 +816,7 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::ARM_SVE>(
|
|
|
813
816
|
&one,
|
|
814
817
|
y + j0 * d,
|
|
815
818
|
&di,
|
|
816
|
-
|
|
819
|
+
xt,
|
|
817
820
|
&di,
|
|
818
821
|
&zero,
|
|
819
822
|
ip_block.get(),
|
|
@@ -938,4 +941,73 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::ARM_SVE>(
|
|
|
938
941
|
}
|
|
939
942
|
}
|
|
940
943
|
|
|
944
|
+
} // namespace
|
|
945
|
+
|
|
946
|
+
template <>
|
|
947
|
+
void exhaustive_L2sqr_blas_cmax<SIMDLevel::ARM_SVE>(
|
|
948
|
+
const float* x,
|
|
949
|
+
const float* y,
|
|
950
|
+
size_t d,
|
|
951
|
+
size_t nx,
|
|
952
|
+
size_t ny,
|
|
953
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
954
|
+
const float* y_norms,
|
|
955
|
+
size_t query_block_size,
|
|
956
|
+
size_t database_block_size) {
|
|
957
|
+
Fp32QueryTiles queries{x, d};
|
|
958
|
+
exhaustive_L2sqr_blas_cmax_sve(
|
|
959
|
+
queries,
|
|
960
|
+
y,
|
|
961
|
+
d,
|
|
962
|
+
nx,
|
|
963
|
+
ny,
|
|
964
|
+
res,
|
|
965
|
+
y_norms,
|
|
966
|
+
query_block_size,
|
|
967
|
+
database_block_size);
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
template <>
|
|
971
|
+
void exhaustive_L2sqr_blas_cmax<SIMDLevel::ARM_SVE>(
|
|
972
|
+
const float* x,
|
|
973
|
+
const float* y,
|
|
974
|
+
size_t d,
|
|
975
|
+
size_t nx,
|
|
976
|
+
size_t ny,
|
|
977
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
978
|
+
const float* y_norms) {
|
|
979
|
+
exhaustive_L2sqr_blas_cmax<SIMDLevel::ARM_SVE>(
|
|
980
|
+
x,
|
|
981
|
+
y,
|
|
982
|
+
d,
|
|
983
|
+
nx,
|
|
984
|
+
ny,
|
|
985
|
+
res,
|
|
986
|
+
y_norms,
|
|
987
|
+
distance_compute_blas_query_bs,
|
|
988
|
+
distance_compute_blas_database_bs);
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
template <>
|
|
992
|
+
void exhaustive_L2sqr_blas_cmax_fp16<SIMDLevel::ARM_SVE>(
|
|
993
|
+
const uint16_t* x,
|
|
994
|
+
const float* y,
|
|
995
|
+
size_t d,
|
|
996
|
+
size_t nx,
|
|
997
|
+
size_t ny,
|
|
998
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
999
|
+
const float* y_norms) {
|
|
1000
|
+
Fp16QueryTiles queries(x, d, nx);
|
|
1001
|
+
exhaustive_L2sqr_blas_cmax_sve(
|
|
1002
|
+
queries,
|
|
1003
|
+
y,
|
|
1004
|
+
d,
|
|
1005
|
+
nx,
|
|
1006
|
+
ny,
|
|
1007
|
+
res,
|
|
1008
|
+
y_norms,
|
|
1009
|
+
distance_compute_blas_query_bs,
|
|
1010
|
+
distance_compute_blas_database_bs);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
941
1013
|
} // namespace faiss
|
|
@@ -208,7 +208,10 @@ float VectorDistance<METRIC_Canberra, SL>::operator()(
|
|
|
208
208
|
float accu = 0;
|
|
209
209
|
for (size_t i = 0; i < this->d; i++) {
|
|
210
210
|
float xi = x[i], yi = y[i];
|
|
211
|
-
|
|
211
|
+
float denominator = fabs(xi) + fabs(yi);
|
|
212
|
+
if (denominator != 0.0f) {
|
|
213
|
+
accu += fabs(xi - yi) / denominator;
|
|
214
|
+
}
|
|
212
215
|
}
|
|
213
216
|
return accu;
|
|
214
217
|
}
|
|
@@ -230,12 +233,13 @@ template <>
|
|
|
230
233
|
float VectorDistance<METRIC_JensenShannon, SL>::operator()(
|
|
231
234
|
const float* x,
|
|
232
235
|
const float* y) const {
|
|
236
|
+
constexpr float kLn2 = 0.6931471805599453f;
|
|
233
237
|
float accu = 0;
|
|
234
238
|
for (size_t i = 0; i < this->d; i++) {
|
|
235
239
|
float xi = x[i], yi = y[i];
|
|
236
240
|
float mi = 0.5 * (xi + yi);
|
|
237
|
-
float kl1 = -xi * log(mi / xi);
|
|
238
|
-
float kl2 = -yi * log(mi / yi);
|
|
241
|
+
float kl1 = xi > 0 ? (yi == 0 ? xi * kLn2 : -xi * log(mi / xi)) : 0.0f;
|
|
242
|
+
float kl2 = yi > 0 ? (xi == 0 ? yi * kLn2 : -yi * log(mi / yi)) : 0.0f;
|
|
239
243
|
accu += kl1 + kl2;
|
|
240
244
|
}
|
|
241
245
|
return 0.5 * accu;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#include <faiss/utils/distances.h>
|
|
9
|
+
#include <faiss/utils/simd_impl/masked_sum-avx2.h>
|
|
9
10
|
|
|
10
11
|
#include <immintrin.h>
|
|
11
12
|
|
|
@@ -105,6 +106,19 @@ void fvec_madd<SIMDLevel::AVX2>(
|
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
template <>
|
|
110
|
+
float fvec_masked_sum<SIMDLevel::AVX2>(
|
|
111
|
+
const float* x,
|
|
112
|
+
const uint8_t* bits,
|
|
113
|
+
size_t d) {
|
|
114
|
+
return masked_sum<SIMDLevel::AVX2>(x, bits, d);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Internal linkage: the same template is compiled with other -m flags in
|
|
118
|
+
// the other per-SIMD distances TU, and a shared symbol would let the linker
|
|
119
|
+
// hand one level the other's code.
|
|
120
|
+
namespace {
|
|
121
|
+
|
|
108
122
|
template <size_t DIM>
|
|
109
123
|
void fvec_L2sqr_ny_y_transposed_D(
|
|
110
124
|
float* distances,
|
|
@@ -181,6 +195,8 @@ void fvec_L2sqr_ny_y_transposed_D(
|
|
|
181
195
|
}
|
|
182
196
|
}
|
|
183
197
|
|
|
198
|
+
} // namespace
|
|
199
|
+
|
|
184
200
|
template <>
|
|
185
201
|
void fvec_L2sqr_ny_transposed<SIMDLevel::AVX2>(
|
|
186
202
|
float* dis,
|
|
@@ -199,8 +215,12 @@ void fvec_L2sqr_ny_transposed<SIMDLevel::AVX2>(
|
|
|
199
215
|
switch (d) {
|
|
200
216
|
DISPATCH(1)
|
|
201
217
|
DISPATCH(2)
|
|
218
|
+
DISPATCH(3)
|
|
202
219
|
DISPATCH(4)
|
|
220
|
+
DISPATCH(6)
|
|
203
221
|
DISPATCH(8)
|
|
222
|
+
DISPATCH(12)
|
|
223
|
+
DISPATCH(16)
|
|
204
224
|
default:
|
|
205
225
|
return fvec_L2sqr_ny_transposed<SIMDLevel::NONE>(
|
|
206
226
|
dis, x, y, y_sqlen, d, d_offset, ny);
|
|
@@ -1060,6 +1080,11 @@ size_t fvec_L2sqr_ny_nearest<SIMDLevel::AVX2>(
|
|
|
1060
1080
|
&fvec_L2sqr_ny_nearest_D8<SIMDLevel::AVX2>);
|
|
1061
1081
|
}
|
|
1062
1082
|
|
|
1083
|
+
// Internal linkage: the same template is compiled with other -m flags in
|
|
1084
|
+
// the other per-SIMD distances TU, and a shared symbol would let the linker
|
|
1085
|
+
// hand one level the other's code.
|
|
1086
|
+
namespace {
|
|
1087
|
+
|
|
1063
1088
|
template <size_t DIM>
|
|
1064
1089
|
size_t fvec_L2sqr_ny_nearest_y_transposed_D(
|
|
1065
1090
|
float* /*distances_tmp_buffer*/,
|
|
@@ -1176,6 +1201,8 @@ size_t fvec_L2sqr_ny_nearest_y_transposed_D(
|
|
|
1176
1201
|
return current_min_index;
|
|
1177
1202
|
}
|
|
1178
1203
|
|
|
1204
|
+
} // namespace
|
|
1205
|
+
|
|
1179
1206
|
template <>
|
|
1180
1207
|
size_t fvec_L2sqr_ny_nearest_y_transposed<SIMDLevel::AVX2>(
|
|
1181
1208
|
float* distances_tmp_buffer,
|
|
@@ -1213,29 +1240,30 @@ int fvec_madd_and_argmin<SIMDLevel::AVX2>(
|
|
|
1213
1240
|
return fvec_madd_and_argmin_sse(n, a, bf, b, c);
|
|
1214
1241
|
}
|
|
1215
1242
|
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1243
|
+
namespace {
|
|
1244
|
+
|
|
1245
|
+
template <class QueryTiles>
|
|
1246
|
+
void exhaustive_L2sqr_blas_cmax_avx2(
|
|
1247
|
+
QueryTiles& queries,
|
|
1219
1248
|
const float* y,
|
|
1220
1249
|
size_t d,
|
|
1221
1250
|
size_t nx,
|
|
1222
1251
|
size_t ny,
|
|
1223
1252
|
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1224
|
-
const float* y_norms
|
|
1253
|
+
const float* y_norms,
|
|
1254
|
+
size_t bs_x,
|
|
1255
|
+
size_t bs_y) {
|
|
1225
1256
|
// BLAS does not like empty matrices
|
|
1226
1257
|
if (nx == 0 || ny == 0) {
|
|
1227
1258
|
return;
|
|
1228
1259
|
}
|
|
1229
1260
|
|
|
1230
|
-
/* block sizes */
|
|
1231
|
-
const size_t bs_x = distance_compute_blas_query_bs;
|
|
1232
|
-
const size_t bs_y = distance_compute_blas_database_bs;
|
|
1233
1261
|
// const size_t bs_x = 16, bs_y = 16;
|
|
1234
1262
|
std::unique_ptr<float[]> ip_block(new float[bs_x * bs_y]);
|
|
1235
1263
|
std::unique_ptr<float[]> x_norms(new float[nx]);
|
|
1236
1264
|
std::unique_ptr<float[]> del2;
|
|
1237
1265
|
|
|
1238
|
-
|
|
1266
|
+
queries.prepare_norms(nx, x_norms.get());
|
|
1239
1267
|
|
|
1240
1268
|
if (!y_norms) {
|
|
1241
1269
|
float* y_norms2 = new float[ny];
|
|
@@ -1250,6 +1278,8 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX2>(
|
|
|
1250
1278
|
i1 = nx;
|
|
1251
1279
|
}
|
|
1252
1280
|
|
|
1281
|
+
const float* xt = queries.tile(i0, i1, x_norms.get());
|
|
1282
|
+
|
|
1253
1283
|
res.begin_multiple(i0, i1);
|
|
1254
1284
|
|
|
1255
1285
|
for (size_t j0 = 0; j0 < ny; j0 += bs_y) {
|
|
@@ -1269,7 +1299,7 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX2>(
|
|
|
1269
1299
|
&one,
|
|
1270
1300
|
y + j0 * d,
|
|
1271
1301
|
&di,
|
|
1272
|
-
|
|
1302
|
+
xt,
|
|
1273
1303
|
&di,
|
|
1274
1304
|
&zero,
|
|
1275
1305
|
ip_block.get(),
|
|
@@ -1427,4 +1457,73 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX2>(
|
|
|
1427
1457
|
}
|
|
1428
1458
|
}
|
|
1429
1459
|
|
|
1460
|
+
} // namespace
|
|
1461
|
+
|
|
1462
|
+
template <>
|
|
1463
|
+
void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX2>(
|
|
1464
|
+
const float* x,
|
|
1465
|
+
const float* y,
|
|
1466
|
+
size_t d,
|
|
1467
|
+
size_t nx,
|
|
1468
|
+
size_t ny,
|
|
1469
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1470
|
+
const float* y_norms,
|
|
1471
|
+
size_t query_block_size,
|
|
1472
|
+
size_t database_block_size) {
|
|
1473
|
+
Fp32QueryTiles queries{x, d};
|
|
1474
|
+
exhaustive_L2sqr_blas_cmax_avx2(
|
|
1475
|
+
queries,
|
|
1476
|
+
y,
|
|
1477
|
+
d,
|
|
1478
|
+
nx,
|
|
1479
|
+
ny,
|
|
1480
|
+
res,
|
|
1481
|
+
y_norms,
|
|
1482
|
+
query_block_size,
|
|
1483
|
+
database_block_size);
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
template <>
|
|
1487
|
+
void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX2>(
|
|
1488
|
+
const float* x,
|
|
1489
|
+
const float* y,
|
|
1490
|
+
size_t d,
|
|
1491
|
+
size_t nx,
|
|
1492
|
+
size_t ny,
|
|
1493
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1494
|
+
const float* y_norms) {
|
|
1495
|
+
exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX2>(
|
|
1496
|
+
x,
|
|
1497
|
+
y,
|
|
1498
|
+
d,
|
|
1499
|
+
nx,
|
|
1500
|
+
ny,
|
|
1501
|
+
res,
|
|
1502
|
+
y_norms,
|
|
1503
|
+
distance_compute_blas_query_bs,
|
|
1504
|
+
distance_compute_blas_database_bs);
|
|
1505
|
+
}
|
|
1506
|
+
|
|
1507
|
+
template <>
|
|
1508
|
+
void exhaustive_L2sqr_blas_cmax_fp16<SIMDLevel::AVX2>(
|
|
1509
|
+
const uint16_t* x,
|
|
1510
|
+
const float* y,
|
|
1511
|
+
size_t d,
|
|
1512
|
+
size_t nx,
|
|
1513
|
+
size_t ny,
|
|
1514
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1515
|
+
const float* y_norms) {
|
|
1516
|
+
Fp16QueryTiles queries(x, d, nx);
|
|
1517
|
+
exhaustive_L2sqr_blas_cmax_avx2(
|
|
1518
|
+
queries,
|
|
1519
|
+
y,
|
|
1520
|
+
d,
|
|
1521
|
+
nx,
|
|
1522
|
+
ny,
|
|
1523
|
+
res,
|
|
1524
|
+
y_norms,
|
|
1525
|
+
distance_compute_blas_query_bs,
|
|
1526
|
+
distance_compute_blas_database_bs);
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1430
1529
|
} // namespace faiss
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
#include <faiss/utils/distances.h>
|
|
9
|
+
#include <faiss/utils/simd_impl/masked_sum-avx512.h>
|
|
9
10
|
|
|
10
11
|
#include <immintrin.h>
|
|
11
12
|
|
|
@@ -78,6 +79,19 @@ void fvec_madd<SIMDLevel::AVX512>(
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
template <>
|
|
83
|
+
float fvec_masked_sum<SIMDLevel::AVX512>(
|
|
84
|
+
const float* x,
|
|
85
|
+
const uint8_t* bits,
|
|
86
|
+
size_t d) {
|
|
87
|
+
return masked_sum<SIMDLevel::AVX512>(x, bits, d);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Internal linkage: the same template is compiled with other -m flags in
|
|
91
|
+
// the other per-SIMD distances TU, and a shared symbol would let the linker
|
|
92
|
+
// hand one level the other's code.
|
|
93
|
+
namespace {
|
|
94
|
+
|
|
81
95
|
template <size_t DIM>
|
|
82
96
|
void fvec_L2sqr_ny_y_transposed_D(
|
|
83
97
|
float* distances,
|
|
@@ -151,6 +165,8 @@ void fvec_L2sqr_ny_y_transposed_D(
|
|
|
151
165
|
}
|
|
152
166
|
}
|
|
153
167
|
|
|
168
|
+
} // namespace
|
|
169
|
+
|
|
154
170
|
template <>
|
|
155
171
|
void fvec_L2sqr_ny_transposed<SIMDLevel::AVX512>(
|
|
156
172
|
float* dis,
|
|
@@ -169,8 +185,12 @@ void fvec_L2sqr_ny_transposed<SIMDLevel::AVX512>(
|
|
|
169
185
|
switch (d) {
|
|
170
186
|
DISPATCH(1)
|
|
171
187
|
DISPATCH(2)
|
|
188
|
+
DISPATCH(3)
|
|
172
189
|
DISPATCH(4)
|
|
190
|
+
DISPATCH(6)
|
|
173
191
|
DISPATCH(8)
|
|
192
|
+
DISPATCH(12)
|
|
193
|
+
DISPATCH(16)
|
|
174
194
|
default:
|
|
175
195
|
return fvec_L2sqr_ny_transposed<SIMDLevel::NONE>(
|
|
176
196
|
dis, x, y, y_sqlen, d, d_offset, ny);
|
|
@@ -657,7 +677,7 @@ void fvec_L2sqr_ny<SIMDLevel::AVX512>(
|
|
|
657
677
|
|
|
658
678
|
template <>
|
|
659
679
|
size_t fvec_L2sqr_ny_nearest_D2<SIMDLevel::AVX512>(
|
|
660
|
-
float* distances_tmp_buffer
|
|
680
|
+
float* /*distances_tmp_buffer*/,
|
|
661
681
|
const float* x,
|
|
662
682
|
const float* y,
|
|
663
683
|
size_t ny) {
|
|
@@ -749,7 +769,7 @@ size_t fvec_L2sqr_ny_nearest_D2<SIMDLevel::AVX512>(
|
|
|
749
769
|
|
|
750
770
|
template <>
|
|
751
771
|
size_t fvec_L2sqr_ny_nearest_D4<SIMDLevel::AVX512>(
|
|
752
|
-
float* distances_tmp_buffer
|
|
772
|
+
float* /*distances_tmp_buffer*/,
|
|
753
773
|
const float* x,
|
|
754
774
|
const float* y,
|
|
755
775
|
size_t ny) {
|
|
@@ -846,7 +866,7 @@ size_t fvec_L2sqr_ny_nearest_D4<SIMDLevel::AVX512>(
|
|
|
846
866
|
|
|
847
867
|
template <>
|
|
848
868
|
size_t fvec_L2sqr_ny_nearest_D8<SIMDLevel::AVX512>(
|
|
849
|
-
float* distances_tmp_buffer
|
|
869
|
+
float* /*distances_tmp_buffer*/,
|
|
850
870
|
const float* x,
|
|
851
871
|
const float* y,
|
|
852
872
|
size_t ny) {
|
|
@@ -983,6 +1003,11 @@ size_t fvec_L2sqr_ny_nearest<SIMDLevel::AVX512>(
|
|
|
983
1003
|
&fvec_L2sqr_ny_nearest_D8<SIMDLevel::AVX512>);
|
|
984
1004
|
}
|
|
985
1005
|
|
|
1006
|
+
// Internal linkage: the same template is compiled with other -m flags in
|
|
1007
|
+
// the other per-SIMD distances TU, and a shared symbol would let the linker
|
|
1008
|
+
// hand one level the other's code.
|
|
1009
|
+
namespace {
|
|
1010
|
+
|
|
986
1011
|
template <size_t DIM>
|
|
987
1012
|
size_t fvec_L2sqr_ny_nearest_y_transposed_D(
|
|
988
1013
|
float* /* distances_tmp_buffer */,
|
|
@@ -1096,6 +1121,8 @@ size_t fvec_L2sqr_ny_nearest_y_transposed_D(
|
|
|
1096
1121
|
return current_min_index;
|
|
1097
1122
|
}
|
|
1098
1123
|
|
|
1124
|
+
} // namespace
|
|
1125
|
+
|
|
1099
1126
|
template <>
|
|
1100
1127
|
size_t fvec_L2sqr_ny_nearest_y_transposed<SIMDLevel::AVX512>(
|
|
1101
1128
|
float* distances_tmp_buffer,
|
|
@@ -1133,28 +1160,29 @@ int fvec_madd_and_argmin<SIMDLevel::AVX512>(
|
|
|
1133
1160
|
return fvec_madd_and_argmin_sse(n, a, bf, b, c);
|
|
1134
1161
|
}
|
|
1135
1162
|
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1163
|
+
namespace {
|
|
1164
|
+
|
|
1165
|
+
template <class QueryTiles>
|
|
1166
|
+
void exhaustive_L2sqr_blas_cmax_avx512(
|
|
1167
|
+
QueryTiles& queries,
|
|
1139
1168
|
const float* y,
|
|
1140
1169
|
size_t d,
|
|
1141
1170
|
size_t nx,
|
|
1142
1171
|
size_t ny,
|
|
1143
1172
|
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1144
|
-
const float* y_norms
|
|
1173
|
+
const float* y_norms,
|
|
1174
|
+
size_t bs_x,
|
|
1175
|
+
size_t bs_y) {
|
|
1145
1176
|
// BLAS does not like empty matrices
|
|
1146
1177
|
if (nx == 0 || ny == 0) {
|
|
1147
1178
|
return;
|
|
1148
1179
|
}
|
|
1149
1180
|
|
|
1150
|
-
/* block sizes */
|
|
1151
|
-
const size_t bs_x = distance_compute_blas_query_bs;
|
|
1152
|
-
const size_t bs_y = distance_compute_blas_database_bs;
|
|
1153
1181
|
std::unique_ptr<float[]> ip_block(new float[bs_x * bs_y]);
|
|
1154
1182
|
std::unique_ptr<float[]> x_norms(new float[nx]);
|
|
1155
1183
|
std::unique_ptr<float[]> del2;
|
|
1156
1184
|
|
|
1157
|
-
|
|
1185
|
+
queries.prepare_norms(nx, x_norms.get());
|
|
1158
1186
|
|
|
1159
1187
|
if (!y_norms) {
|
|
1160
1188
|
float* y_norms2 = new float[ny];
|
|
@@ -1169,6 +1197,8 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX512>(
|
|
|
1169
1197
|
i1 = nx;
|
|
1170
1198
|
}
|
|
1171
1199
|
|
|
1200
|
+
const float* xt = queries.tile(i0, i1, x_norms.get());
|
|
1201
|
+
|
|
1172
1202
|
res.begin_multiple(i0, i1);
|
|
1173
1203
|
|
|
1174
1204
|
for (size_t j0 = 0; j0 < ny; j0 += bs_y) {
|
|
@@ -1188,7 +1218,7 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX512>(
|
|
|
1188
1218
|
&one,
|
|
1189
1219
|
y + j0 * d,
|
|
1190
1220
|
&di,
|
|
1191
|
-
|
|
1221
|
+
xt,
|
|
1192
1222
|
&di,
|
|
1193
1223
|
&zero,
|
|
1194
1224
|
ip_block.get(),
|
|
@@ -1340,4 +1370,73 @@ void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX512>(
|
|
|
1340
1370
|
}
|
|
1341
1371
|
}
|
|
1342
1372
|
|
|
1373
|
+
} // namespace
|
|
1374
|
+
|
|
1375
|
+
template <>
|
|
1376
|
+
void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX512>(
|
|
1377
|
+
const float* x,
|
|
1378
|
+
const float* y,
|
|
1379
|
+
size_t d,
|
|
1380
|
+
size_t nx,
|
|
1381
|
+
size_t ny,
|
|
1382
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1383
|
+
const float* y_norms,
|
|
1384
|
+
size_t query_block_size,
|
|
1385
|
+
size_t database_block_size) {
|
|
1386
|
+
Fp32QueryTiles queries{x, d};
|
|
1387
|
+
exhaustive_L2sqr_blas_cmax_avx512(
|
|
1388
|
+
queries,
|
|
1389
|
+
y,
|
|
1390
|
+
d,
|
|
1391
|
+
nx,
|
|
1392
|
+
ny,
|
|
1393
|
+
res,
|
|
1394
|
+
y_norms,
|
|
1395
|
+
query_block_size,
|
|
1396
|
+
database_block_size);
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
template <>
|
|
1400
|
+
void exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX512>(
|
|
1401
|
+
const float* x,
|
|
1402
|
+
const float* y,
|
|
1403
|
+
size_t d,
|
|
1404
|
+
size_t nx,
|
|
1405
|
+
size_t ny,
|
|
1406
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1407
|
+
const float* y_norms) {
|
|
1408
|
+
exhaustive_L2sqr_blas_cmax<SIMDLevel::AVX512>(
|
|
1409
|
+
x,
|
|
1410
|
+
y,
|
|
1411
|
+
d,
|
|
1412
|
+
nx,
|
|
1413
|
+
ny,
|
|
1414
|
+
res,
|
|
1415
|
+
y_norms,
|
|
1416
|
+
distance_compute_blas_query_bs,
|
|
1417
|
+
distance_compute_blas_database_bs);
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
template <>
|
|
1421
|
+
void exhaustive_L2sqr_blas_cmax_fp16<SIMDLevel::AVX512>(
|
|
1422
|
+
const uint16_t* x,
|
|
1423
|
+
const float* y,
|
|
1424
|
+
size_t d,
|
|
1425
|
+
size_t nx,
|
|
1426
|
+
size_t ny,
|
|
1427
|
+
Top1BlockResultHandler<CMax<float, int64_t>>& res,
|
|
1428
|
+
const float* y_norms) {
|
|
1429
|
+
Fp16QueryTiles queries(x, d, nx);
|
|
1430
|
+
exhaustive_L2sqr_blas_cmax_avx512(
|
|
1431
|
+
queries,
|
|
1432
|
+
y,
|
|
1433
|
+
d,
|
|
1434
|
+
nx,
|
|
1435
|
+
ny,
|
|
1436
|
+
res,
|
|
1437
|
+
y_norms,
|
|
1438
|
+
distance_compute_blas_query_bs,
|
|
1439
|
+
distance_compute_blas_database_bs);
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1343
1442
|
} // namespace faiss
|