faiss 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +2 -2
- data/vendor/faiss/faiss/AutoTune.h +3 -3
- data/vendor/faiss/faiss/Clustering.cpp +37 -6
- data/vendor/faiss/faiss/Clustering.h +12 -3
- data/vendor/faiss/faiss/IVFlib.cpp +6 -3
- data/vendor/faiss/faiss/IVFlib.h +2 -2
- data/vendor/faiss/faiss/Index.cpp +6 -2
- data/vendor/faiss/faiss/Index.h +30 -8
- data/vendor/faiss/faiss/Index2Layer.cpp +2 -2
- data/vendor/faiss/faiss/Index2Layer.h +2 -2
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +7 -7
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +14 -16
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +2 -2
- data/vendor/faiss/faiss/IndexBinary.cpp +13 -2
- data/vendor/faiss/faiss/IndexBinary.h +8 -2
- data/vendor/faiss/faiss/IndexBinaryFlat.cpp +2 -3
- data/vendor/faiss/faiss/IndexBinaryFlat.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +2 -2
- data/vendor/faiss/faiss/IndexBinaryFromFloat.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +2 -7
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +3 -3
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +2 -3
- data/vendor/faiss/faiss/IndexBinaryHash.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +3 -3
- data/vendor/faiss/faiss/IndexBinaryIVF.h +2 -2
- data/vendor/faiss/faiss/IndexFastScan.cpp +32 -18
- data/vendor/faiss/faiss/IndexFastScan.h +11 -2
- data/vendor/faiss/faiss/IndexFlat.cpp +13 -10
- data/vendor/faiss/faiss/IndexFlat.h +2 -2
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +170 -7
- data/vendor/faiss/faiss/IndexFlatCodes.h +25 -5
- data/vendor/faiss/faiss/IndexHNSW.cpp +156 -96
- data/vendor/faiss/faiss/IndexHNSW.h +54 -5
- data/vendor/faiss/faiss/IndexIDMap.cpp +19 -3
- data/vendor/faiss/faiss/IndexIDMap.h +5 -2
- data/vendor/faiss/faiss/IndexIVF.cpp +5 -6
- data/vendor/faiss/faiss/IndexIVF.h +13 -4
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +21 -7
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +5 -2
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +3 -14
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +2 -4
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +201 -91
- data/vendor/faiss/faiss/IndexIVFFastScan.h +33 -9
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +2 -2
- data/vendor/faiss/faiss/IndexIVFFlat.h +2 -2
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/IndexIVFIndependentQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +3 -6
- data/vendor/faiss/faiss/IndexIVFPQ.h +2 -2
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +7 -14
- data/vendor/faiss/faiss/IndexIVFPQFastScan.h +2 -4
- data/vendor/faiss/faiss/IndexIVFPQR.cpp +2 -2
- data/vendor/faiss/faiss/IndexIVFPQR.h +2 -2
- data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +2 -3
- data/vendor/faiss/faiss/IndexIVFSpectralHash.h +2 -2
- data/vendor/faiss/faiss/IndexLSH.cpp +2 -3
- data/vendor/faiss/faiss/IndexLSH.h +2 -2
- data/vendor/faiss/faiss/IndexLattice.cpp +3 -21
- data/vendor/faiss/faiss/IndexLattice.h +5 -24
- data/vendor/faiss/faiss/IndexNNDescent.cpp +2 -31
- data/vendor/faiss/faiss/IndexNNDescent.h +3 -3
- data/vendor/faiss/faiss/IndexNSG.cpp +2 -5
- data/vendor/faiss/faiss/IndexNSG.h +3 -3
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +56 -0
- data/vendor/faiss/faiss/IndexNeuralNetCodec.h +49 -0
- data/vendor/faiss/faiss/IndexPQ.cpp +26 -26
- data/vendor/faiss/faiss/IndexPQ.h +2 -2
- data/vendor/faiss/faiss/IndexPQFastScan.cpp +2 -5
- data/vendor/faiss/faiss/IndexPQFastScan.h +2 -11
- data/vendor/faiss/faiss/IndexPreTransform.cpp +2 -2
- data/vendor/faiss/faiss/IndexPreTransform.h +3 -3
- data/vendor/faiss/faiss/IndexRefine.cpp +46 -9
- data/vendor/faiss/faiss/IndexRefine.h +9 -2
- data/vendor/faiss/faiss/IndexReplicas.cpp +2 -2
- data/vendor/faiss/faiss/IndexReplicas.h +2 -2
- data/vendor/faiss/faiss/IndexRowwiseMinMax.cpp +2 -2
- data/vendor/faiss/faiss/IndexRowwiseMinMax.h +2 -2
- data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +5 -4
- data/vendor/faiss/faiss/IndexScalarQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexShards.cpp +2 -2
- data/vendor/faiss/faiss/IndexShards.h +2 -2
- data/vendor/faiss/faiss/IndexShardsIVF.cpp +2 -2
- data/vendor/faiss/faiss/IndexShardsIVF.h +2 -2
- data/vendor/faiss/faiss/MatrixStats.cpp +2 -2
- data/vendor/faiss/faiss/MatrixStats.h +2 -2
- data/vendor/faiss/faiss/MetaIndexes.cpp +2 -3
- data/vendor/faiss/faiss/MetaIndexes.h +2 -2
- data/vendor/faiss/faiss/MetricType.h +9 -4
- data/vendor/faiss/faiss/VectorTransform.cpp +2 -2
- data/vendor/faiss/faiss/VectorTransform.h +2 -2
- data/vendor/faiss/faiss/clone_index.cpp +2 -2
- data/vendor/faiss/faiss/clone_index.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +97 -19
- data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +192 -0
- data/vendor/faiss/faiss/cppcontrib/factory_tools.h +29 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +85 -32
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMax-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMaxFP16-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-neon-inl.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuAutoTune.cpp +2 -5
- data/vendor/faiss/faiss/gpu/GpuAutoTune.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +45 -13
- data/vendor/faiss/faiss/gpu/GpuCloner.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +12 -6
- data/vendor/faiss/faiss/gpu/GpuDistance.h +11 -7
- data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +3 -3
- data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndex.h +10 -15
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +285 -0
- data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +8 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +4 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h +3 -3
- data/vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndicesOptions.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuResources.cpp +7 -2
- data/vendor/faiss/faiss/gpu/GpuResources.h +11 -4
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +66 -11
- data/vendor/faiss/faiss/gpu/StandardGpuResources.h +15 -5
- data/vendor/faiss/faiss/gpu/impl/IndexUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp +28 -23
- data/vendor/faiss/faiss/gpu/impl/InterleavedCodes.h +2 -2
- data/vendor/faiss/faiss/gpu/impl/RemapIndices.cpp +2 -2
- data/vendor/faiss/faiss/gpu/impl/RemapIndices.h +2 -2
- data/vendor/faiss/faiss/gpu/perf/IndexWrapper-inl.h +2 -2
- data/vendor/faiss/faiss/gpu/perf/IndexWrapper.h +2 -2
- data/vendor/faiss/faiss/gpu/perf/PerfClustering.cpp +8 -2
- data/vendor/faiss/faiss/gpu/perf/PerfIVFPQAdd.cpp +2 -3
- data/vendor/faiss/faiss/gpu/perf/WriteIndex.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestCodePacking.cpp +10 -7
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +54 -54
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +144 -77
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFPQ.cpp +51 -51
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFScalarQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/gpu/test/TestGpuMemoryException.cpp +3 -3
- data/vendor/faiss/faiss/gpu/test/TestGpuResidualQuantizer.cpp +70 -0
- data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +74 -4
- data/vendor/faiss/faiss/gpu/test/TestUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +3 -3
- data/vendor/faiss/faiss/gpu/utils/{RaftUtils.h → CuvsUtils.h} +12 -11
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +8 -2
- data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.cpp +2 -2
- data/vendor/faiss/faiss/gpu/utils/StackDeviceMemory.h +2 -2
- data/vendor/faiss/faiss/gpu/utils/StaticUtils.h +2 -2
- data/vendor/faiss/faiss/gpu/utils/Timer.cpp +6 -3
- data/vendor/faiss/faiss/gpu/utils/Timer.h +3 -3
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +79 -11
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +17 -5
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +27 -2
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +11 -3
- data/vendor/faiss/faiss/impl/CodePacker.cpp +2 -2
- data/vendor/faiss/faiss/impl/CodePacker.h +2 -2
- data/vendor/faiss/faiss/impl/DistanceComputer.h +48 -2
- data/vendor/faiss/faiss/impl/FaissAssert.h +6 -4
- data/vendor/faiss/faiss/impl/FaissException.cpp +2 -2
- data/vendor/faiss/faiss/impl/FaissException.h +2 -3
- data/vendor/faiss/faiss/impl/HNSW.cpp +378 -205
- data/vendor/faiss/faiss/impl/HNSW.h +55 -24
- data/vendor/faiss/faiss/impl/IDSelector.cpp +2 -2
- data/vendor/faiss/faiss/impl/IDSelector.h +2 -2
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +10 -10
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +36 -2
- data/vendor/faiss/faiss/impl/NNDescent.cpp +15 -10
- data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
- data/vendor/faiss/faiss/impl/NSG.cpp +26 -49
- data/vendor/faiss/faiss/impl/NSG.h +20 -8
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +2 -2
- data/vendor/faiss/faiss/impl/PolysemousTraining.h +2 -2
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +2 -4
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer-inl.h +2 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +3 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +7 -3
- data/vendor/faiss/faiss/impl/Quantizer.h +2 -2
- data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +2 -36
- data/vendor/faiss/faiss/impl/ResidualQuantizer.h +3 -13
- data/vendor/faiss/faiss/impl/ResultHandler.h +153 -34
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +721 -104
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +5 -2
- data/vendor/faiss/faiss/impl/ThreadedIndex-inl.h +2 -2
- data/vendor/faiss/faiss/impl/ThreadedIndex.h +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx2.h +7 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +248 -0
- data/vendor/faiss/faiss/impl/code_distance/code_distance-generic.h +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-sve.h +440 -0
- data/vendor/faiss/faiss/impl/code_distance/code_distance.h +55 -2
- data/vendor/faiss/faiss/impl/index_read.cpp +31 -20
- data/vendor/faiss/faiss/impl/index_read_utils.h +37 -0
- data/vendor/faiss/faiss/impl/index_write.cpp +30 -16
- data/vendor/faiss/faiss/impl/io.cpp +15 -7
- data/vendor/faiss/faiss/impl/io.h +6 -6
- data/vendor/faiss/faiss/impl/io_macros.h +8 -9
- data/vendor/faiss/faiss/impl/kmeans1d.cpp +2 -3
- data/vendor/faiss/faiss/impl/kmeans1d.h +2 -2
- data/vendor/faiss/faiss/impl/lattice_Zn.cpp +2 -3
- data/vendor/faiss/faiss/impl/lattice_Zn.h +2 -2
- data/vendor/faiss/faiss/impl/platform_macros.h +34 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +13 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +20 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +3 -3
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +450 -3
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +8 -8
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +3 -3
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +151 -67
- data/vendor/faiss/faiss/index_factory.cpp +51 -34
- data/vendor/faiss/faiss/index_factory.h +2 -2
- data/vendor/faiss/faiss/index_io.h +14 -7
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +30 -10
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +5 -2
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +11 -3
- data/vendor/faiss/faiss/invlists/DirectMap.h +2 -2
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +57 -19
- data/vendor/faiss/faiss/invlists/InvertedLists.h +20 -11
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.cpp +2 -2
- data/vendor/faiss/faiss/invlists/InvertedListsIOHook.h +2 -2
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +23 -9
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +4 -3
- data/vendor/faiss/faiss/python/python_callbacks.cpp +5 -5
- data/vendor/faiss/faiss/python/python_callbacks.h +2 -2
- data/vendor/faiss/faiss/utils/AlignedTable.h +5 -3
- data/vendor/faiss/faiss/utils/Heap.cpp +2 -2
- data/vendor/faiss/faiss/utils/Heap.h +107 -2
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +346 -0
- data/vendor/faiss/faiss/utils/NeuralNet.h +147 -0
- data/vendor/faiss/faiss/utils/WorkerThread.cpp +2 -2
- data/vendor/faiss/faiss/utils/WorkerThread.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/approx_topk.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/avx2-inl.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/generic.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk/mode.h +2 -2
- data/vendor/faiss/faiss/utils/approx_topk_hamming/approx_topk_hamming.h +2 -2
- data/vendor/faiss/faiss/utils/bf16.h +36 -0
- data/vendor/faiss/faiss/utils/distances.cpp +249 -90
- data/vendor/faiss/faiss/utils/distances.h +8 -8
- data/vendor/faiss/faiss/utils/distances_fused/avx512.cpp +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/avx512.h +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.cpp +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/distances_fused.h +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.cpp +2 -2
- data/vendor/faiss/faiss/utils/distances_fused/simdlib_based.h +2 -2
- data/vendor/faiss/faiss/utils/distances_simd.cpp +1543 -56
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +72 -2
- data/vendor/faiss/faiss/utils/extra_distances.cpp +87 -140
- data/vendor/faiss/faiss/utils/extra_distances.h +5 -4
- data/vendor/faiss/faiss/utils/fp16-arm.h +2 -2
- data/vendor/faiss/faiss/utils/fp16-fp16c.h +2 -2
- data/vendor/faiss/faiss/utils/fp16-inl.h +2 -2
- data/vendor/faiss/faiss/utils/fp16.h +2 -2
- data/vendor/faiss/faiss/utils/hamming-inl.h +2 -2
- data/vendor/faiss/faiss/utils/hamming.cpp +3 -4
- data/vendor/faiss/faiss/utils/hamming.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/avx2-inl.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/avx512-inl.h +490 -0
- data/vendor/faiss/faiss/utils/hamming_distance/common.h +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +6 -3
- data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +7 -3
- data/vendor/faiss/faiss/utils/hamming_distance/neon-inl.h +5 -5
- data/vendor/faiss/faiss/utils/ordered_key_value.h +2 -2
- data/vendor/faiss/faiss/utils/partitioning.cpp +2 -2
- data/vendor/faiss/faiss/utils/partitioning.h +2 -2
- data/vendor/faiss/faiss/utils/prefetch.h +2 -2
- data/vendor/faiss/faiss/utils/quantize_lut.cpp +2 -2
- data/vendor/faiss/faiss/utils/quantize_lut.h +2 -2
- data/vendor/faiss/faiss/utils/random.cpp +45 -2
- data/vendor/faiss/faiss/utils/random.h +27 -2
- data/vendor/faiss/faiss/utils/simdlib.h +12 -3
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +296 -0
- data/vendor/faiss/faiss/utils/simdlib_emulated.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_neon.h +7 -4
- data/vendor/faiss/faiss/utils/simdlib_ppc64.h +1084 -0
- data/vendor/faiss/faiss/utils/sorting.cpp +2 -2
- data/vendor/faiss/faiss/utils/sorting.h +2 -2
- data/vendor/faiss/faiss/utils/transpose/transpose-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +176 -0
- data/vendor/faiss/faiss/utils/utils.cpp +17 -10
- data/vendor/faiss/faiss/utils/utils.h +7 -3
- metadata +22 -11
- data/vendor/faiss/faiss/impl/code_distance/code_distance_avx512.h +0 -102
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -14,7 +14,6 @@
|
|
14
14
|
#include <faiss/gpu/utils/DeviceUtils.h>
|
15
15
|
#include <faiss/gpu/utils/Timer.h>
|
16
16
|
#include <gflags/gflags.h>
|
17
|
-
#include <map>
|
18
17
|
#include <vector>
|
19
18
|
|
20
19
|
DEFINE_int32(batches, 10, "number of batches of vectors to add");
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
#include <faiss/gpu/impl/InterleavedCodes.h>
|
9
9
|
#include <faiss/gpu/test/TestUtils.h>
|
10
|
+
#include <faiss/gpu/utils/DeviceUtils.h>
|
10
11
|
#include <faiss/gpu/utils/StaticUtils.h>
|
11
12
|
#include <gtest/gtest.h>
|
12
13
|
#include <cmath>
|
@@ -119,8 +120,9 @@ TEST(TestCodePacking, InterleavedCodes_UnpackPack) {
|
|
119
120
|
std::cout << bitsPerCode << " " << dims << " " << numVecs
|
120
121
|
<< "\n";
|
121
122
|
|
122
|
-
int
|
123
|
-
int
|
123
|
+
int warpSize = getWarpSizeCurrentDevice();
|
124
|
+
int blocks = utils::divUp(numVecs, warpSize);
|
125
|
+
int bytesPerDimBlock = warpSize * bitsPerCode / 8;
|
124
126
|
int bytesPerBlock = bytesPerDimBlock * dims;
|
125
127
|
int size = blocks * bytesPerBlock;
|
126
128
|
|
@@ -132,9 +134,9 @@ TEST(TestCodePacking, InterleavedCodes_UnpackPack) {
|
|
132
134
|
|
133
135
|
for (int i = 0; i < blocks; ++i) {
|
134
136
|
for (int j = 0; j < dims; ++j) {
|
135
|
-
for (int k = 0; k <
|
137
|
+
for (int k = 0; k < warpSize; ++k) {
|
136
138
|
for (int l = 0; l < bytesPerCode; ++l) {
|
137
|
-
int vec = i *
|
139
|
+
int vec = i * warpSize + k;
|
138
140
|
if (vec < numVecs) {
|
139
141
|
data[i * bytesPerBlock +
|
140
142
|
j * bytesPerDimBlock +
|
@@ -148,7 +150,8 @@ TEST(TestCodePacking, InterleavedCodes_UnpackPack) {
|
|
148
150
|
for (int i = 0; i < blocks; ++i) {
|
149
151
|
for (int j = 0; j < dims; ++j) {
|
150
152
|
for (int k = 0; k < bytesPerDimBlock; ++k) {
|
151
|
-
int loVec =
|
153
|
+
int loVec =
|
154
|
+
i * warpSize + (k * 8) / bitsPerCode;
|
152
155
|
int hiVec = loVec + 1;
|
153
156
|
int hiVec2 = hiVec + 1;
|
154
157
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
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.
|
@@ -29,7 +29,7 @@ struct TestFlatOptions {
|
|
29
29
|
numQueriesOverride(-1),
|
30
30
|
kOverride(-1),
|
31
31
|
dimOverride(-1),
|
32
|
-
|
32
|
+
use_cuvs(false) {}
|
33
33
|
|
34
34
|
faiss::MetricType metric;
|
35
35
|
float metricArg;
|
@@ -39,7 +39,7 @@ struct TestFlatOptions {
|
|
39
39
|
int numQueriesOverride;
|
40
40
|
int kOverride;
|
41
41
|
int dimOverride;
|
42
|
-
bool
|
42
|
+
bool use_cuvs;
|
43
43
|
};
|
44
44
|
|
45
45
|
void testFlat(const TestFlatOptions& opt) {
|
@@ -75,7 +75,7 @@ void testFlat(const TestFlatOptions& opt) {
|
|
75
75
|
faiss::gpu::GpuIndexFlatConfig config;
|
76
76
|
config.device = device;
|
77
77
|
config.useFloat16 = opt.useFloat16;
|
78
|
-
config.
|
78
|
+
config.use_cuvs = opt.use_cuvs;
|
79
79
|
|
80
80
|
faiss::gpu::GpuIndexFlat gpuIndex(&res, dim, opt.metric, config);
|
81
81
|
gpuIndex.metric_arg = opt.metricArg;
|
@@ -114,8 +114,8 @@ TEST(TestGpuIndexFlat, IP_Float32) {
|
|
114
114
|
|
115
115
|
testFlat(opt);
|
116
116
|
|
117
|
-
#if defined
|
118
|
-
opt.
|
117
|
+
#if defined USE_NVIDIA_CUVS
|
118
|
+
opt.use_cuvs = true;
|
119
119
|
testFlat(opt);
|
120
120
|
#endif
|
121
121
|
}
|
@@ -128,8 +128,8 @@ TEST(TestGpuIndexFlat, L1_Float32) {
|
|
128
128
|
|
129
129
|
testFlat(opt);
|
130
130
|
|
131
|
-
#if defined
|
132
|
-
opt.
|
131
|
+
#if defined USE_NVIDIA_CUVS
|
132
|
+
opt.use_cuvs = true;
|
133
133
|
testFlat(opt);
|
134
134
|
#endif
|
135
135
|
}
|
@@ -141,8 +141,8 @@ TEST(TestGpuIndexFlat, Lp_Float32) {
|
|
141
141
|
opt.useFloat16 = false;
|
142
142
|
|
143
143
|
testFlat(opt);
|
144
|
-
#if defined
|
145
|
-
opt.
|
144
|
+
#if defined USE_NVIDIA_CUVS
|
145
|
+
opt.use_cuvs = true;
|
146
146
|
testFlat(opt);
|
147
147
|
#endif
|
148
148
|
}
|
@@ -155,8 +155,8 @@ TEST(TestGpuIndexFlat, L2_Float32) {
|
|
155
155
|
opt.useFloat16 = false;
|
156
156
|
|
157
157
|
testFlat(opt);
|
158
|
-
#if defined
|
159
|
-
opt.
|
158
|
+
#if defined USE_NVIDIA_CUVS
|
159
|
+
opt.use_cuvs = true;
|
160
160
|
testFlat(opt);
|
161
161
|
#endif
|
162
162
|
}
|
@@ -173,8 +173,8 @@ TEST(TestGpuIndexFlat, L2_k_2048) {
|
|
173
173
|
opt.numVecsOverride = 10000;
|
174
174
|
|
175
175
|
testFlat(opt);
|
176
|
-
#if defined
|
177
|
-
opt.
|
176
|
+
#if defined USE_NVIDIA_CUVS
|
177
|
+
opt.use_cuvs = true;
|
178
178
|
testFlat(opt);
|
179
179
|
#endif
|
180
180
|
}
|
@@ -189,8 +189,8 @@ TEST(TestGpuIndexFlat, L2_Float32_K1) {
|
|
189
189
|
opt.kOverride = 1;
|
190
190
|
|
191
191
|
testFlat(opt);
|
192
|
-
#if defined
|
193
|
-
opt.
|
192
|
+
#if defined USE_NVIDIA_CUVS
|
193
|
+
opt.use_cuvs = true;
|
194
194
|
testFlat(opt);
|
195
195
|
#endif
|
196
196
|
}
|
@@ -203,8 +203,8 @@ TEST(TestGpuIndexFlat, IP_Float16) {
|
|
203
203
|
opt.useFloat16 = true;
|
204
204
|
|
205
205
|
testFlat(opt);
|
206
|
-
#if defined
|
207
|
-
opt.
|
206
|
+
#if defined USE_NVIDIA_CUVS
|
207
|
+
opt.use_cuvs = true;
|
208
208
|
testFlat(opt);
|
209
209
|
#endif
|
210
210
|
}
|
@@ -217,8 +217,8 @@ TEST(TestGpuIndexFlat, L2_Float16) {
|
|
217
217
|
opt.useFloat16 = true;
|
218
218
|
|
219
219
|
testFlat(opt);
|
220
|
-
#if defined
|
221
|
-
opt.
|
220
|
+
#if defined USE_NVIDIA_CUVS
|
221
|
+
opt.use_cuvs = true;
|
222
222
|
testFlat(opt);
|
223
223
|
#endif
|
224
224
|
}
|
@@ -233,8 +233,8 @@ TEST(TestGpuIndexFlat, L2_Float16_K1) {
|
|
233
233
|
opt.kOverride = 1;
|
234
234
|
|
235
235
|
testFlat(opt);
|
236
|
-
#if defined
|
237
|
-
opt.
|
236
|
+
#if defined USE_NVIDIA_CUVS
|
237
|
+
opt.use_cuvs = true;
|
238
238
|
testFlat(opt);
|
239
239
|
#endif
|
240
240
|
}
|
@@ -254,8 +254,8 @@ TEST(TestGpuIndexFlat, L2_Tiling) {
|
|
254
254
|
opt.kOverride = 64;
|
255
255
|
|
256
256
|
testFlat(opt);
|
257
|
-
#if defined
|
258
|
-
opt.
|
257
|
+
#if defined USE_NVIDIA_CUVS
|
258
|
+
opt.use_cuvs = true;
|
259
259
|
testFlat(opt);
|
260
260
|
#endif
|
261
261
|
}
|
@@ -268,7 +268,7 @@ TEST(TestGpuIndexFlat, QueryEmpty) {
|
|
268
268
|
faiss::gpu::GpuIndexFlatConfig config;
|
269
269
|
config.device = 0;
|
270
270
|
config.useFloat16 = false;
|
271
|
-
config.
|
271
|
+
config.use_cuvs = false;
|
272
272
|
int dim = 128;
|
273
273
|
faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, dim, config);
|
274
274
|
|
@@ -292,7 +292,7 @@ TEST(TestGpuIndexFlat, QueryEmpty) {
|
|
292
292
|
}
|
293
293
|
}
|
294
294
|
|
295
|
-
void testCopyFrom(bool
|
295
|
+
void testCopyFrom(bool use_cuvs) {
|
296
296
|
int numVecs = faiss::gpu::randVal(100, 200);
|
297
297
|
int dim = faiss::gpu::randVal(1, 1000);
|
298
298
|
|
@@ -310,7 +310,7 @@ void testCopyFrom(bool use_raft) {
|
|
310
310
|
faiss::gpu::GpuIndexFlatConfig config;
|
311
311
|
config.device = device;
|
312
312
|
config.useFloat16 = useFloat16;
|
313
|
-
config.
|
313
|
+
config.use_cuvs = use_cuvs;
|
314
314
|
|
315
315
|
// Fill with garbage values
|
316
316
|
faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, 2000, config);
|
@@ -343,13 +343,13 @@ TEST(TestGpuIndexFlat, CopyFrom) {
|
|
343
343
|
testCopyFrom(false);
|
344
344
|
}
|
345
345
|
|
346
|
-
#if defined
|
347
|
-
TEST(
|
346
|
+
#if defined USE_NVIDIA_CUVS
|
347
|
+
TEST(TestCuvsGpuIndexFlat, CopyFrom) {
|
348
348
|
testCopyFrom(true);
|
349
349
|
}
|
350
350
|
#endif
|
351
351
|
|
352
|
-
void testCopyTo(bool
|
352
|
+
void testCopyTo(bool use_cuvs) {
|
353
353
|
faiss::gpu::StandardGpuResources res;
|
354
354
|
res.noTempMemory();
|
355
355
|
|
@@ -363,7 +363,7 @@ void testCopyTo(bool use_raft) {
|
|
363
363
|
faiss::gpu::GpuIndexFlatConfig config;
|
364
364
|
config.device = device;
|
365
365
|
config.useFloat16 = useFloat16;
|
366
|
-
config.
|
366
|
+
config.use_cuvs = use_cuvs;
|
367
367
|
|
368
368
|
faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, dim, config);
|
369
369
|
gpuIndex.add(numVecs, vecs.data());
|
@@ -394,13 +394,13 @@ TEST(TestGpuIndexFlat, CopyTo) {
|
|
394
394
|
testCopyTo(false);
|
395
395
|
}
|
396
396
|
|
397
|
-
#if defined
|
398
|
-
TEST(
|
397
|
+
#if defined USE_NVIDIA_CUVS
|
398
|
+
TEST(TestCuvsGpuIndexFlat, CopyTo) {
|
399
399
|
testCopyTo(true);
|
400
400
|
}
|
401
401
|
#endif
|
402
402
|
|
403
|
-
void testUnifiedMemory(bool
|
403
|
+
void testUnifiedMemory(bool use_cuvs) {
|
404
404
|
// Construct on a random device to test multi-device, if we have
|
405
405
|
// multiple devices
|
406
406
|
int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
@@ -426,7 +426,7 @@ void testUnifiedMemory(bool use_raft) {
|
|
426
426
|
faiss::gpu::GpuIndexFlatConfig config;
|
427
427
|
config.device = device;
|
428
428
|
config.memorySpace = faiss::gpu::MemorySpace::Unified;
|
429
|
-
config.
|
429
|
+
config.use_cuvs = use_cuvs;
|
430
430
|
|
431
431
|
faiss::gpu::GpuIndexFlatL2 gpuIndexL2(&res, dim, config);
|
432
432
|
|
@@ -452,13 +452,13 @@ TEST(TestGpuIndexFlat, UnifiedMemory) {
|
|
452
452
|
testUnifiedMemory(false);
|
453
453
|
}
|
454
454
|
|
455
|
-
#if defined
|
456
|
-
TEST(
|
455
|
+
#if defined USE_NVIDIA_CUVS
|
456
|
+
TEST(TestCuvsGpuIndexFlat, UnifiedMemory) {
|
457
457
|
testUnifiedMemory(true);
|
458
458
|
}
|
459
459
|
#endif
|
460
460
|
|
461
|
-
void testLargeIndex(bool
|
461
|
+
void testLargeIndex(bool use_cuvs) {
|
462
462
|
// Construct on a random device to test multi-device, if we have
|
463
463
|
// multiple devices
|
464
464
|
int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
@@ -489,7 +489,7 @@ void testLargeIndex(bool use_raft) {
|
|
489
489
|
|
490
490
|
faiss::gpu::GpuIndexFlatConfig config;
|
491
491
|
config.device = device;
|
492
|
-
config.
|
492
|
+
config.use_cuvs = use_cuvs;
|
493
493
|
faiss::gpu::GpuIndexFlatL2 gpuIndexL2(&res, dim, config);
|
494
494
|
|
495
495
|
cpuIndexL2.add(nb, xb.data());
|
@@ -513,13 +513,13 @@ TEST(TestGpuIndexFlat, LargeIndex) {
|
|
513
513
|
testLargeIndex(false);
|
514
514
|
}
|
515
515
|
|
516
|
-
#if defined
|
517
|
-
TEST(
|
516
|
+
#if defined USE_NVIDIA_CUVS
|
517
|
+
TEST(TestCuvsGpuIndexFlat, LargeIndex) {
|
518
518
|
testLargeIndex(true);
|
519
519
|
}
|
520
520
|
#endif
|
521
521
|
|
522
|
-
void testResidual(bool
|
522
|
+
void testResidual(bool use_cuvs) {
|
523
523
|
// Construct on a random device to test multi-device, if we have
|
524
524
|
// multiple devices
|
525
525
|
int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
@@ -529,7 +529,7 @@ void testResidual(bool use_raft) {
|
|
529
529
|
|
530
530
|
faiss::gpu::GpuIndexFlatConfig config;
|
531
531
|
config.device = device;
|
532
|
-
config.
|
532
|
+
config.use_cuvs = use_cuvs;
|
533
533
|
|
534
534
|
int dim = 32;
|
535
535
|
faiss::IndexFlat cpuIndex(dim, faiss::MetricType::METRIC_L2);
|
@@ -566,13 +566,13 @@ TEST(TestGpuIndexFlat, Residual) {
|
|
566
566
|
testResidual(false);
|
567
567
|
}
|
568
568
|
|
569
|
-
#if defined
|
570
|
-
TEST(
|
569
|
+
#if defined USE_NVIDIA_CUVS
|
570
|
+
TEST(TestCuvsGpuIndexFlat, Residual) {
|
571
571
|
testResidual(true);
|
572
572
|
}
|
573
573
|
#endif
|
574
574
|
|
575
|
-
void testReconstruct(bool
|
575
|
+
void testReconstruct(bool use_cuvs) {
|
576
576
|
// Construct on a random device to test multi-device, if we have
|
577
577
|
// multiple devices
|
578
578
|
int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
@@ -589,7 +589,7 @@ void testReconstruct(bool use_raft) {
|
|
589
589
|
faiss::gpu::GpuIndexFlatConfig config;
|
590
590
|
config.device = device;
|
591
591
|
config.useFloat16 = useFloat16;
|
592
|
-
config.
|
592
|
+
config.use_cuvs = use_cuvs;
|
593
593
|
|
594
594
|
faiss::gpu::GpuIndexFlat gpuIndex(
|
595
595
|
&res, dim, faiss::MetricType::METRIC_L2, config);
|
@@ -657,13 +657,13 @@ void testReconstruct(bool use_raft) {
|
|
657
657
|
TEST(TestGpuIndexFlat, Reconstruct) {
|
658
658
|
testReconstruct(false);
|
659
659
|
}
|
660
|
-
#if defined
|
661
|
-
TEST(
|
660
|
+
#if defined USE_NVIDIA_CUVS
|
661
|
+
TEST(TestCuvsGpuIndexFlat, Reconstruct) {
|
662
662
|
testReconstruct(true);
|
663
663
|
}
|
664
664
|
#endif
|
665
665
|
|
666
|
-
void testSearchAndReconstruct(bool
|
666
|
+
void testSearchAndReconstruct(bool use_cuvs) {
|
667
667
|
// Construct on a random device to test multi-device, if we have
|
668
668
|
// multiple devices
|
669
669
|
int device = faiss::gpu::randVal(0, faiss::gpu::getNumDevices() - 1);
|
@@ -683,7 +683,7 @@ void testSearchAndReconstruct(bool use_raft) {
|
|
683
683
|
|
684
684
|
faiss::gpu::GpuIndexFlatConfig config;
|
685
685
|
config.device = device;
|
686
|
-
config.
|
686
|
+
config.use_cuvs = use_cuvs;
|
687
687
|
faiss::gpu::GpuIndexFlatL2 gpuIndex(&res, dim, config);
|
688
688
|
|
689
689
|
cpuIndex.add(nb, xb.data());
|
@@ -754,8 +754,8 @@ TEST(TestGpuIndexFlat, SearchAndReconstruct) {
|
|
754
754
|
testSearchAndReconstruct(false);
|
755
755
|
}
|
756
756
|
|
757
|
-
#if defined
|
758
|
-
TEST(
|
757
|
+
#if defined USE_NVIDIA_CUVS
|
758
|
+
TEST(TestCuvsGpuIndexFlat, SearchAndReconstruct) {
|
759
759
|
testSearchAndReconstruct(true);
|
760
760
|
}
|
761
761
|
#endif
|