faiss 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/LICENSE.txt +1 -1
- data/README.md +23 -21
- data/ext/faiss/extconf.rb +11 -0
- data/ext/faiss/index.cpp +4 -4
- data/ext/faiss/index_binary.cpp +6 -6
- data/ext/faiss/product_quantizer.cpp +4 -4
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +13 -0
- data/vendor/faiss/faiss/Clustering.cpp +32 -0
- data/vendor/faiss/faiss/Clustering.h +14 -0
- data/vendor/faiss/faiss/IVFlib.cpp +101 -2
- data/vendor/faiss/faiss/IVFlib.h +26 -2
- data/vendor/faiss/faiss/Index.cpp +36 -3
- data/vendor/faiss/faiss/Index.h +43 -6
- data/vendor/faiss/faiss/Index2Layer.cpp +24 -93
- data/vendor/faiss/faiss/Index2Layer.h +8 -17
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +610 -0
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.h +253 -0
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +299 -0
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +199 -0
- data/vendor/faiss/faiss/IndexBinary.cpp +20 -4
- data/vendor/faiss/faiss/IndexBinary.h +18 -3
- data/vendor/faiss/faiss/IndexBinaryFlat.cpp +9 -2
- data/vendor/faiss/faiss/IndexBinaryFlat.h +4 -2
- data/vendor/faiss/faiss/IndexBinaryFromFloat.cpp +4 -1
- data/vendor/faiss/faiss/IndexBinaryFromFloat.h +2 -1
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +5 -1
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +2 -1
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +17 -4
- data/vendor/faiss/faiss/IndexBinaryHash.h +8 -4
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +28 -13
- data/vendor/faiss/faiss/IndexBinaryIVF.h +10 -7
- data/vendor/faiss/faiss/IndexFastScan.cpp +626 -0
- data/vendor/faiss/faiss/IndexFastScan.h +145 -0
- data/vendor/faiss/faiss/IndexFlat.cpp +52 -69
- data/vendor/faiss/faiss/IndexFlat.h +16 -19
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +101 -0
- data/vendor/faiss/faiss/IndexFlatCodes.h +59 -0
- data/vendor/faiss/faiss/IndexHNSW.cpp +66 -138
- data/vendor/faiss/faiss/IndexHNSW.h +4 -2
- data/vendor/faiss/faiss/IndexIDMap.cpp +247 -0
- data/vendor/faiss/faiss/IndexIDMap.h +107 -0
- data/vendor/faiss/faiss/IndexIVF.cpp +200 -40
- data/vendor/faiss/faiss/IndexIVF.h +59 -22
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +393 -0
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h +183 -0
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +590 -0
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +171 -0
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +1290 -0
- data/vendor/faiss/faiss/IndexIVFFastScan.h +213 -0
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +43 -26
- data/vendor/faiss/faiss/IndexIVFFlat.h +4 -2
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +238 -53
- data/vendor/faiss/faiss/IndexIVFPQ.h +6 -2
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +23 -852
- data/vendor/faiss/faiss/IndexIVFPQFastScan.h +7 -112
- data/vendor/faiss/faiss/IndexIVFPQR.cpp +3 -3
- data/vendor/faiss/faiss/IndexIVFPQR.h +1 -1
- data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +63 -40
- data/vendor/faiss/faiss/IndexIVFSpectralHash.h +23 -7
- data/vendor/faiss/faiss/IndexLSH.cpp +8 -32
- data/vendor/faiss/faiss/IndexLSH.h +4 -16
- data/vendor/faiss/faiss/IndexLattice.cpp +7 -1
- data/vendor/faiss/faiss/IndexLattice.h +3 -1
- data/vendor/faiss/faiss/IndexNNDescent.cpp +4 -5
- data/vendor/faiss/faiss/IndexNNDescent.h +2 -1
- data/vendor/faiss/faiss/IndexNSG.cpp +37 -5
- data/vendor/faiss/faiss/IndexNSG.h +25 -1
- data/vendor/faiss/faiss/IndexPQ.cpp +108 -120
- data/vendor/faiss/faiss/IndexPQ.h +21 -22
- data/vendor/faiss/faiss/IndexPQFastScan.cpp +15 -450
- data/vendor/faiss/faiss/IndexPQFastScan.h +15 -78
- data/vendor/faiss/faiss/IndexPreTransform.cpp +47 -8
- data/vendor/faiss/faiss/IndexPreTransform.h +15 -3
- data/vendor/faiss/faiss/IndexRefine.cpp +36 -4
- data/vendor/faiss/faiss/IndexRefine.h +14 -2
- data/vendor/faiss/faiss/IndexReplicas.cpp +4 -2
- data/vendor/faiss/faiss/IndexReplicas.h +2 -1
- data/vendor/faiss/faiss/IndexRowwiseMinMax.cpp +438 -0
- data/vendor/faiss/faiss/IndexRowwiseMinMax.h +92 -0
- data/vendor/faiss/faiss/IndexScalarQuantizer.cpp +28 -43
- data/vendor/faiss/faiss/IndexScalarQuantizer.h +8 -23
- data/vendor/faiss/faiss/IndexShards.cpp +4 -1
- data/vendor/faiss/faiss/IndexShards.h +2 -1
- data/vendor/faiss/faiss/MetaIndexes.cpp +5 -178
- data/vendor/faiss/faiss/MetaIndexes.h +3 -81
- data/vendor/faiss/faiss/VectorTransform.cpp +45 -1
- data/vendor/faiss/faiss/VectorTransform.h +25 -4
- data/vendor/faiss/faiss/clone_index.cpp +26 -3
- data/vendor/faiss/faiss/clone_index.h +3 -0
- data/vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h +300 -0
- data/vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h +24 -0
- data/vendor/faiss/faiss/cppcontrib/detail/UintReader.h +195 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h +2058 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h +408 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h +2147 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMax-inl.h +460 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/MinMaxFP16-inl.h +465 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h +1618 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h +251 -0
- data/vendor/faiss/faiss/cppcontrib/sa_decode/PQ-neon-inl.h +1452 -0
- data/vendor/faiss/faiss/gpu/GpuAutoTune.cpp +1 -0
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +2 -6
- data/vendor/faiss/faiss/gpu/GpuIcmEncoder.h +60 -0
- data/vendor/faiss/faiss/gpu/GpuIndex.h +28 -4
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +2 -1
- data/vendor/faiss/faiss/gpu/GpuIndexFlat.h +10 -8
- data/vendor/faiss/faiss/gpu/GpuIndexIVF.h +75 -14
- data/vendor/faiss/faiss/gpu/GpuIndexIVFFlat.h +19 -32
- data/vendor/faiss/faiss/gpu/GpuIndexIVFPQ.h +22 -31
- data/vendor/faiss/faiss/gpu/GpuIndexIVFScalarQuantizer.h +22 -28
- data/vendor/faiss/faiss/gpu/GpuResources.cpp +14 -0
- data/vendor/faiss/faiss/gpu/GpuResources.h +16 -3
- data/vendor/faiss/faiss/gpu/StandardGpuResources.cpp +3 -3
- data/vendor/faiss/faiss/gpu/impl/IndexUtils.h +32 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexBinaryFlat.cpp +1 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexFlat.cpp +311 -75
- data/vendor/faiss/faiss/gpu/test/TestUtils.cpp +10 -0
- data/vendor/faiss/faiss/gpu/test/TestUtils.h +3 -0
- data/vendor/faiss/faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp +2 -2
- data/vendor/faiss/faiss/gpu/utils/DeviceUtils.h +5 -4
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +331 -29
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +110 -19
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +0 -54
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +0 -76
- data/vendor/faiss/faiss/impl/DistanceComputer.h +64 -0
- data/vendor/faiss/faiss/impl/HNSW.cpp +133 -32
- data/vendor/faiss/faiss/impl/HNSW.h +19 -16
- data/vendor/faiss/faiss/impl/IDSelector.cpp +125 -0
- data/vendor/faiss/faiss/impl/IDSelector.h +135 -0
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +378 -217
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +106 -29
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +77 -0
- data/vendor/faiss/faiss/impl/NNDescent.cpp +1 -0
- data/vendor/faiss/faiss/impl/NSG.cpp +1 -4
- data/vendor/faiss/faiss/impl/NSG.h +1 -1
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +383 -0
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +154 -0
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +225 -145
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +29 -10
- data/vendor/faiss/faiss/impl/Quantizer.h +43 -0
- data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +521 -55
- data/vendor/faiss/faiss/impl/ResidualQuantizer.h +94 -16
- data/vendor/faiss/faiss/impl/ResultHandler.h +96 -0
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +108 -191
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +18 -18
- data/vendor/faiss/faiss/impl/index_read.cpp +338 -24
- data/vendor/faiss/faiss/impl/index_write.cpp +300 -18
- data/vendor/faiss/faiss/impl/io.cpp +1 -1
- data/vendor/faiss/faiss/impl/io_macros.h +20 -0
- data/vendor/faiss/faiss/impl/kmeans1d.cpp +303 -0
- data/vendor/faiss/faiss/impl/kmeans1d.h +48 -0
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +56 -16
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +25 -8
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +66 -25
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +75 -27
- data/vendor/faiss/faiss/index_factory.cpp +772 -412
- data/vendor/faiss/faiss/index_factory.h +3 -0
- data/vendor/faiss/faiss/index_io.h +5 -0
- data/vendor/faiss/faiss/invlists/DirectMap.cpp +1 -0
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +4 -1
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +2 -1
- data/vendor/faiss/faiss/python/python_callbacks.cpp +27 -0
- data/vendor/faiss/faiss/python/python_callbacks.h +15 -0
- data/vendor/faiss/faiss/utils/Heap.h +31 -15
- data/vendor/faiss/faiss/utils/distances.cpp +384 -58
- data/vendor/faiss/faiss/utils/distances.h +149 -18
- data/vendor/faiss/faiss/utils/distances_simd.cpp +776 -6
- data/vendor/faiss/faiss/utils/extra_distances.cpp +12 -7
- data/vendor/faiss/faiss/utils/extra_distances.h +3 -1
- data/vendor/faiss/faiss/utils/fp16-fp16c.h +21 -0
- data/vendor/faiss/faiss/utils/fp16-inl.h +101 -0
- data/vendor/faiss/faiss/utils/fp16.h +11 -0
- data/vendor/faiss/faiss/utils/hamming-inl.h +54 -0
- data/vendor/faiss/faiss/utils/hamming.cpp +0 -48
- data/vendor/faiss/faiss/utils/ordered_key_value.h +10 -0
- data/vendor/faiss/faiss/utils/quantize_lut.cpp +62 -0
- data/vendor/faiss/faiss/utils/quantize_lut.h +20 -0
- data/vendor/faiss/faiss/utils/random.cpp +53 -0
- data/vendor/faiss/faiss/utils/random.h +5 -0
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +4 -0
- data/vendor/faiss/faiss/utils/simdlib_emulated.h +6 -1
- data/vendor/faiss/faiss/utils/simdlib_neon.h +7 -2
- data/vendor/faiss/faiss/utils/utils.h +1 -1
- metadata +46 -5
- data/vendor/faiss/faiss/IndexResidual.cpp +0 -291
- data/vendor/faiss/faiss/IndexResidual.h +0 -152
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: faiss
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Kane
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-12-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rice
|
|
@@ -71,6 +71,10 @@ files:
|
|
|
71
71
|
- vendor/faiss/faiss/Index.h
|
|
72
72
|
- vendor/faiss/faiss/Index2Layer.cpp
|
|
73
73
|
- vendor/faiss/faiss/Index2Layer.h
|
|
74
|
+
- vendor/faiss/faiss/IndexAdditiveQuantizer.cpp
|
|
75
|
+
- vendor/faiss/faiss/IndexAdditiveQuantizer.h
|
|
76
|
+
- vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp
|
|
77
|
+
- vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h
|
|
74
78
|
- vendor/faiss/faiss/IndexBinary.cpp
|
|
75
79
|
- vendor/faiss/faiss/IndexBinary.h
|
|
76
80
|
- vendor/faiss/faiss/IndexBinaryFlat.cpp
|
|
@@ -83,12 +87,24 @@ files:
|
|
|
83
87
|
- vendor/faiss/faiss/IndexBinaryHash.h
|
|
84
88
|
- vendor/faiss/faiss/IndexBinaryIVF.cpp
|
|
85
89
|
- vendor/faiss/faiss/IndexBinaryIVF.h
|
|
90
|
+
- vendor/faiss/faiss/IndexFastScan.cpp
|
|
91
|
+
- vendor/faiss/faiss/IndexFastScan.h
|
|
86
92
|
- vendor/faiss/faiss/IndexFlat.cpp
|
|
87
93
|
- vendor/faiss/faiss/IndexFlat.h
|
|
94
|
+
- vendor/faiss/faiss/IndexFlatCodes.cpp
|
|
95
|
+
- vendor/faiss/faiss/IndexFlatCodes.h
|
|
88
96
|
- vendor/faiss/faiss/IndexHNSW.cpp
|
|
89
97
|
- vendor/faiss/faiss/IndexHNSW.h
|
|
98
|
+
- vendor/faiss/faiss/IndexIDMap.cpp
|
|
99
|
+
- vendor/faiss/faiss/IndexIDMap.h
|
|
90
100
|
- vendor/faiss/faiss/IndexIVF.cpp
|
|
91
101
|
- vendor/faiss/faiss/IndexIVF.h
|
|
102
|
+
- vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp
|
|
103
|
+
- vendor/faiss/faiss/IndexIVFAdditiveQuantizer.h
|
|
104
|
+
- vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp
|
|
105
|
+
- vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h
|
|
106
|
+
- vendor/faiss/faiss/IndexIVFFastScan.cpp
|
|
107
|
+
- vendor/faiss/faiss/IndexIVFFastScan.h
|
|
92
108
|
- vendor/faiss/faiss/IndexIVFFlat.cpp
|
|
93
109
|
- vendor/faiss/faiss/IndexIVFFlat.h
|
|
94
110
|
- vendor/faiss/faiss/IndexIVFPQ.cpp
|
|
@@ -117,8 +133,8 @@ files:
|
|
|
117
133
|
- vendor/faiss/faiss/IndexRefine.h
|
|
118
134
|
- vendor/faiss/faiss/IndexReplicas.cpp
|
|
119
135
|
- vendor/faiss/faiss/IndexReplicas.h
|
|
120
|
-
- vendor/faiss/faiss/
|
|
121
|
-
- vendor/faiss/faiss/
|
|
136
|
+
- vendor/faiss/faiss/IndexRowwiseMinMax.cpp
|
|
137
|
+
- vendor/faiss/faiss/IndexRowwiseMinMax.h
|
|
122
138
|
- vendor/faiss/faiss/IndexScalarQuantizer.cpp
|
|
123
139
|
- vendor/faiss/faiss/IndexScalarQuantizer.h
|
|
124
140
|
- vendor/faiss/faiss/IndexShards.cpp
|
|
@@ -132,6 +148,17 @@ files:
|
|
|
132
148
|
- vendor/faiss/faiss/VectorTransform.h
|
|
133
149
|
- vendor/faiss/faiss/clone_index.cpp
|
|
134
150
|
- vendor/faiss/faiss/clone_index.h
|
|
151
|
+
- vendor/faiss/faiss/cppcontrib/SaDecodeKernels.h
|
|
152
|
+
- vendor/faiss/faiss/cppcontrib/detail/CoarseBitType.h
|
|
153
|
+
- vendor/faiss/faiss/cppcontrib/detail/UintReader.h
|
|
154
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/Level2-avx2-inl.h
|
|
155
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/Level2-inl.h
|
|
156
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/Level2-neon-inl.h
|
|
157
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/MinMax-inl.h
|
|
158
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/MinMaxFP16-inl.h
|
|
159
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/PQ-avx2-inl.h
|
|
160
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/PQ-inl.h
|
|
161
|
+
- vendor/faiss/faiss/cppcontrib/sa_decode/PQ-neon-inl.h
|
|
135
162
|
- vendor/faiss/faiss/gpu/GpuAutoTune.cpp
|
|
136
163
|
- vendor/faiss/faiss/gpu/GpuAutoTune.h
|
|
137
164
|
- vendor/faiss/faiss/gpu/GpuCloner.cpp
|
|
@@ -140,6 +167,7 @@ files:
|
|
|
140
167
|
- vendor/faiss/faiss/gpu/GpuClonerOptions.h
|
|
141
168
|
- vendor/faiss/faiss/gpu/GpuDistance.h
|
|
142
169
|
- vendor/faiss/faiss/gpu/GpuFaissAssert.h
|
|
170
|
+
- vendor/faiss/faiss/gpu/GpuIcmEncoder.h
|
|
143
171
|
- vendor/faiss/faiss/gpu/GpuIndex.h
|
|
144
172
|
- vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h
|
|
145
173
|
- vendor/faiss/faiss/gpu/GpuIndexFlat.h
|
|
@@ -152,6 +180,7 @@ files:
|
|
|
152
180
|
- vendor/faiss/faiss/gpu/GpuResources.h
|
|
153
181
|
- vendor/faiss/faiss/gpu/StandardGpuResources.cpp
|
|
154
182
|
- vendor/faiss/faiss/gpu/StandardGpuResources.h
|
|
183
|
+
- vendor/faiss/faiss/gpu/impl/IndexUtils.h
|
|
155
184
|
- vendor/faiss/faiss/gpu/impl/InterleavedCodes.cpp
|
|
156
185
|
- vendor/faiss/faiss/gpu/impl/InterleavedCodes.h
|
|
157
186
|
- vendor/faiss/faiss/gpu/impl/RemapIndices.cpp
|
|
@@ -181,22 +210,29 @@ files:
|
|
|
181
210
|
- vendor/faiss/faiss/impl/AdditiveQuantizer.h
|
|
182
211
|
- vendor/faiss/faiss/impl/AuxIndexStructures.cpp
|
|
183
212
|
- vendor/faiss/faiss/impl/AuxIndexStructures.h
|
|
213
|
+
- vendor/faiss/faiss/impl/DistanceComputer.h
|
|
184
214
|
- vendor/faiss/faiss/impl/FaissAssert.h
|
|
185
215
|
- vendor/faiss/faiss/impl/FaissException.cpp
|
|
186
216
|
- vendor/faiss/faiss/impl/FaissException.h
|
|
187
217
|
- vendor/faiss/faiss/impl/HNSW.cpp
|
|
188
218
|
- vendor/faiss/faiss/impl/HNSW.h
|
|
219
|
+
- vendor/faiss/faiss/impl/IDSelector.cpp
|
|
220
|
+
- vendor/faiss/faiss/impl/IDSelector.h
|
|
189
221
|
- vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp
|
|
190
222
|
- vendor/faiss/faiss/impl/LocalSearchQuantizer.h
|
|
223
|
+
- vendor/faiss/faiss/impl/LookupTableScaler.h
|
|
191
224
|
- vendor/faiss/faiss/impl/NNDescent.cpp
|
|
192
225
|
- vendor/faiss/faiss/impl/NNDescent.h
|
|
193
226
|
- vendor/faiss/faiss/impl/NSG.cpp
|
|
194
227
|
- vendor/faiss/faiss/impl/NSG.h
|
|
195
228
|
- vendor/faiss/faiss/impl/PolysemousTraining.cpp
|
|
196
229
|
- vendor/faiss/faiss/impl/PolysemousTraining.h
|
|
230
|
+
- vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp
|
|
231
|
+
- vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h
|
|
197
232
|
- vendor/faiss/faiss/impl/ProductQuantizer-inl.h
|
|
198
233
|
- vendor/faiss/faiss/impl/ProductQuantizer.cpp
|
|
199
234
|
- vendor/faiss/faiss/impl/ProductQuantizer.h
|
|
235
|
+
- vendor/faiss/faiss/impl/Quantizer.h
|
|
200
236
|
- vendor/faiss/faiss/impl/ResidualQuantizer.cpp
|
|
201
237
|
- vendor/faiss/faiss/impl/ResidualQuantizer.h
|
|
202
238
|
- vendor/faiss/faiss/impl/ResultHandler.h
|
|
@@ -209,6 +245,8 @@ files:
|
|
|
209
245
|
- vendor/faiss/faiss/impl/io.cpp
|
|
210
246
|
- vendor/faiss/faiss/impl/io.h
|
|
211
247
|
- vendor/faiss/faiss/impl/io_macros.h
|
|
248
|
+
- vendor/faiss/faiss/impl/kmeans1d.cpp
|
|
249
|
+
- vendor/faiss/faiss/impl/kmeans1d.h
|
|
212
250
|
- vendor/faiss/faiss/impl/lattice_Zn.cpp
|
|
213
251
|
- vendor/faiss/faiss/impl/lattice_Zn.h
|
|
214
252
|
- vendor/faiss/faiss/impl/platform_macros.h
|
|
@@ -243,6 +281,9 @@ files:
|
|
|
243
281
|
- vendor/faiss/faiss/utils/extra_distances-inl.h
|
|
244
282
|
- vendor/faiss/faiss/utils/extra_distances.cpp
|
|
245
283
|
- vendor/faiss/faiss/utils/extra_distances.h
|
|
284
|
+
- vendor/faiss/faiss/utils/fp16-fp16c.h
|
|
285
|
+
- vendor/faiss/faiss/utils/fp16-inl.h
|
|
286
|
+
- vendor/faiss/faiss/utils/fp16.h
|
|
246
287
|
- vendor/faiss/faiss/utils/hamming-inl.h
|
|
247
288
|
- vendor/faiss/faiss/utils/hamming.cpp
|
|
248
289
|
- vendor/faiss/faiss/utils/hamming.h
|
|
@@ -278,7 +319,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
278
319
|
- !ruby/object:Gem::Version
|
|
279
320
|
version: '0'
|
|
280
321
|
requirements: []
|
|
281
|
-
rubygems_version: 3.
|
|
322
|
+
rubygems_version: 3.4.1
|
|
282
323
|
signing_key:
|
|
283
324
|
specification_version: 4
|
|
284
325
|
summary: Efficient similarity search and clustering for Ruby
|
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
#include <faiss/IndexResidual.h>
|
|
9
|
-
|
|
10
|
-
#include <algorithm>
|
|
11
|
-
#include <cmath>
|
|
12
|
-
#include <cstring>
|
|
13
|
-
|
|
14
|
-
#include <faiss/impl/FaissAssert.h>
|
|
15
|
-
#include <faiss/impl/ResultHandler.h>
|
|
16
|
-
#include <faiss/utils/distances.h>
|
|
17
|
-
#include <faiss/utils/extra_distances.h>
|
|
18
|
-
#include <faiss/utils/utils.h>
|
|
19
|
-
|
|
20
|
-
namespace faiss {
|
|
21
|
-
|
|
22
|
-
/**************************************************************************************
|
|
23
|
-
* IndexResidual
|
|
24
|
-
**************************************************************************************/
|
|
25
|
-
|
|
26
|
-
IndexResidual::IndexResidual(
|
|
27
|
-
int d, ///< dimensionality of the input vectors
|
|
28
|
-
size_t M, ///< number of subquantizers
|
|
29
|
-
size_t nbits, ///< number of bit per subvector index
|
|
30
|
-
MetricType metric,
|
|
31
|
-
Search_type_t search_type_in)
|
|
32
|
-
: Index(d, metric), rq(d, M, nbits), search_type(ST_decompress) {
|
|
33
|
-
is_trained = false;
|
|
34
|
-
norm_max = norm_min = NAN;
|
|
35
|
-
set_search_type(search_type_in);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
IndexResidual::IndexResidual(
|
|
39
|
-
int d,
|
|
40
|
-
const std::vector<size_t>& nbits,
|
|
41
|
-
MetricType metric,
|
|
42
|
-
Search_type_t search_type_in)
|
|
43
|
-
: Index(d, metric), rq(d, nbits), search_type(ST_decompress) {
|
|
44
|
-
is_trained = false;
|
|
45
|
-
norm_max = norm_min = NAN;
|
|
46
|
-
set_search_type(search_type_in);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
IndexResidual::IndexResidual() : IndexResidual(0, 0, 0) {}
|
|
50
|
-
|
|
51
|
-
void IndexResidual::set_search_type(Search_type_t new_search_type) {
|
|
52
|
-
int norm_bits = new_search_type == ST_norm_float ? 32
|
|
53
|
-
: new_search_type == ST_norm_qint8 ? 8
|
|
54
|
-
: 0;
|
|
55
|
-
|
|
56
|
-
FAISS_THROW_IF_NOT(ntotal == 0);
|
|
57
|
-
|
|
58
|
-
search_type = new_search_type;
|
|
59
|
-
code_size = (rq.tot_bits + norm_bits + 7) / 8;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
void IndexResidual::train(idx_t n, const float* x) {
|
|
63
|
-
rq.train(n, x);
|
|
64
|
-
|
|
65
|
-
std::vector<float> norms(n);
|
|
66
|
-
fvec_norms_L2sqr(norms.data(), x, d, n);
|
|
67
|
-
|
|
68
|
-
norm_min = HUGE_VALF;
|
|
69
|
-
norm_max = -HUGE_VALF;
|
|
70
|
-
for (idx_t i = 0; i < n; i++) {
|
|
71
|
-
if (norms[i] < norm_min) {
|
|
72
|
-
norm_min = norms[i];
|
|
73
|
-
}
|
|
74
|
-
if (norms[i] > norm_min) {
|
|
75
|
-
norm_max = norms[i];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
is_trained = true;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
void IndexResidual::add(idx_t n, const float* x) {
|
|
83
|
-
FAISS_THROW_IF_NOT(is_trained);
|
|
84
|
-
codes.resize((n + ntotal) * rq.code_size);
|
|
85
|
-
if (search_type == ST_decompress || search_type == ST_LUT_nonorm) {
|
|
86
|
-
rq.compute_codes(x, &codes[ntotal * rq.code_size], n);
|
|
87
|
-
} else {
|
|
88
|
-
// should compute codes + compute and quantize norms
|
|
89
|
-
FAISS_THROW_MSG("not implemented");
|
|
90
|
-
}
|
|
91
|
-
ntotal += n;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
namespace {
|
|
95
|
-
|
|
96
|
-
template <class VectorDistance, class ResultHandler>
|
|
97
|
-
void search_with_decompress(
|
|
98
|
-
const IndexResidual& ir,
|
|
99
|
-
const float* xq,
|
|
100
|
-
VectorDistance& vd,
|
|
101
|
-
ResultHandler& res) {
|
|
102
|
-
const uint8_t* codes = ir.codes.data();
|
|
103
|
-
size_t ntotal = ir.ntotal;
|
|
104
|
-
size_t code_size = ir.code_size;
|
|
105
|
-
|
|
106
|
-
using SingleResultHandler = typename ResultHandler::SingleResultHandler;
|
|
107
|
-
|
|
108
|
-
#pragma omp parallel for
|
|
109
|
-
for (int64_t q = 0; q < res.nq; q++) {
|
|
110
|
-
SingleResultHandler resi(res);
|
|
111
|
-
resi.begin(q);
|
|
112
|
-
std::vector<float> tmp(ir.d);
|
|
113
|
-
const float* x = xq + ir.d * q;
|
|
114
|
-
for (size_t i = 0; i < ntotal; i++) {
|
|
115
|
-
ir.rq.decode(codes + i * code_size, tmp.data(), 1);
|
|
116
|
-
float dis = vd(x, tmp.data());
|
|
117
|
-
resi.add_result(dis, i);
|
|
118
|
-
}
|
|
119
|
-
resi.end();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
} // anonymous namespace
|
|
124
|
-
|
|
125
|
-
void IndexResidual::search(
|
|
126
|
-
idx_t n,
|
|
127
|
-
const float* x,
|
|
128
|
-
idx_t k,
|
|
129
|
-
float* distances,
|
|
130
|
-
idx_t* labels) const {
|
|
131
|
-
if (search_type == ST_decompress) {
|
|
132
|
-
if (metric_type == METRIC_L2) {
|
|
133
|
-
using VD = VectorDistance<METRIC_L2>;
|
|
134
|
-
VD vd = {size_t(d), metric_arg};
|
|
135
|
-
HeapResultHandler<VD::C> rh(n, distances, labels, k);
|
|
136
|
-
search_with_decompress(*this, x, vd, rh);
|
|
137
|
-
} else if (metric_type == METRIC_INNER_PRODUCT) {
|
|
138
|
-
using VD = VectorDistance<METRIC_INNER_PRODUCT>;
|
|
139
|
-
VD vd = {size_t(d), metric_arg};
|
|
140
|
-
HeapResultHandler<VD::C> rh(n, distances, labels, k);
|
|
141
|
-
search_with_decompress(*this, x, vd, rh);
|
|
142
|
-
}
|
|
143
|
-
} else {
|
|
144
|
-
FAISS_THROW_MSG("not implemented");
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
void IndexResidual::reset() {
|
|
149
|
-
codes.clear();
|
|
150
|
-
ntotal = 0;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
size_t IndexResidual::sa_code_size() const {
|
|
154
|
-
return code_size;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
void IndexResidual::sa_encode(idx_t n, const float* x, uint8_t* bytes) const {
|
|
158
|
-
return rq.compute_codes(x, bytes, n);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
void IndexResidual::sa_decode(idx_t n, const uint8_t* bytes, float* x) const {
|
|
162
|
-
return rq.decode(bytes, x, n);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**************************************************************************************
|
|
166
|
-
* ResidualCoarseQuantizer
|
|
167
|
-
**************************************************************************************/
|
|
168
|
-
|
|
169
|
-
ResidualCoarseQuantizer::ResidualCoarseQuantizer(
|
|
170
|
-
int d, ///< dimensionality of the input vectors
|
|
171
|
-
size_t M, ///< number of subquantizers
|
|
172
|
-
size_t nbits, ///< number of bit per subvector index
|
|
173
|
-
MetricType metric)
|
|
174
|
-
: Index(d, metric), rq(d, M, nbits), beam_factor(4.0) {
|
|
175
|
-
FAISS_THROW_IF_NOT(rq.tot_bits <= 63);
|
|
176
|
-
is_trained = false;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
ResidualCoarseQuantizer::ResidualCoarseQuantizer(
|
|
180
|
-
int d,
|
|
181
|
-
const std::vector<size_t>& nbits,
|
|
182
|
-
MetricType metric)
|
|
183
|
-
: Index(d, metric), rq(d, nbits), beam_factor(4.0) {
|
|
184
|
-
FAISS_THROW_IF_NOT(rq.tot_bits <= 63);
|
|
185
|
-
is_trained = false;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
ResidualCoarseQuantizer::ResidualCoarseQuantizer() {}
|
|
189
|
-
|
|
190
|
-
void ResidualCoarseQuantizer::train(idx_t n, const float* x) {
|
|
191
|
-
rq.train(n, x);
|
|
192
|
-
is_trained = true;
|
|
193
|
-
ntotal = (idx_t)1 << rq.tot_bits;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
void ResidualCoarseQuantizer::add(idx_t, const float*) {
|
|
197
|
-
FAISS_THROW_MSG("not applicable");
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
void ResidualCoarseQuantizer::set_beam_factor(float new_beam_factor) {
|
|
201
|
-
centroid_norms.resize(0);
|
|
202
|
-
beam_factor = new_beam_factor;
|
|
203
|
-
if (new_beam_factor > 0) {
|
|
204
|
-
FAISS_THROW_IF_NOT(new_beam_factor >= 1.0);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (metric_type == METRIC_L2) {
|
|
209
|
-
centroid_norms.resize((size_t)1 << rq.tot_bits);
|
|
210
|
-
rq.compute_centroid_norms(centroid_norms.data());
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
void ResidualCoarseQuantizer::search(
|
|
215
|
-
idx_t n,
|
|
216
|
-
const float* x,
|
|
217
|
-
idx_t k,
|
|
218
|
-
float* distances,
|
|
219
|
-
idx_t* labels) const {
|
|
220
|
-
if (beam_factor < 0) {
|
|
221
|
-
if (metric_type == METRIC_INNER_PRODUCT) {
|
|
222
|
-
rq.knn_exact_inner_product(n, x, k, distances, labels);
|
|
223
|
-
} else if (metric_type == METRIC_L2) {
|
|
224
|
-
FAISS_THROW_IF_NOT(centroid_norms.size() == ntotal);
|
|
225
|
-
rq.knn_exact_L2(n, x, k, distances, labels, centroid_norms.data());
|
|
226
|
-
}
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
int beam_size = int(k * beam_factor);
|
|
231
|
-
|
|
232
|
-
size_t memory_per_point = rq.memory_per_point(beam_size);
|
|
233
|
-
|
|
234
|
-
/*
|
|
235
|
-
|
|
236
|
-
printf("mem per point %ld n=%d max_mem_distance=%ld mem_kb=%zd\n",
|
|
237
|
-
memory_per_point, int(n), rq.max_mem_distances, get_mem_usage_kb());
|
|
238
|
-
*/
|
|
239
|
-
if (n > 1 && memory_per_point * n > rq.max_mem_distances) {
|
|
240
|
-
// then split queries to reduce temp memory
|
|
241
|
-
idx_t bs = rq.max_mem_distances / memory_per_point;
|
|
242
|
-
if (bs == 0) {
|
|
243
|
-
bs = 1; // otherwise we can't do much
|
|
244
|
-
}
|
|
245
|
-
if (verbose) {
|
|
246
|
-
printf("ResidualCoarseQuantizer::search: run %d searches in batches of size %d\n",
|
|
247
|
-
int(n),
|
|
248
|
-
int(bs));
|
|
249
|
-
}
|
|
250
|
-
for (idx_t i0 = 0; i0 < n; i0 += bs) {
|
|
251
|
-
idx_t i1 = std::min(n, i0 + bs);
|
|
252
|
-
search(i1 - i0, x + i0 * d, k, distances + i0 * k, labels + i0 * k);
|
|
253
|
-
InterruptCallback::check();
|
|
254
|
-
}
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
std::vector<int32_t> codes(beam_size * rq.M * n);
|
|
259
|
-
std::vector<float> beam_distances(n * beam_size);
|
|
260
|
-
|
|
261
|
-
rq.refine_beam(
|
|
262
|
-
n, 1, x, beam_size, codes.data(), nullptr, beam_distances.data());
|
|
263
|
-
|
|
264
|
-
#pragma omp parallel for if (n > 4000)
|
|
265
|
-
for (idx_t i = 0; i < n; i++) {
|
|
266
|
-
memcpy(distances + i * k,
|
|
267
|
-
beam_distances.data() + beam_size * i,
|
|
268
|
-
k * sizeof(distances[0]));
|
|
269
|
-
|
|
270
|
-
const int32_t* codes_i = codes.data() + beam_size * i * rq.M;
|
|
271
|
-
for (idx_t j = 0; j < k; j++) {
|
|
272
|
-
idx_t l = 0;
|
|
273
|
-
int shift = 0;
|
|
274
|
-
for (int m = 0; m < rq.M; m++) {
|
|
275
|
-
l |= (*codes_i++) << shift;
|
|
276
|
-
shift += rq.nbits[m];
|
|
277
|
-
}
|
|
278
|
-
labels[i * k + j] = l;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
void ResidualCoarseQuantizer::reconstruct(idx_t key, float* recons) const {
|
|
284
|
-
rq.decode_64bit(key, recons);
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
void ResidualCoarseQuantizer::reset() {
|
|
288
|
-
FAISS_THROW_MSG("not applicable");
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
} // namespace faiss
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
#ifndef FAISS_INDEX_RESIDUAL_H
|
|
9
|
-
#define FAISS_INDEX_RESIDUAL_H
|
|
10
|
-
|
|
11
|
-
#include <stdint.h>
|
|
12
|
-
|
|
13
|
-
#include <vector>
|
|
14
|
-
|
|
15
|
-
#include <faiss/Index.h>
|
|
16
|
-
#include <faiss/impl/ResidualQuantizer.h>
|
|
17
|
-
#include <faiss/impl/platform_macros.h>
|
|
18
|
-
|
|
19
|
-
namespace faiss {
|
|
20
|
-
|
|
21
|
-
/** Index based on a residual quantizer. Stored vectors are
|
|
22
|
-
* approximated by residual quantization codes.
|
|
23
|
-
* Can also be used as a codec
|
|
24
|
-
*/
|
|
25
|
-
struct IndexResidual : Index {
|
|
26
|
-
/// The residual quantizer used to encode the vectors
|
|
27
|
-
ResidualQuantizer rq;
|
|
28
|
-
|
|
29
|
-
enum Search_type_t {
|
|
30
|
-
ST_decompress, ///< decompress database vector
|
|
31
|
-
ST_LUT_nonorm, ///< use a LUT, don't include norms (OK for IP or
|
|
32
|
-
///< normalized vectors)
|
|
33
|
-
ST_norm_float, ///< use a LUT, and store float32 norm with the vectors
|
|
34
|
-
ST_norm_qint8, ///< use a LUT, and store 8bit-quantized norm
|
|
35
|
-
};
|
|
36
|
-
Search_type_t search_type;
|
|
37
|
-
|
|
38
|
-
/// min/max for quantization of norms
|
|
39
|
-
float norm_min, norm_max;
|
|
40
|
-
|
|
41
|
-
/// size of residual quantizer codes + norms
|
|
42
|
-
size_t code_size;
|
|
43
|
-
|
|
44
|
-
/// Codes. Size ntotal * rq.code_size
|
|
45
|
-
std::vector<uint8_t> codes;
|
|
46
|
-
|
|
47
|
-
/** Constructor.
|
|
48
|
-
*
|
|
49
|
-
* @param d dimensionality of the input vectors
|
|
50
|
-
* @param M number of subquantizers
|
|
51
|
-
* @param nbits number of bit per subvector index
|
|
52
|
-
*/
|
|
53
|
-
IndexResidual(
|
|
54
|
-
int d, ///< dimensionality of the input vectors
|
|
55
|
-
size_t M, ///< number of subquantizers
|
|
56
|
-
size_t nbits, ///< number of bit per subvector index
|
|
57
|
-
MetricType metric = METRIC_L2,
|
|
58
|
-
Search_type_t search_type = ST_decompress);
|
|
59
|
-
|
|
60
|
-
IndexResidual(
|
|
61
|
-
int d,
|
|
62
|
-
const std::vector<size_t>& nbits,
|
|
63
|
-
MetricType metric = METRIC_L2,
|
|
64
|
-
Search_type_t search_type = ST_decompress);
|
|
65
|
-
|
|
66
|
-
IndexResidual();
|
|
67
|
-
|
|
68
|
-
/// set search type and update parameters
|
|
69
|
-
void set_search_type(Search_type_t search_type);
|
|
70
|
-
|
|
71
|
-
void train(idx_t n, const float* x) override;
|
|
72
|
-
|
|
73
|
-
void add(idx_t n, const float* x) override;
|
|
74
|
-
|
|
75
|
-
/// not implemented
|
|
76
|
-
void search(
|
|
77
|
-
idx_t n,
|
|
78
|
-
const float* x,
|
|
79
|
-
idx_t k,
|
|
80
|
-
float* distances,
|
|
81
|
-
idx_t* labels) const override;
|
|
82
|
-
|
|
83
|
-
void reset() override;
|
|
84
|
-
|
|
85
|
-
/* The standalone codec interface */
|
|
86
|
-
size_t sa_code_size() const override;
|
|
87
|
-
|
|
88
|
-
void sa_encode(idx_t n, const float* x, uint8_t* bytes) const override;
|
|
89
|
-
|
|
90
|
-
void sa_decode(idx_t n, const uint8_t* bytes, float* x) const override;
|
|
91
|
-
|
|
92
|
-
// DistanceComputer* get_distance_computer() const override;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/** A "virtual" index where the elements are the residual quantizer centroids.
|
|
96
|
-
*
|
|
97
|
-
* Intended for use as a coarse quantizer in an IndexIVF.
|
|
98
|
-
*/
|
|
99
|
-
struct ResidualCoarseQuantizer : Index {
|
|
100
|
-
/// The residual quantizer used to encode the vectors
|
|
101
|
-
ResidualQuantizer rq;
|
|
102
|
-
|
|
103
|
-
/// factor between the beam size and the search k
|
|
104
|
-
/// if negative, use exact search-to-centroid
|
|
105
|
-
float beam_factor;
|
|
106
|
-
|
|
107
|
-
/// norms of centroids, useful for knn-search
|
|
108
|
-
std::vector<float> centroid_norms;
|
|
109
|
-
|
|
110
|
-
/// computes centroid norms if required
|
|
111
|
-
void set_beam_factor(float new_beam_factor);
|
|
112
|
-
|
|
113
|
-
/** Constructor.
|
|
114
|
-
*
|
|
115
|
-
* @param d dimensionality of the input vectors
|
|
116
|
-
* @param M number of subquantizers
|
|
117
|
-
* @param nbits number of bit per subvector index
|
|
118
|
-
*/
|
|
119
|
-
ResidualCoarseQuantizer(
|
|
120
|
-
int d, ///< dimensionality of the input vectors
|
|
121
|
-
size_t M, ///< number of subquantizers
|
|
122
|
-
size_t nbits, ///< number of bit per subvector index
|
|
123
|
-
MetricType metric = METRIC_L2);
|
|
124
|
-
|
|
125
|
-
ResidualCoarseQuantizer(
|
|
126
|
-
int d,
|
|
127
|
-
const std::vector<size_t>& nbits,
|
|
128
|
-
MetricType metric = METRIC_L2);
|
|
129
|
-
|
|
130
|
-
ResidualCoarseQuantizer();
|
|
131
|
-
|
|
132
|
-
void train(idx_t n, const float* x) override;
|
|
133
|
-
|
|
134
|
-
/// N/A
|
|
135
|
-
void add(idx_t n, const float* x) override;
|
|
136
|
-
|
|
137
|
-
void search(
|
|
138
|
-
idx_t n,
|
|
139
|
-
const float* x,
|
|
140
|
-
idx_t k,
|
|
141
|
-
float* distances,
|
|
142
|
-
idx_t* labels) const override;
|
|
143
|
-
|
|
144
|
-
void reconstruct(idx_t key, float* recons) const override;
|
|
145
|
-
|
|
146
|
-
/// N/A
|
|
147
|
-
void reset() override;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
} // namespace faiss
|
|
151
|
-
|
|
152
|
-
#endif
|