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.
|
@@ -159,16 +159,16 @@ void IndexPQ::search(
|
|
159
159
|
FAISS_THROW_IF_NOT(is_trained);
|
160
160
|
|
161
161
|
const SearchParametersPQ* params = nullptr;
|
162
|
-
Search_type_t
|
162
|
+
Search_type_t param_search_type = this->search_type;
|
163
163
|
|
164
164
|
if (iparams) {
|
165
165
|
params = dynamic_cast<const SearchParametersPQ*>(iparams);
|
166
166
|
FAISS_THROW_IF_NOT_MSG(params, "invalid search params");
|
167
167
|
FAISS_THROW_IF_NOT_MSG(!params->sel, "selector not supported");
|
168
|
-
|
168
|
+
param_search_type = params->search_type;
|
169
169
|
}
|
170
170
|
|
171
|
-
if (
|
171
|
+
if (param_search_type == ST_PQ) { // Simple PQ search
|
172
172
|
|
173
173
|
if (metric_type == METRIC_L2) {
|
174
174
|
float_maxheap_array_t res = {
|
@@ -183,10 +183,10 @@ void IndexPQ::search(
|
|
183
183
|
indexPQ_stats.ncode += n * ntotal;
|
184
184
|
|
185
185
|
} else if (
|
186
|
-
|
187
|
-
|
186
|
+
param_search_type == ST_polysemous ||
|
187
|
+
param_search_type == ST_polysemous_generalize) {
|
188
188
|
FAISS_THROW_IF_NOT(metric_type == METRIC_L2);
|
189
|
-
int
|
189
|
+
int param_polysemous_ht =
|
190
190
|
params ? params->polysemous_ht : this->polysemous_ht;
|
191
191
|
search_core_polysemous(
|
192
192
|
n,
|
@@ -194,8 +194,8 @@ void IndexPQ::search(
|
|
194
194
|
k,
|
195
195
|
distances,
|
196
196
|
labels,
|
197
|
-
|
198
|
-
|
197
|
+
param_polysemous_ht,
|
198
|
+
param_search_type == ST_polysemous_generalize);
|
199
199
|
|
200
200
|
} else { // code-to-code distances
|
201
201
|
|
@@ -215,7 +215,7 @@ void IndexPQ::search(
|
|
215
215
|
}
|
216
216
|
}
|
217
217
|
|
218
|
-
if (
|
218
|
+
if (param_search_type == ST_SDC) {
|
219
219
|
float_maxheap_array_t res = {
|
220
220
|
size_t(n), size_t(k), labels, distances};
|
221
221
|
|
@@ -227,7 +227,7 @@ void IndexPQ::search(
|
|
227
227
|
int_maxheap_array_t res = {
|
228
228
|
size_t(n), size_t(k), labels, idistances.get()};
|
229
229
|
|
230
|
-
if (
|
230
|
+
if (param_search_type == ST_HE) {
|
231
231
|
hammings_knn_hc(
|
232
232
|
&res,
|
233
233
|
q_codes.get(),
|
@@ -236,7 +236,7 @@ void IndexPQ::search(
|
|
236
236
|
pq.code_size,
|
237
237
|
true);
|
238
238
|
|
239
|
-
} else if (
|
239
|
+
} else if (param_search_type == ST_generalized_HE) {
|
240
240
|
generalized_hammings_knn_hc(
|
241
241
|
&res,
|
242
242
|
q_codes.get(),
|
@@ -322,13 +322,13 @@ void IndexPQ::search_core_polysemous(
|
|
322
322
|
idx_t k,
|
323
323
|
float* distances,
|
324
324
|
idx_t* labels,
|
325
|
-
int
|
325
|
+
int param_polysemous_ht,
|
326
326
|
bool generalized_hamming) const {
|
327
327
|
FAISS_THROW_IF_NOT(k > 0);
|
328
328
|
FAISS_THROW_IF_NOT(pq.nbits == 8);
|
329
329
|
|
330
|
-
if (
|
331
|
-
|
330
|
+
if (param_polysemous_ht == 0) {
|
331
|
+
param_polysemous_ht = pq.nbits * pq.M + 1;
|
332
332
|
}
|
333
333
|
|
334
334
|
// PQ distance tables
|
@@ -374,7 +374,7 @@ void IndexPQ::search_core_polysemous(
|
|
374
374
|
k,
|
375
375
|
heap_dis,
|
376
376
|
heap_ids,
|
377
|
-
|
377
|
+
param_polysemous_ht);
|
378
378
|
|
379
379
|
} else { // generalized hamming
|
380
380
|
switch (pq.code_size) {
|
@@ -387,7 +387,7 @@ void IndexPQ::search_core_polysemous(
|
|
387
387
|
k, \
|
388
388
|
heap_dis, \
|
389
389
|
heap_ids, \
|
390
|
-
|
390
|
+
param_polysemous_ht); \
|
391
391
|
break;
|
392
392
|
DISPATCH(8)
|
393
393
|
DISPATCH(16)
|
@@ -401,7 +401,7 @@ void IndexPQ::search_core_polysemous(
|
|
401
401
|
k,
|
402
402
|
heap_dis,
|
403
403
|
heap_ids,
|
404
|
-
|
404
|
+
param_polysemous_ht);
|
405
405
|
} else {
|
406
406
|
bad_code_size++;
|
407
407
|
}
|
@@ -516,8 +516,8 @@ struct PreSortedArray {
|
|
516
516
|
int N;
|
517
517
|
|
518
518
|
explicit PreSortedArray(int N) : N(N) {}
|
519
|
-
void init(const T*
|
520
|
-
this->x =
|
519
|
+
void init(const T* x_2) {
|
520
|
+
this->x = x_2;
|
521
521
|
}
|
522
522
|
// get smallest value
|
523
523
|
T get_0() {
|
@@ -557,11 +557,11 @@ struct SortedArray {
|
|
557
557
|
perm.resize(N);
|
558
558
|
}
|
559
559
|
|
560
|
-
void init(const T*
|
561
|
-
this->x =
|
560
|
+
void init(const T* x_2) {
|
561
|
+
this->x = x_2;
|
562
562
|
for (int n = 0; n < N; n++)
|
563
563
|
perm[n] = n;
|
564
|
-
ArgSort<T> cmp = {
|
564
|
+
ArgSort<T> cmp = {x_2};
|
565
565
|
std::sort(perm.begin(), perm.end(), cmp);
|
566
566
|
}
|
567
567
|
|
@@ -639,8 +639,8 @@ struct SemiSortedArray {
|
|
639
639
|
k_factor = 4;
|
640
640
|
}
|
641
641
|
|
642
|
-
void init(const T*
|
643
|
-
this->x =
|
642
|
+
void init(const T* x_2) {
|
643
|
+
this->x = x_2;
|
644
644
|
for (int n = 0; n < N; n++)
|
645
645
|
perm[n] = n;
|
646
646
|
k = 0;
|
@@ -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.
|
@@ -8,11 +8,8 @@
|
|
8
8
|
#include <faiss/IndexPQFastScan.h>
|
9
9
|
|
10
10
|
#include <cassert>
|
11
|
-
#include <climits>
|
12
11
|
#include <memory>
|
13
12
|
|
14
|
-
#include <omp.h>
|
15
|
-
|
16
13
|
#include <faiss/impl/FaissAssert.h>
|
17
14
|
#include <faiss/impl/pq4_fast_scan.h>
|
18
15
|
#include <faiss/utils/utils.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.
|
@@ -47,15 +47,6 @@ struct IndexPQFastScan : IndexFastScan {
|
|
47
47
|
|
48
48
|
void compute_float_LUT(float* lut, idx_t n, const float* x) const override;
|
49
49
|
|
50
|
-
/** Decode a set of vectors.
|
51
|
-
*
|
52
|
-
* NOTE: The codes in the IndexPQFastScan object are non-contiguous.
|
53
|
-
* But this method requires a contiguous representation.
|
54
|
-
*
|
55
|
-
* @param n number of vectors
|
56
|
-
* @param bytes input encoded vectors, size n * code_size
|
57
|
-
* @param x output vectors, size n * d
|
58
|
-
*/
|
59
50
|
void sa_decode(idx_t n, const uint8_t* bytes, float* x) const override;
|
60
51
|
};
|
61
52
|
|
@@ -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.
|
@@ -23,7 +23,7 @@ struct SearchParametersPreTransform : SearchParameters {
|
|
23
23
|
/** Index that applies a LinearTransform transform on vectors before
|
24
24
|
* handing them over to a sub-index */
|
25
25
|
struct IndexPreTransform : Index {
|
26
|
-
std::vector<VectorTransform*> chain; ///! chain of
|
26
|
+
std::vector<VectorTransform*> chain; ///! chain of transforms
|
27
27
|
Index* index; ///! the sub-index
|
28
28
|
|
29
29
|
bool own_fields; ///! whether pointers are deleted in destructor
|
@@ -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.
|
@@ -11,8 +11,6 @@
|
|
11
11
|
#include <faiss/impl/AuxIndexStructures.h>
|
12
12
|
#include <faiss/impl/FaissAssert.h>
|
13
13
|
#include <faiss/utils/Heap.h>
|
14
|
-
#include <faiss/utils/distances.h>
|
15
|
-
#include <faiss/utils/utils.h>
|
16
14
|
|
17
15
|
namespace faiss {
|
18
16
|
|
@@ -68,12 +66,12 @@ template <class C>
|
|
68
66
|
static void reorder_2_heaps(
|
69
67
|
idx_t n,
|
70
68
|
idx_t k,
|
71
|
-
idx_t* labels,
|
72
|
-
float* distances,
|
69
|
+
idx_t* __restrict labels,
|
70
|
+
float* __restrict distances,
|
73
71
|
idx_t k_base,
|
74
|
-
const idx_t* base_labels,
|
75
|
-
const float* base_distances) {
|
76
|
-
#pragma omp parallel for
|
72
|
+
const idx_t* __restrict base_labels,
|
73
|
+
const float* __restrict base_distances) {
|
74
|
+
#pragma omp parallel for if (n > 1)
|
77
75
|
for (idx_t i = 0; i < n; i++) {
|
78
76
|
idx_t* idxo = labels + i * k;
|
79
77
|
float* diso = distances + i * k;
|
@@ -168,6 +166,45 @@ void IndexRefine::search(
|
|
168
166
|
}
|
169
167
|
}
|
170
168
|
|
169
|
+
void IndexRefine::range_search(
|
170
|
+
idx_t n,
|
171
|
+
const float* x,
|
172
|
+
float radius,
|
173
|
+
RangeSearchResult* result,
|
174
|
+
const SearchParameters* params_in) const {
|
175
|
+
const IndexRefineSearchParameters* params = nullptr;
|
176
|
+
if (params_in) {
|
177
|
+
params = dynamic_cast<const IndexRefineSearchParameters*>(params_in);
|
178
|
+
FAISS_THROW_IF_NOT_MSG(
|
179
|
+
params, "IndexRefine params have incorrect type");
|
180
|
+
}
|
181
|
+
|
182
|
+
SearchParameters* base_index_params =
|
183
|
+
(params != nullptr) ? params->base_index_params : nullptr;
|
184
|
+
|
185
|
+
base_index->range_search(n, x, radius, result, base_index_params);
|
186
|
+
|
187
|
+
#pragma omp parallel if (n > 1)
|
188
|
+
{
|
189
|
+
std::unique_ptr<DistanceComputer> dc(
|
190
|
+
refine_index->get_distance_computer());
|
191
|
+
|
192
|
+
#pragma omp for
|
193
|
+
for (idx_t i = 0; i < n; i++) {
|
194
|
+
dc->set_query(x + i * d);
|
195
|
+
|
196
|
+
// reevaluate distances
|
197
|
+
const size_t idx_start = result->lims[i];
|
198
|
+
const size_t idx_end = result->lims[i + 1];
|
199
|
+
|
200
|
+
for (size_t j = idx_start; j < idx_end; j++) {
|
201
|
+
const auto label = result->labels[j];
|
202
|
+
result->distances[j] = (*dc)(label);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
171
208
|
void IndexRefine::reconstruct(idx_t key, float* recons) const {
|
172
209
|
refine_index->reconstruct(key, recons);
|
173
210
|
}
|
@@ -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.
|
@@ -54,6 +54,13 @@ struct IndexRefine : Index {
|
|
54
54
|
idx_t* labels,
|
55
55
|
const SearchParameters* params = nullptr) const override;
|
56
56
|
|
57
|
+
void range_search(
|
58
|
+
idx_t n,
|
59
|
+
const float* x,
|
60
|
+
float radius,
|
61
|
+
RangeSearchResult* result,
|
62
|
+
const SearchParameters* params = nullptr) const override;
|
63
|
+
|
57
64
|
// reconstruct is routed to the refine_index
|
58
65
|
void reconstruct(idx_t key, float* recons) const override;
|
59
66
|
|
@@ -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
|
|
15
15
|
#include <omp.h>
|
16
16
|
|
17
|
-
#include <faiss/impl/AuxIndexStructures.h>
|
18
17
|
#include <faiss/impl/FaissAssert.h>
|
19
18
|
#include <faiss/impl/IDSelector.h>
|
20
19
|
#include <faiss/impl/ScalarQuantizer.h>
|
@@ -32,7 +31,9 @@ IndexScalarQuantizer::IndexScalarQuantizer(
|
|
32
31
|
MetricType metric)
|
33
32
|
: IndexFlatCodes(0, d, metric), sq(d, qtype) {
|
34
33
|
is_trained = qtype == ScalarQuantizer::QT_fp16 ||
|
35
|
-
qtype == ScalarQuantizer::QT_8bit_direct
|
34
|
+
qtype == ScalarQuantizer::QT_8bit_direct ||
|
35
|
+
qtype == ScalarQuantizer::QT_bf16 ||
|
36
|
+
qtype == ScalarQuantizer::QT_8bit_direct_signed;
|
36
37
|
code_size = sq.code_size;
|
37
38
|
}
|
38
39
|
|
@@ -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 <faiss/impl/AuxIndexStructures.h>
|
18
18
|
#include <faiss/impl/FaissAssert.h>
|
19
|
-
#include <faiss/impl/IDSelector.h>
|
20
19
|
#include <faiss/utils/Heap.h>
|
21
20
|
#include <faiss/utils/WorkerThread.h>
|
22
21
|
#include <faiss/utils/random.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.
|
@@ -31,8 +31,13 @@ enum MetricType {
|
|
31
31
|
METRIC_Canberra = 20,
|
32
32
|
METRIC_BrayCurtis,
|
33
33
|
METRIC_JensenShannon,
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
/// sum_i(min(a_i, b_i)) / sum_i(max(a_i, b_i)) where a_i, b_i > 0
|
36
|
+
METRIC_Jaccard,
|
37
|
+
/// Squared Eucliden distance, ignoring NaNs
|
38
|
+
METRIC_NaNEuclidean,
|
39
|
+
/// abs(x | y): the distance to a hyperplane
|
40
|
+
METRIC_ABS_INNER_PRODUCT,
|
36
41
|
};
|
37
42
|
|
38
43
|
/// all vector indices are this type
|