faiss 0.3.2 → 0.3.4
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 +8 -0
- data/LICENSE.txt +1 -1
- data/ext/faiss/extconf.rb +1 -1
- data/ext/faiss/index.cpp +10 -14
- data/ext/faiss/numo.hpp +957 -833
- 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
data/lib/faiss/version.rb
CHANGED
data/vendor/faiss/faiss/IVFlib.h
CHANGED
@@ -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.
|
@@ -134,6 +134,10 @@ void Index::sa_decode(idx_t, const uint8_t*, float*) const {
|
|
134
134
|
FAISS_THROW_MSG("standalone codec not implemented for this type of index");
|
135
135
|
}
|
136
136
|
|
137
|
+
void Index::add_sa_codes(idx_t, const uint8_t*, const idx_t*) {
|
138
|
+
FAISS_THROW_MSG("add_sa_codes not implemented for this type of index");
|
139
|
+
}
|
140
|
+
|
137
141
|
namespace {
|
138
142
|
|
139
143
|
// storage that explicitly reconstructs vectors before computing distances
|
data/vendor/faiss/faiss/Index.h
CHANGED
@@ -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.
|
@@ -17,7 +17,7 @@
|
|
17
17
|
#include <typeinfo>
|
18
18
|
|
19
19
|
#define FAISS_VERSION_MAJOR 1
|
20
|
-
#define FAISS_VERSION_MINOR
|
20
|
+
#define FAISS_VERSION_MINOR 10
|
21
21
|
#define FAISS_VERSION_PATCH 0
|
22
22
|
|
23
23
|
// Macro to combine the version components into a single string
|
@@ -307,6 +307,13 @@ struct Index {
|
|
307
307
|
* trained in the same way and have the same
|
308
308
|
* parameters). Otherwise throw. */
|
309
309
|
virtual void check_compatible_for_merge(const Index& otherIndex) const;
|
310
|
+
|
311
|
+
/** Add vectors that are computed with the standalone codec
|
312
|
+
*
|
313
|
+
* @param codes codes to add size n * sa_code_size()
|
314
|
+
* @param xids corresponding ids, size n
|
315
|
+
*/
|
316
|
+
virtual void add_sa_codes(idx_t n, const uint8_t* codes, const idx_t* xids);
|
310
317
|
};
|
311
318
|
|
312
319
|
} // 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.
|
@@ -16,7 +16,6 @@
|
|
16
16
|
#include <faiss/impl/ResultHandler.h>
|
17
17
|
#include <faiss/utils/distances.h>
|
18
18
|
#include <faiss/utils/extra_distances.h>
|
19
|
-
#include <faiss/utils/utils.h>
|
20
19
|
|
21
20
|
namespace faiss {
|
22
21
|
|
@@ -273,6 +272,7 @@ void IndexAdditiveQuantizer::search(
|
|
273
272
|
DISPATCH(ST_norm_qint8)
|
274
273
|
DISPATCH(ST_norm_qint4)
|
275
274
|
DISPATCH(ST_norm_cqint4)
|
275
|
+
DISPATCH(ST_norm_from_LUT)
|
276
276
|
case AdditiveQuantizer::ST_norm_cqint8:
|
277
277
|
case AdditiveQuantizer::ST_norm_lsq2x4:
|
278
278
|
case AdditiveQuantizer::ST_norm_rq2x4:
|
@@ -527,7 +527,7 @@ void ResidualCoarseQuantizer::search(
|
|
527
527
|
float* distances,
|
528
528
|
idx_t* labels,
|
529
529
|
const SearchParameters* params_in) const {
|
530
|
-
float
|
530
|
+
float actual_beam_factor = this->beam_factor;
|
531
531
|
if (params_in) {
|
532
532
|
auto params =
|
533
533
|
dynamic_cast<const SearchParametersResidualCoarseQuantizer*>(
|
@@ -535,15 +535,15 @@ void ResidualCoarseQuantizer::search(
|
|
535
535
|
FAISS_THROW_IF_NOT_MSG(
|
536
536
|
params,
|
537
537
|
"need SearchParametersResidualCoarseQuantizer parameters");
|
538
|
-
|
538
|
+
actual_beam_factor = params->beam_factor;
|
539
539
|
}
|
540
540
|
|
541
|
-
if (
|
541
|
+
if (actual_beam_factor < 0) {
|
542
542
|
AdditiveCoarseQuantizer::search(n, x, k, distances, labels);
|
543
543
|
return;
|
544
544
|
}
|
545
545
|
|
546
|
-
int beam_size = int(k *
|
546
|
+
int beam_size = int(k * actual_beam_factor);
|
547
547
|
if (beam_size > ntotal) {
|
548
548
|
beam_size = ntotal;
|
549
549
|
}
|
@@ -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/IndexAdditiveQuantizerFastScan.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/LocalSearchQuantizer.h>
|
18
15
|
#include <faiss/impl/LookupTableScaler.h>
|
@@ -35,30 +32,31 @@ IndexAdditiveQuantizerFastScan::IndexAdditiveQuantizerFastScan(
|
|
35
32
|
}
|
36
33
|
|
37
34
|
void IndexAdditiveQuantizerFastScan::init(
|
38
|
-
AdditiveQuantizer*
|
35
|
+
AdditiveQuantizer* aq_init,
|
39
36
|
MetricType metric,
|
40
37
|
int bbs) {
|
41
|
-
FAISS_THROW_IF_NOT(
|
42
|
-
FAISS_THROW_IF_NOT(!
|
43
|
-
FAISS_THROW_IF_NOT(
|
38
|
+
FAISS_THROW_IF_NOT(aq_init != nullptr);
|
39
|
+
FAISS_THROW_IF_NOT(!aq_init->nbits.empty());
|
40
|
+
FAISS_THROW_IF_NOT(aq_init->nbits[0] == 4);
|
44
41
|
if (metric == METRIC_INNER_PRODUCT) {
|
45
42
|
FAISS_THROW_IF_NOT_MSG(
|
46
|
-
|
43
|
+
aq_init->search_type == AdditiveQuantizer::ST_LUT_nonorm,
|
47
44
|
"Search type must be ST_LUT_nonorm for IP metric");
|
48
45
|
} else {
|
49
46
|
FAISS_THROW_IF_NOT_MSG(
|
50
|
-
|
51
|
-
|
47
|
+
aq_init->search_type == AdditiveQuantizer::ST_norm_lsq2x4 ||
|
48
|
+
aq_init->search_type ==
|
49
|
+
AdditiveQuantizer::ST_norm_rq2x4,
|
52
50
|
"Search type must be lsq2x4 or rq2x4 for L2 metric");
|
53
51
|
}
|
54
52
|
|
55
|
-
this->aq =
|
53
|
+
this->aq = aq_init;
|
56
54
|
if (metric == METRIC_L2) {
|
57
|
-
M =
|
55
|
+
M = aq_init->M + 2; // 2x4 bits AQ
|
58
56
|
} else {
|
59
|
-
M =
|
57
|
+
M = aq_init->M;
|
60
58
|
}
|
61
|
-
init_fastscan(
|
59
|
+
init_fastscan(aq_init->d, M, 4, metric, bbs);
|
62
60
|
|
63
61
|
max_train_points = 1024 * ksub * M;
|
64
62
|
}
|
@@ -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.
|
@@ -103,4 +103,15 @@ void IndexBinary::check_compatible_for_merge(
|
|
103
103
|
FAISS_THROW_MSG("check_compatible_for_merge() not implemented");
|
104
104
|
}
|
105
105
|
|
106
|
+
size_t IndexBinary::sa_code_size() const {
|
107
|
+
return code_size;
|
108
|
+
}
|
109
|
+
|
110
|
+
void IndexBinary::add_sa_codes(
|
111
|
+
idx_t n,
|
112
|
+
const uint8_t* codes,
|
113
|
+
const idx_t* xids) {
|
114
|
+
add_with_ids(n, codes, xids);
|
115
|
+
}
|
116
|
+
|
106
117
|
} // 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.
|
@@ -171,6 +171,12 @@ struct IndexBinary {
|
|
171
171
|
* parameters). Otherwise throw. */
|
172
172
|
virtual void check_compatible_for_merge(
|
173
173
|
const IndexBinary& otherIndex) const;
|
174
|
+
|
175
|
+
/** size of the produced codes in bytes */
|
176
|
+
virtual size_t sa_code_size() const;
|
177
|
+
|
178
|
+
/** Same as add_with_ids for IndexBinary. */
|
179
|
+
virtual void add_sa_codes(idx_t n, const uint8_t* codes, const idx_t* xids);
|
174
180
|
};
|
175
181
|
|
176
182
|
} // 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.
|
@@ -14,7 +14,6 @@
|
|
14
14
|
#include <faiss/impl/IDSelector.h>
|
15
15
|
#include <faiss/utils/Heap.h>
|
16
16
|
#include <faiss/utils/hamming.h>
|
17
|
-
#include <faiss/utils/utils.h>
|
18
17
|
#include <cstring>
|
19
18
|
|
20
19
|
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.
|
@@ -15,11 +15,6 @@
|
|
15
15
|
#include <cstring>
|
16
16
|
#include <memory>
|
17
17
|
|
18
|
-
#include <queue>
|
19
|
-
#include <unordered_set>
|
20
|
-
|
21
|
-
#include <sys/stat.h>
|
22
|
-
#include <sys/types.h>
|
23
18
|
#include <cstdint>
|
24
19
|
|
25
20
|
#include <faiss/IndexBinaryFlat.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.
|
@@ -19,7 +19,6 @@
|
|
19
19
|
|
20
20
|
#include <faiss/impl/AuxIndexStructures.h>
|
21
21
|
#include <faiss/impl/FaissAssert.h>
|
22
|
-
#include <faiss/impl/platform_macros.h>
|
23
22
|
|
24
23
|
namespace faiss {
|
25
24
|
|
@@ -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.
|
@@ -17,11 +17,7 @@
|
|
17
17
|
#include <faiss/impl/IDSelector.h>
|
18
18
|
#include <faiss/impl/LookupTableScaler.h>
|
19
19
|
#include <faiss/impl/ResultHandler.h>
|
20
|
-
#include <faiss/utils/distances.h>
|
21
|
-
#include <faiss/utils/extra_distances.h>
|
22
20
|
#include <faiss/utils/hamming.h>
|
23
|
-
#include <faiss/utils/random.h>
|
24
|
-
#include <faiss/utils/utils.h>
|
25
21
|
|
26
22
|
#include <faiss/impl/pq4_fast_scan.h>
|
27
23
|
#include <faiss/impl/simd_result_handlers.h>
|
@@ -37,22 +33,22 @@ inline size_t roundup(size_t a, size_t b) {
|
|
37
33
|
|
38
34
|
void IndexFastScan::init_fastscan(
|
39
35
|
int d,
|
40
|
-
size_t
|
41
|
-
size_t
|
36
|
+
size_t M_init,
|
37
|
+
size_t nbits_init,
|
42
38
|
MetricType metric,
|
43
39
|
int bbs) {
|
44
|
-
FAISS_THROW_IF_NOT(
|
40
|
+
FAISS_THROW_IF_NOT(nbits_init == 4);
|
45
41
|
FAISS_THROW_IF_NOT(bbs % 32 == 0);
|
46
42
|
this->d = d;
|
47
|
-
this->M =
|
48
|
-
this->nbits =
|
43
|
+
this->M = M_init;
|
44
|
+
this->nbits = nbits_init;
|
49
45
|
this->metric_type = metric;
|
50
46
|
this->bbs = bbs;
|
51
|
-
ksub = (1 <<
|
47
|
+
ksub = (1 << nbits_init);
|
52
48
|
|
53
|
-
code_size = (
|
49
|
+
code_size = (M_init * nbits_init + 7) / 8;
|
54
50
|
ntotal = ntotal2 = 0;
|
55
|
-
M2 = roundup(
|
51
|
+
M2 = roundup(M_init, 2);
|
56
52
|
is_trained = false;
|
57
53
|
}
|
58
54
|
|
@@ -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.
|
@@ -133,6 +133,15 @@ struct IndexFastScan : Index {
|
|
133
133
|
|
134
134
|
void merge_from(Index& otherIndex, idx_t add_id = 0) override;
|
135
135
|
void check_compatible_for_merge(const Index& otherIndex) const override;
|
136
|
+
|
137
|
+
/// standalone codes interface (but the codes are flattened)
|
138
|
+
size_t sa_code_size() const override {
|
139
|
+
return code_size;
|
140
|
+
}
|
141
|
+
|
142
|
+
void sa_encode(idx_t n, const float* x, uint8_t* bytes) const override {
|
143
|
+
compute_codes(bytes, n, x);
|
144
|
+
}
|
136
145
|
};
|
137
146
|
|
138
147
|
struct FastScanStats {
|
@@ -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
|
#include <faiss/utils/extra_distances.h>
|
17
17
|
#include <faiss/utils/prefetch.h>
|
18
18
|
#include <faiss/utils/sorting.h>
|
19
|
-
#include <faiss/utils/utils.h>
|
20
19
|
#include <cstring>
|
21
20
|
|
22
21
|
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.
|
@@ -32,6 +32,15 @@ void IndexFlatCodes::add(idx_t n, const float* x) {
|
|
32
32
|
ntotal += n;
|
33
33
|
}
|
34
34
|
|
35
|
+
void IndexFlatCodes::add_sa_codes(
|
36
|
+
idx_t n,
|
37
|
+
const uint8_t* codes_in,
|
38
|
+
const idx_t* /* xids */) {
|
39
|
+
codes.resize((ntotal + n) * code_size);
|
40
|
+
memcpy(codes.data() + (ntotal * code_size), codes_in, n * code_size);
|
41
|
+
ntotal += n;
|
42
|
+
}
|
43
|
+
|
35
44
|
void IndexFlatCodes::reset() {
|
36
45
|
codes.clear();
|
37
46
|
ntotal = 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.
|
@@ -76,6 +76,9 @@ struct IndexFlatCodes : Index {
|
|
76
76
|
|
77
77
|
virtual void merge_from(Index& otherIndex, idx_t add_id = 0) override;
|
78
78
|
|
79
|
+
virtual void add_sa_codes(idx_t n, const uint8_t* x, const idx_t* xids)
|
80
|
+
override;
|
81
|
+
|
79
82
|
// permute_entries. perm of size ntotal maps new to old positions
|
80
83
|
void permute_entries(const idx_t* perm);
|
81
84
|
};
|
@@ -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.
|
@@ -19,10 +19,7 @@
|
|
19
19
|
#include <memory>
|
20
20
|
#include <queue>
|
21
21
|
#include <random>
|
22
|
-
#include <unordered_set>
|
23
22
|
|
24
|
-
#include <sys/stat.h>
|
25
|
-
#include <sys/types.h>
|
26
23
|
#include <cstdint>
|
27
24
|
|
28
25
|
#include <faiss/Index2Layer.h>
|
@@ -31,7 +28,6 @@
|
|
31
28
|
#include <faiss/impl/AuxIndexStructures.h>
|
32
29
|
#include <faiss/impl/FaissAssert.h>
|
33
30
|
#include <faiss/impl/ResultHandler.h>
|
34
|
-
#include <faiss/utils/distances.h>
|
35
31
|
#include <faiss/utils/random.h>
|
36
32
|
#include <faiss/utils/sorting.h>
|
37
33
|
|
@@ -355,6 +351,17 @@ void IndexHNSW::reconstruct(idx_t key, float* recons) const {
|
|
355
351
|
storage->reconstruct(key, recons);
|
356
352
|
}
|
357
353
|
|
354
|
+
/**************************************************************
|
355
|
+
* This section of functions were used during the development of HNSW support.
|
356
|
+
* They may be useful in the future but are dormant for now, and thus are not
|
357
|
+
* unit tested at the moment.
|
358
|
+
* shrink_level_0_neighbors
|
359
|
+
* search_level_0
|
360
|
+
* init_level_0_from_knngraph
|
361
|
+
* init_level_0_from_entry_points
|
362
|
+
* reorder_links
|
363
|
+
* link_singletons
|
364
|
+
**************************************************************/
|
358
365
|
void IndexHNSW::shrink_level_0_neighbors(int new_size) {
|
359
366
|
#pragma omp parallel
|
360
367
|
{
|