faiss 0.3.2 → 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 +4 -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 +2 -2
- data/vendor/faiss/faiss/Clustering.cpp +2 -2
- data/vendor/faiss/faiss/Clustering.h +2 -2
- data/vendor/faiss/faiss/IVFlib.cpp +2 -2
- data/vendor/faiss/faiss/IVFlib.h +2 -2
- data/vendor/faiss/faiss/Index.cpp +6 -2
- data/vendor/faiss/faiss/Index.h +10 -3
- 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 +2 -2
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +2 -3
- data/vendor/faiss/faiss/IndexBinaryHash.h +2 -2
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +2 -2
- data/vendor/faiss/faiss/IndexBinaryIVF.h +2 -2
- data/vendor/faiss/faiss/IndexFastScan.cpp +10 -14
- data/vendor/faiss/faiss/IndexFastScan.h +11 -2
- data/vendor/faiss/faiss/IndexFlat.cpp +2 -3
- data/vendor/faiss/faiss/IndexFlat.h +2 -2
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +11 -2
- data/vendor/faiss/faiss/IndexFlatCodes.h +5 -2
- data/vendor/faiss/faiss/IndexHNSW.cpp +13 -6
- data/vendor/faiss/faiss/IndexHNSW.h +2 -2
- data/vendor/faiss/faiss/IndexIDMap.cpp +19 -3
- data/vendor/faiss/faiss/IndexIDMap.h +5 -2
- data/vendor/faiss/faiss/IndexIVF.cpp +2 -3
- data/vendor/faiss/faiss/IndexIVF.h +5 -4
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +6 -7
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +2 -2
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +3 -14
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +2 -4
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +71 -34
- data/vendor/faiss/faiss/IndexIVFFastScan.h +19 -2
- 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 +2 -3
- data/vendor/faiss/faiss/IndexIVFPQ.h +2 -2
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +7 -33
- 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 +2 -2
- data/vendor/faiss/faiss/IndexLattice.h +2 -2
- data/vendor/faiss/faiss/IndexNNDescent.cpp +2 -2
- data/vendor/faiss/faiss/IndexNNDescent.h +2 -2
- data/vendor/faiss/faiss/IndexNSG.cpp +2 -5
- data/vendor/faiss/faiss/IndexNSG.h +2 -2
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +2 -2
- data/vendor/faiss/faiss/IndexNeuralNetCodec.h +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/IndexRefine.cpp +41 -4
- 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 +2 -3
- 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 +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/cppcontrib/factory_tools.cpp +44 -4
- data/vendor/faiss/faiss/cppcontrib/factory_tools.h +7 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +2 -2
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +2 -2
- 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 +13 -13
- data/vendor/faiss/faiss/gpu/GpuCloner.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuClonerOptions.h +6 -6
- data/vendor/faiss/faiss/gpu/GpuDistance.h +11 -7
- data/vendor/faiss/faiss/gpu/GpuFaissAssert.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndex.h +8 -7
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +6 -3
- data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +2 -2
- data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +2 -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 +51 -21
- 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 +2 -2
- 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 +2 -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 +2 -2
- 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 +80 -78
- 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 +2 -2
- data/vendor/faiss/faiss/gpu/utils/{RaftUtils.h → CuvsUtils.h} +12 -11
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +2 -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 +2 -2
- data/vendor/faiss/faiss/gpu/utils/Timer.h +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/impl/FaissAssert.h +2 -2
- 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 +24 -19
- data/vendor/faiss/faiss/impl/HNSW.h +12 -2
- 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 +2 -2
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +2 -2
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +2 -2
- data/vendor/faiss/faiss/impl/NNDescent.cpp +2 -2
- data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
- data/vendor/faiss/faiss/impl/NSG.cpp +27 -21
- 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 +2 -2
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +2 -2
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +2 -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 +2 -2
- data/vendor/faiss/faiss/impl/code_distance/code_distance-avx512.h +2 -2
- 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 +2 -5
- data/vendor/faiss/faiss/impl/index_read_utils.h +2 -2
- data/vendor/faiss/faiss/impl/index_write.cpp +2 -6
- data/vendor/faiss/faiss/impl/io.cpp +2 -2
- data/vendor/faiss/faiss/impl/io.h +2 -2
- data/vendor/faiss/faiss/impl/io_macros.h +2 -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 +12 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +2 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +20 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +2 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +2 -2
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +3 -3
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.h +2 -2
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +18 -18
- data/vendor/faiss/faiss/index_factory.cpp +20 -21
- data/vendor/faiss/faiss/index_factory.h +2 -2
- data/vendor/faiss/faiss/index_io.h +2 -2
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +2 -2
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.h +2 -2
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +2 -2
- data/vendor/faiss/faiss/invlists/DirectMap.h +2 -2
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +2 -2
- data/vendor/faiss/faiss/invlists/InvertedLists.h +2 -2
- 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 +2 -3
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.h +2 -2
- data/vendor/faiss/faiss/python/python_callbacks.cpp +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +11 -7
- data/vendor/faiss/faiss/utils/NeuralNet.h +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/utils/distances.cpp +191 -2
- data/vendor/faiss/faiss/utils/distances.h +3 -3
- 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 +502 -3
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +2 -2
- data/vendor/faiss/faiss/utils/extra_distances.cpp +2 -3
- data/vendor/faiss/faiss/utils/extra_distances.h +2 -2
- 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 +2 -3
- 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 +2 -2
- data/vendor/faiss/faiss/utils/hamming_distance/hamdis-inl.h +5 -2
- 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 +2 -2
- data/vendor/faiss/faiss/utils/random.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_emulated.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_neon.h +2 -2
- data/vendor/faiss/faiss/utils/simdlib_ppc64.h +2 -2
- 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 +2 -2
- data/vendor/faiss/faiss/utils/utils.cpp +7 -7
- data/vendor/faiss/faiss/utils/utils.h +4 -3
- metadata +9 -10
@@ -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.
|
@@ -77,6 +77,59 @@ inline void distance_four_codes(
|
|
77
77
|
|
78
78
|
} // namespace faiss
|
79
79
|
|
80
|
+
#elif defined(__ARM_FEATURE_SVE)
|
81
|
+
|
82
|
+
#include <faiss/impl/code_distance/code_distance-sve.h>
|
83
|
+
|
84
|
+
namespace faiss {
|
85
|
+
|
86
|
+
template <typename PQDecoderT>
|
87
|
+
inline float distance_single_code(
|
88
|
+
// the product quantizer
|
89
|
+
const size_t M,
|
90
|
+
// number of bits per quantization index
|
91
|
+
const size_t nbits,
|
92
|
+
// precomputed distances, layout (M, ksub)
|
93
|
+
const float* sim_table,
|
94
|
+
// the code
|
95
|
+
const uint8_t* code) {
|
96
|
+
return distance_single_code_sve<PQDecoderT>(M, nbits, sim_table, code);
|
97
|
+
}
|
98
|
+
|
99
|
+
template <typename PQDecoderT>
|
100
|
+
inline void distance_four_codes(
|
101
|
+
// the product quantizer
|
102
|
+
const size_t M,
|
103
|
+
// number of bits per quantization index
|
104
|
+
const size_t nbits,
|
105
|
+
// precomputed distances, layout (M, ksub)
|
106
|
+
const float* sim_table,
|
107
|
+
// codes
|
108
|
+
const uint8_t* __restrict code0,
|
109
|
+
const uint8_t* __restrict code1,
|
110
|
+
const uint8_t* __restrict code2,
|
111
|
+
const uint8_t* __restrict code3,
|
112
|
+
// computed distances
|
113
|
+
float& result0,
|
114
|
+
float& result1,
|
115
|
+
float& result2,
|
116
|
+
float& result3) {
|
117
|
+
distance_four_codes_sve<PQDecoderT>(
|
118
|
+
M,
|
119
|
+
nbits,
|
120
|
+
sim_table,
|
121
|
+
code0,
|
122
|
+
code1,
|
123
|
+
code2,
|
124
|
+
code3,
|
125
|
+
result0,
|
126
|
+
result1,
|
127
|
+
result2,
|
128
|
+
result3);
|
129
|
+
}
|
130
|
+
|
131
|
+
} // namespace faiss
|
132
|
+
|
80
133
|
#else
|
81
134
|
|
82
135
|
#include <faiss/impl/code_distance/code_distance-generic.h>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -13,9 +13,6 @@
|
|
13
13
|
#include <cstdio>
|
14
14
|
#include <cstdlib>
|
15
15
|
|
16
|
-
#include <sys/stat.h>
|
17
|
-
#include <sys/types.h>
|
18
|
-
|
19
16
|
#include <faiss/impl/FaissAssert.h>
|
20
17
|
#include <faiss/impl/io.h>
|
21
18
|
#include <faiss/impl/io_macros.h>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -13,13 +13,9 @@
|
|
13
13
|
#include <cstdio>
|
14
14
|
#include <cstdlib>
|
15
15
|
|
16
|
-
#include <sys/stat.h>
|
17
|
-
#include <sys/types.h>
|
18
|
-
|
19
16
|
#include <faiss/invlists/InvertedListsIOHook.h>
|
20
17
|
|
21
18
|
#include <faiss/impl/FaissAssert.h>
|
22
|
-
#include <faiss/impl/io.h>
|
23
19
|
#include <faiss/impl/io_macros.h>
|
24
20
|
#include <faiss/utils/hamming.h>
|
25
21
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -45,13 +45,6 @@
|
|
45
45
|
READANDCHECK((vec).data(), size); \
|
46
46
|
}
|
47
47
|
|
48
|
-
#define READSTRING(s) \
|
49
|
-
{ \
|
50
|
-
size_t size = (s).size(); \
|
51
|
-
WRITEANDCHECK(&size, 1); \
|
52
|
-
WRITEANDCHECK((s).c_str(), size); \
|
53
|
-
}
|
54
|
-
|
55
48
|
#define WRITEANDCHECK(ptr, n) \
|
56
49
|
{ \
|
57
50
|
size_t ret = (*f)(ptr, sizeof(*(ptr)), n); \
|
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
6
6
|
*/
|
7
7
|
|
8
8
|
#include <algorithm>
|
9
|
-
#include <cstdint>
|
10
9
|
#include <cstring>
|
11
10
|
#include <functional>
|
12
11
|
#include <numeric>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -16,7 +16,6 @@
|
|
16
16
|
|
17
17
|
#include <algorithm>
|
18
18
|
#include <queue>
|
19
|
-
#include <unordered_map>
|
20
19
|
#include <unordered_set>
|
21
20
|
|
22
21
|
#include <faiss/impl/platform_macros.h>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -39,6 +39,7 @@
|
|
39
39
|
// redefine the GCC intrinsics with Windows equivalents
|
40
40
|
|
41
41
|
#include <intrin.h>
|
42
|
+
#include <limits.h>
|
42
43
|
|
43
44
|
#ifndef __clang__
|
44
45
|
inline int __builtin_ctzll(uint64_t x) {
|
@@ -59,7 +60,16 @@ inline int __builtin_ctz(unsigned long x) {
|
|
59
60
|
|
60
61
|
#ifndef __clang__
|
61
62
|
inline int __builtin_clzll(uint64_t x) {
|
63
|
+
#if defined(_M_X64) || defined(__x86_64__)
|
62
64
|
return (int)__lzcnt64(x);
|
65
|
+
#elif defined(_M_ARM64)
|
66
|
+
unsigned long index;
|
67
|
+
int count = sizeof(uint64_t) * CHAR_BIT;
|
68
|
+
if (_BitScanReverse64(&index, x)) {
|
69
|
+
count = count - 1 - index;
|
70
|
+
}
|
71
|
+
return count;
|
72
|
+
#endif
|
63
73
|
}
|
64
74
|
#endif
|
65
75
|
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -189,4 +189,22 @@ void pq4_accumulate_loop_qbs(
|
|
189
189
|
SIMDResultHandler& res,
|
190
190
|
const NormTableScaler* scaler = nullptr);
|
191
191
|
|
192
|
+
/** Wrapper of pq4_accumulate_loop_qbs using simple StoreResultHandler
|
193
|
+
* and DummyScaler
|
194
|
+
*
|
195
|
+
* @param nq number of queries
|
196
|
+
* @param ntotal2 number of database elements (multiple of 32)
|
197
|
+
* @param nsq number of sub-quantizers (muliple of 2)
|
198
|
+
* @param codes packed codes array
|
199
|
+
* @param LUT packed look-up table
|
200
|
+
* @param accu array to store the results
|
201
|
+
*/
|
202
|
+
void accumulate_to_mem(
|
203
|
+
int nq,
|
204
|
+
size_t ntotal2,
|
205
|
+
int nsq,
|
206
|
+
const uint8_t* codes,
|
207
|
+
const uint8_t* LUT,
|
208
|
+
uint16_t* accu);
|
209
|
+
|
192
210
|
} // namespace faiss
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -809,7 +809,7 @@ void refine_beam_LUT_mp(
|
|
809
809
|
rq.codebook_offsets.data(),
|
810
810
|
query_cp + rq.codebook_offsets[m],
|
811
811
|
rq.total_codebook_size,
|
812
|
-
rq.
|
812
|
+
rq.centroid_norms.data() + rq.codebook_offsets[m],
|
813
813
|
m,
|
814
814
|
codes_ptr,
|
815
815
|
distances_ptr,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -368,10 +368,10 @@ struct HeapHandler : ResultHandlerCompare<C, with_id_map> {
|
|
368
368
|
auto real_idx = this->adjust_id(b, j);
|
369
369
|
lt_mask -= 1 << j;
|
370
370
|
if (this->sel->is_member(real_idx)) {
|
371
|
-
T
|
372
|
-
if (C::cmp(heap_dis[0],
|
371
|
+
T dis_2 = d32tab[j];
|
372
|
+
if (C::cmp(heap_dis[0], dis_2)) {
|
373
373
|
heap_replace_top<C>(
|
374
|
-
k, heap_dis, heap_ids,
|
374
|
+
k, heap_dis, heap_ids, dis_2, real_idx);
|
375
375
|
}
|
376
376
|
}
|
377
377
|
}
|
@@ -380,10 +380,10 @@ struct HeapHandler : ResultHandlerCompare<C, with_id_map> {
|
|
380
380
|
// find first non-zero
|
381
381
|
int j = __builtin_ctz(lt_mask);
|
382
382
|
lt_mask -= 1 << j;
|
383
|
-
T
|
384
|
-
if (C::cmp(heap_dis[0],
|
383
|
+
T dis_2 = d32tab[j];
|
384
|
+
if (C::cmp(heap_dis[0], dis_2)) {
|
385
385
|
int64_t idx = this->adjust_id(b, j);
|
386
|
-
heap_replace_top<C>(k, heap_dis, heap_ids,
|
386
|
+
heap_replace_top<C>(k, heap_dis, heap_ids, dis_2, idx);
|
387
387
|
}
|
388
388
|
}
|
389
389
|
}
|
@@ -480,8 +480,8 @@ struct ReservoirHandler : ResultHandlerCompare<C, with_id_map> {
|
|
480
480
|
auto real_idx = this->adjust_id(b, j);
|
481
481
|
lt_mask -= 1 << j;
|
482
482
|
if (this->sel->is_member(real_idx)) {
|
483
|
-
T
|
484
|
-
res.add(
|
483
|
+
T dis_2 = d32tab[j];
|
484
|
+
res.add(dis_2, real_idx);
|
485
485
|
}
|
486
486
|
}
|
487
487
|
} else {
|
@@ -489,8 +489,8 @@ struct ReservoirHandler : ResultHandlerCompare<C, with_id_map> {
|
|
489
489
|
// find first non-zero
|
490
490
|
int j = __builtin_ctz(lt_mask);
|
491
491
|
lt_mask -= 1 << j;
|
492
|
-
T
|
493
|
-
res.add(
|
492
|
+
T dis_2 = d32tab[j];
|
493
|
+
res.add(dis_2, this->adjust_id(b, j));
|
494
494
|
}
|
495
495
|
}
|
496
496
|
}
|
@@ -719,10 +719,10 @@ void dispatch_SIMDResultHandler_fixedCW(
|
|
719
719
|
Types... args) {
|
720
720
|
if (auto resh = dynamic_cast<SingleResultHandler<C, W>*>(&res)) {
|
721
721
|
consumer.template f<SingleResultHandler<C, W>>(*resh, args...);
|
722
|
-
} else if (auto
|
723
|
-
consumer.template f<HeapHandler<C, W>>(*
|
724
|
-
} else if (auto
|
725
|
-
consumer.template f<ReservoirHandler<C, W>>(*
|
722
|
+
} else if (auto resh_2 = dynamic_cast<HeapHandler<C, W>*>(&res)) {
|
723
|
+
consumer.template f<HeapHandler<C, W>>(*resh_2, args...);
|
724
|
+
} else if (auto resh_2 = dynamic_cast<ReservoirHandler<C, W>*>(&res)) {
|
725
|
+
consumer.template f<ReservoirHandler<C, W>>(*resh_2, args...);
|
726
726
|
} else { // generic handler -- will not be inlined
|
727
727
|
FAISS_THROW_IF_NOT_FMT(
|
728
728
|
simd_result_handlers_accept_virtual,
|
@@ -752,8 +752,8 @@ void dispatch_SIMDResultHandler(
|
|
752
752
|
if (res.sizeof_ids == 0) {
|
753
753
|
if (auto resh = dynamic_cast<StoreResultHandler*>(&res)) {
|
754
754
|
consumer.template f<StoreResultHandler>(*resh, args...);
|
755
|
-
} else if (auto
|
756
|
-
consumer.template f<DummyResultHandler>(*
|
755
|
+
} else if (auto resh_2 = dynamic_cast<DummyResultHandler*>(&res)) {
|
756
|
+
consumer.template f<DummyResultHandler>(*resh_2, args...);
|
757
757
|
} else { // generic path
|
758
758
|
FAISS_THROW_IF_NOT_FMT(
|
759
759
|
simd_result_handlers_accept_virtual,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -20,7 +20,6 @@
|
|
20
20
|
|
21
21
|
#include <faiss/impl/FaissAssert.h>
|
22
22
|
#include <faiss/utils/random.h>
|
23
|
-
#include <faiss/utils/utils.h>
|
24
23
|
|
25
24
|
#include <faiss/Index2Layer.h>
|
26
25
|
#include <faiss/IndexAdditiveQuantizer.h>
|
@@ -679,6 +678,24 @@ std::unique_ptr<Index> index_factory_sub(
|
|
679
678
|
// for the current match
|
680
679
|
std::smatch sm;
|
681
680
|
|
681
|
+
// IndexIDMap -- it turns out is was used both as a prefix and a suffix, so
|
682
|
+
// support both
|
683
|
+
if (re_match(description, "(.+),IDMap2", sm) ||
|
684
|
+
re_match(description, "IDMap2,(.+)", sm)) {
|
685
|
+
IndexIDMap2* idmap2 = new IndexIDMap2(
|
686
|
+
index_factory_sub(d, sm[1].str(), metric).release());
|
687
|
+
idmap2->own_fields = true;
|
688
|
+
return std::unique_ptr<Index>(idmap2);
|
689
|
+
}
|
690
|
+
|
691
|
+
if (re_match(description, "(.+),IDMap", sm) ||
|
692
|
+
re_match(description, "IDMap,(.+)", sm)) {
|
693
|
+
IndexIDMap* idmap = new IndexIDMap(
|
694
|
+
index_factory_sub(d, sm[1].str(), metric).release());
|
695
|
+
idmap->own_fields = true;
|
696
|
+
return std::unique_ptr<Index>(idmap);
|
697
|
+
}
|
698
|
+
|
682
699
|
// handle refines
|
683
700
|
if (re_match(description, "(.+),RFlat", sm) ||
|
684
701
|
re_match(description, "(.+),Refine\\((.+)\\)", sm)) {
|
@@ -755,24 +772,6 @@ std::unique_ptr<Index> index_factory_sub(
|
|
755
772
|
d);
|
756
773
|
}
|
757
774
|
|
758
|
-
// IndexIDMap -- it turns out is was used both as a prefix and a suffix, so
|
759
|
-
// support both
|
760
|
-
if (re_match(description, "(.+),IDMap2", sm) ||
|
761
|
-
re_match(description, "IDMap2,(.+)", sm)) {
|
762
|
-
IndexIDMap2* idmap2 = new IndexIDMap2(
|
763
|
-
index_factory_sub(d, sm[1].str(), metric).release());
|
764
|
-
idmap2->own_fields = true;
|
765
|
-
return std::unique_ptr<Index>(idmap2);
|
766
|
-
}
|
767
|
-
|
768
|
-
if (re_match(description, "(.+),IDMap", sm) ||
|
769
|
-
re_match(description, "IDMap,(.+)", sm)) {
|
770
|
-
IndexIDMap* idmap = new IndexIDMap(
|
771
|
-
index_factory_sub(d, sm[1].str(), metric).release());
|
772
|
-
idmap->own_fields = true;
|
773
|
-
return std::unique_ptr<Index>(idmap);
|
774
|
-
}
|
775
|
-
|
776
775
|
{ // handle basic index types
|
777
776
|
Index* index = parse_other_indexes(description, d, metric);
|
778
777
|
if (index) {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -15,7 +15,6 @@
|
|
15
15
|
|
16
16
|
#include <sys/mman.h>
|
17
17
|
#include <sys/stat.h>
|
18
|
-
#include <sys/types.h>
|
19
18
|
#include <unistd.h>
|
20
19
|
|
21
20
|
#include <faiss/impl/FaissAssert.h>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
* Copyright (c)
|
1
|
+
/*
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
3
|
*
|
4
4
|
* This source code is licensed under the MIT license found in the
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
@@ -63,7 +63,9 @@ struct AlignedTableTightAlloc {
|
|
63
63
|
}
|
64
64
|
|
65
65
|
void clear() {
|
66
|
-
|
66
|
+
if (numel > 0) {
|
67
|
+
memset(ptr, 0, nbytes());
|
68
|
+
}
|
67
69
|
}
|
68
70
|
size_t size() const {
|
69
71
|
return numel;
|