faiss 0.4.3 → 0.5.0
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 +5 -0
- data/ext/faiss/index.cpp +25 -6
- data/ext/faiss/index_binary.cpp +17 -4
- data/ext/faiss/kmeans.cpp +6 -6
- data/lib/faiss/version.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +2 -3
- data/vendor/faiss/faiss/AutoTune.h +1 -1
- data/vendor/faiss/faiss/Clustering.cpp +2 -2
- data/vendor/faiss/faiss/Clustering.h +2 -2
- data/vendor/faiss/faiss/IVFlib.cpp +1 -2
- data/vendor/faiss/faiss/IVFlib.h +1 -1
- data/vendor/faiss/faiss/Index.h +10 -10
- data/vendor/faiss/faiss/Index2Layer.cpp +1 -1
- data/vendor/faiss/faiss/Index2Layer.h +2 -2
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.cpp +9 -4
- data/vendor/faiss/faiss/IndexAdditiveQuantizerFastScan.h +5 -1
- data/vendor/faiss/faiss/IndexBinary.h +7 -7
- data/vendor/faiss/faiss/IndexBinaryFromFloat.h +1 -1
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +3 -1
- data/vendor/faiss/faiss/IndexBinaryHNSW.h +1 -1
- data/vendor/faiss/faiss/IndexBinaryHash.cpp +3 -3
- data/vendor/faiss/faiss/IndexBinaryHash.h +5 -5
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +7 -6
- data/vendor/faiss/faiss/IndexFastScan.cpp +125 -49
- data/vendor/faiss/faiss/IndexFastScan.h +107 -7
- data/vendor/faiss/faiss/IndexFlat.h +1 -1
- data/vendor/faiss/faiss/IndexHNSW.cpp +3 -1
- data/vendor/faiss/faiss/IndexHNSW.h +1 -1
- data/vendor/faiss/faiss/IndexIDMap.cpp +14 -13
- data/vendor/faiss/faiss/IndexIDMap.h +6 -6
- data/vendor/faiss/faiss/IndexIVF.cpp +1 -1
- data/vendor/faiss/faiss/IndexIVF.h +5 -5
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizer.cpp +1 -1
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +9 -3
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +3 -1
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +176 -90
- data/vendor/faiss/faiss/IndexIVFFastScan.h +173 -18
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +1 -0
- data/vendor/faiss/faiss/IndexIVFFlatPanorama.cpp +366 -0
- data/vendor/faiss/faiss/IndexIVFFlatPanorama.h +64 -0
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +3 -1
- data/vendor/faiss/faiss/IndexIVFPQ.h +1 -1
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +134 -2
- data/vendor/faiss/faiss/IndexIVFPQFastScan.h +7 -1
- data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +13 -6
- data/vendor/faiss/faiss/IndexIVFRaBitQ.h +1 -0
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +650 -0
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +216 -0
- data/vendor/faiss/faiss/IndexIVFSpectralHash.cpp +1 -1
- data/vendor/faiss/faiss/IndexIVFSpectralHash.h +1 -1
- data/vendor/faiss/faiss/IndexNNDescent.cpp +1 -1
- data/vendor/faiss/faiss/IndexNSG.cpp +1 -1
- data/vendor/faiss/faiss/IndexNeuralNetCodec.h +1 -1
- data/vendor/faiss/faiss/IndexPQ.h +1 -1
- data/vendor/faiss/faiss/IndexPQFastScan.cpp +6 -2
- data/vendor/faiss/faiss/IndexPQFastScan.h +5 -1
- data/vendor/faiss/faiss/IndexRaBitQ.cpp +13 -10
- data/vendor/faiss/faiss/IndexRaBitQ.h +7 -2
- data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +586 -0
- data/vendor/faiss/faiss/IndexRaBitQFastScan.h +149 -0
- data/vendor/faiss/faiss/IndexShards.cpp +1 -1
- data/vendor/faiss/faiss/MatrixStats.cpp +3 -3
- data/vendor/faiss/faiss/MetricType.h +1 -1
- data/vendor/faiss/faiss/VectorTransform.h +2 -2
- data/vendor/faiss/faiss/clone_index.cpp +3 -1
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +1 -1
- data/vendor/faiss/faiss/gpu/GpuIndex.h +11 -11
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryCagra.h +1 -1
- data/vendor/faiss/faiss/gpu/GpuIndexBinaryFlat.h +1 -1
- data/vendor/faiss/faiss/gpu/GpuIndexCagra.h +10 -6
- data/vendor/faiss/faiss/gpu/perf/IndexWrapper-inl.h +2 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIcmEncoder.cpp +7 -0
- data/vendor/faiss/faiss/gpu/test/TestGpuIndexIVFFlat.cpp +1 -1
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +1 -1
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/AuxIndexStructures.cpp +2 -2
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +1 -1
- data/vendor/faiss/faiss/impl/CodePacker.h +2 -2
- data/vendor/faiss/faiss/impl/DistanceComputer.h +3 -3
- data/vendor/faiss/faiss/impl/FastScanDistancePostProcessing.h +53 -0
- data/vendor/faiss/faiss/impl/HNSW.cpp +1 -1
- data/vendor/faiss/faiss/impl/HNSW.h +4 -4
- data/vendor/faiss/faiss/impl/IDSelector.cpp +2 -2
- data/vendor/faiss/faiss/impl/IDSelector.h +1 -1
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +4 -4
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/LookupTableScaler.h +1 -1
- data/vendor/faiss/faiss/impl/NNDescent.cpp +1 -1
- data/vendor/faiss/faiss/impl/NNDescent.h +2 -2
- data/vendor/faiss/faiss/impl/NSG.cpp +1 -1
- data/vendor/faiss/faiss/impl/PanoramaStats.cpp +33 -0
- data/vendor/faiss/faiss/impl/PanoramaStats.h +38 -0
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +5 -5
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.cpp +1 -1
- data/vendor/faiss/faiss/impl/ProductAdditiveQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/ProductQuantizer-inl.h +2 -0
- data/vendor/faiss/faiss/impl/ProductQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/RaBitQUtils.cpp +246 -0
- data/vendor/faiss/faiss/impl/RaBitQUtils.h +153 -0
- data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +54 -158
- data/vendor/faiss/faiss/impl/RaBitQuantizer.h +2 -1
- data/vendor/faiss/faiss/impl/ResidualQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/ResultHandler.h +4 -4
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +1 -1
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +1 -1
- data/vendor/faiss/faiss/impl/ThreadedIndex-inl.h +7 -4
- data/vendor/faiss/faiss/impl/index_read.cpp +87 -3
- data/vendor/faiss/faiss/impl/index_write.cpp +73 -3
- data/vendor/faiss/faiss/impl/io.cpp +2 -2
- data/vendor/faiss/faiss/impl/io.h +4 -4
- data/vendor/faiss/faiss/impl/kmeans1d.cpp +1 -1
- data/vendor/faiss/faiss/impl/kmeans1d.h +1 -1
- data/vendor/faiss/faiss/impl/lattice_Zn.h +2 -2
- data/vendor/faiss/faiss/impl/mapped_io.cpp +2 -2
- data/vendor/faiss/faiss/impl/mapped_io.h +4 -3
- data/vendor/faiss/faiss/impl/maybe_owned_vector.h +8 -1
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +30 -4
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +14 -8
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +5 -6
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +55 -11
- data/vendor/faiss/faiss/impl/zerocopy_io.h +1 -1
- data/vendor/faiss/faiss/index_factory.cpp +43 -1
- data/vendor/faiss/faiss/index_factory.h +1 -1
- data/vendor/faiss/faiss/index_io.h +1 -1
- data/vendor/faiss/faiss/invlists/InvertedLists.cpp +205 -0
- data/vendor/faiss/faiss/invlists/InvertedLists.h +62 -0
- data/vendor/faiss/faiss/utils/AlignedTable.h +1 -1
- data/vendor/faiss/faiss/utils/Heap.cpp +2 -2
- data/vendor/faiss/faiss/utils/Heap.h +3 -3
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +1 -1
- data/vendor/faiss/faiss/utils/NeuralNet.h +3 -3
- 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/mode.h +1 -1
- data/vendor/faiss/faiss/utils/distances.h +2 -2
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +3 -1
- data/vendor/faiss/faiss/utils/hamming-inl.h +2 -0
- data/vendor/faiss/faiss/utils/hamming.cpp +7 -6
- data/vendor/faiss/faiss/utils/hamming.h +1 -1
- data/vendor/faiss/faiss/utils/hamming_distance/common.h +1 -2
- data/vendor/faiss/faiss/utils/partitioning.cpp +5 -5
- data/vendor/faiss/faiss/utils/partitioning.h +2 -2
- data/vendor/faiss/faiss/utils/rabitq_simd.h +222 -336
- data/vendor/faiss/faiss/utils/random.cpp +1 -1
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +1 -1
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +1 -1
- data/vendor/faiss/faiss/utils/simdlib_neon.h +2 -2
- data/vendor/faiss/faiss/utils/transpose/transpose-avx512-inl.h +1 -1
- data/vendor/faiss/faiss/utils/utils.cpp +5 -2
- data/vendor/faiss/faiss/utils/utils.h +2 -2
- metadata +12 -1
|
@@ -59,7 +59,7 @@ IndexIDMapTemplate<IndexT>::IndexIDMapTemplate(IndexT* index) : index(index) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
template <typename IndexT>
|
|
62
|
-
void IndexIDMapTemplate<IndexT>::
|
|
62
|
+
void IndexIDMapTemplate<IndexT>::add_ex(
|
|
63
63
|
idx_t,
|
|
64
64
|
const void*,
|
|
65
65
|
NumericType numeric_type) {
|
|
@@ -78,11 +78,11 @@ void IndexIDMapTemplate<IndexT>::add(
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
template <typename IndexT>
|
|
81
|
-
void IndexIDMapTemplate<IndexT>::
|
|
81
|
+
void IndexIDMapTemplate<IndexT>::train_ex(
|
|
82
82
|
idx_t n,
|
|
83
83
|
const void* x,
|
|
84
84
|
NumericType numeric_type) {
|
|
85
|
-
index->
|
|
85
|
+
index->train_ex(n, x, numeric_type);
|
|
86
86
|
this->is_trained = index->is_trained;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -90,7 +90,8 @@ template <typename IndexT>
|
|
|
90
90
|
void IndexIDMapTemplate<IndexT>::train(
|
|
91
91
|
idx_t n,
|
|
92
92
|
const typename IndexT::component_t* x) {
|
|
93
|
-
|
|
93
|
+
train_ex(
|
|
94
|
+
n,
|
|
94
95
|
static_cast<const void*>(x),
|
|
95
96
|
component_t_to_numeric<typename IndexT::component_t>());
|
|
96
97
|
}
|
|
@@ -103,12 +104,12 @@ void IndexIDMapTemplate<IndexT>::reset() {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
template <typename IndexT>
|
|
106
|
-
void IndexIDMapTemplate<IndexT>::
|
|
107
|
+
void IndexIDMapTemplate<IndexT>::add_with_ids_ex(
|
|
107
108
|
idx_t n,
|
|
108
109
|
const void* x,
|
|
109
110
|
NumericType numeric_type,
|
|
110
111
|
const idx_t* xids) {
|
|
111
|
-
index->
|
|
112
|
+
index->add_ex(n, x, numeric_type);
|
|
112
113
|
for (idx_t i = 0; i < n; i++) {
|
|
113
114
|
id_map.push_back(xids[i]);
|
|
114
115
|
}
|
|
@@ -120,7 +121,7 @@ void IndexIDMapTemplate<IndexT>::add_with_ids(
|
|
|
120
121
|
idx_t n,
|
|
121
122
|
const typename IndexT::component_t* x,
|
|
122
123
|
const idx_t* xids) {
|
|
123
|
-
|
|
124
|
+
add_with_ids_ex(
|
|
124
125
|
n,
|
|
125
126
|
static_cast<const void*>(x),
|
|
126
127
|
component_t_to_numeric<typename IndexT::component_t>(),
|
|
@@ -166,7 +167,7 @@ struct ScopedSelChange {
|
|
|
166
167
|
} // namespace
|
|
167
168
|
|
|
168
169
|
template <typename IndexT>
|
|
169
|
-
void IndexIDMapTemplate<IndexT>::
|
|
170
|
+
void IndexIDMapTemplate<IndexT>::search_ex(
|
|
170
171
|
idx_t n,
|
|
171
172
|
const void* x,
|
|
172
173
|
NumericType numeric_type,
|
|
@@ -193,7 +194,7 @@ void IndexIDMapTemplate<IndexT>::searchEx(
|
|
|
193
194
|
sel_change.set(params_non_const, &this_idtrans);
|
|
194
195
|
}
|
|
195
196
|
}
|
|
196
|
-
index->
|
|
197
|
+
index->search_ex(n, x, numeric_type, k, distances, labels, params);
|
|
197
198
|
idx_t* li = labels;
|
|
198
199
|
#pragma omp parallel for
|
|
199
200
|
for (idx_t i = 0; i < n * k; i++) {
|
|
@@ -209,7 +210,7 @@ void IndexIDMapTemplate<IndexT>::search(
|
|
|
209
210
|
typename IndexT::distance_t* distances,
|
|
210
211
|
idx_t* labels,
|
|
211
212
|
const SearchParameters* params) const {
|
|
212
|
-
|
|
213
|
+
search_ex(
|
|
213
214
|
n,
|
|
214
215
|
static_cast<const void*>(x),
|
|
215
216
|
component_t_to_numeric<typename IndexT::component_t>(),
|
|
@@ -301,13 +302,13 @@ IndexIDMap2Template<IndexT>::IndexIDMap2Template(IndexT* index)
|
|
|
301
302
|
: IndexIDMapTemplate<IndexT>(index) {}
|
|
302
303
|
|
|
303
304
|
template <typename IndexT>
|
|
304
|
-
void IndexIDMap2Template<IndexT>::
|
|
305
|
+
void IndexIDMap2Template<IndexT>::add_with_ids_ex(
|
|
305
306
|
idx_t n,
|
|
306
307
|
const void* x,
|
|
307
308
|
NumericType numeric_type,
|
|
308
309
|
const idx_t* xids) {
|
|
309
310
|
size_t prev_ntotal = this->ntotal;
|
|
310
|
-
IndexIDMapTemplate<IndexT>::
|
|
311
|
+
IndexIDMapTemplate<IndexT>::add_with_ids_ex(n, x, numeric_type, xids);
|
|
311
312
|
for (size_t i = prev_ntotal; i < this->ntotal; i++) {
|
|
312
313
|
rev_map[this->id_map[i]] = i;
|
|
313
314
|
}
|
|
@@ -318,7 +319,7 @@ void IndexIDMap2Template<IndexT>::add_with_ids(
|
|
|
318
319
|
idx_t n,
|
|
319
320
|
const typename IndexT::component_t* x,
|
|
320
321
|
const idx_t* xids) {
|
|
321
|
-
|
|
322
|
+
add_with_ids_ex(
|
|
322
323
|
n,
|
|
323
324
|
static_cast<const void*>(x),
|
|
324
325
|
component_t_to_numeric<typename IndexT::component_t>(),
|
|
@@ -23,7 +23,7 @@ struct IndexIDMapTemplate : IndexT {
|
|
|
23
23
|
using distance_t = typename IndexT::distance_t;
|
|
24
24
|
|
|
25
25
|
IndexT* index = nullptr; ///! the sub-index
|
|
26
|
-
bool own_fields = false; ///! whether pointers are deleted in
|
|
26
|
+
bool own_fields = false; ///! whether pointers are deleted in destructor
|
|
27
27
|
std::vector<idx_t> id_map;
|
|
28
28
|
|
|
29
29
|
explicit IndexIDMapTemplate(IndexT* index);
|
|
@@ -31,7 +31,7 @@ struct IndexIDMapTemplate : IndexT {
|
|
|
31
31
|
/// @param xids if non-null, ids to store for the vectors (size n)
|
|
32
32
|
void add_with_ids(idx_t n, const component_t* x, const idx_t* xids)
|
|
33
33
|
override;
|
|
34
|
-
void
|
|
34
|
+
void add_with_ids_ex(
|
|
35
35
|
idx_t n,
|
|
36
36
|
const void* x,
|
|
37
37
|
NumericType numeric_type,
|
|
@@ -39,7 +39,7 @@ struct IndexIDMapTemplate : IndexT {
|
|
|
39
39
|
|
|
40
40
|
/// this will fail. Use add_with_ids
|
|
41
41
|
void add(idx_t n, const component_t* x) override;
|
|
42
|
-
void
|
|
42
|
+
void add_ex(idx_t n, const void* x, NumericType numeric_type) override;
|
|
43
43
|
|
|
44
44
|
void search(
|
|
45
45
|
idx_t n,
|
|
@@ -48,7 +48,7 @@ struct IndexIDMapTemplate : IndexT {
|
|
|
48
48
|
distance_t* distances,
|
|
49
49
|
idx_t* labels,
|
|
50
50
|
const SearchParameters* params = nullptr) const override;
|
|
51
|
-
void
|
|
51
|
+
void search_ex(
|
|
52
52
|
idx_t n,
|
|
53
53
|
const void* x,
|
|
54
54
|
NumericType numeric_type,
|
|
@@ -58,7 +58,7 @@ struct IndexIDMapTemplate : IndexT {
|
|
|
58
58
|
const SearchParameters* params = nullptr) const override;
|
|
59
59
|
|
|
60
60
|
void train(idx_t n, const component_t* x) override;
|
|
61
|
-
void
|
|
61
|
+
void train_ex(idx_t n, const void* x, NumericType numeric_type) override;
|
|
62
62
|
|
|
63
63
|
void reset() override;
|
|
64
64
|
|
|
@@ -104,7 +104,7 @@ struct IndexIDMap2Template : IndexIDMapTemplate<IndexT> {
|
|
|
104
104
|
|
|
105
105
|
void add_with_ids(idx_t n, const component_t* x, const idx_t* xids)
|
|
106
106
|
override;
|
|
107
|
-
void
|
|
107
|
+
void add_with_ids_ex(
|
|
108
108
|
idx_t n,
|
|
109
109
|
const void* x,
|
|
110
110
|
NumericType numeric_type,
|
|
@@ -506,7 +506,7 @@ void IndexIVF::search_preassigned(
|
|
|
506
506
|
};
|
|
507
507
|
|
|
508
508
|
// single list scan using the current scanner (with query
|
|
509
|
-
// set
|
|
509
|
+
// set properly) and storing results in simi and idxi
|
|
510
510
|
auto scan_one_list = [&](idx_t key,
|
|
511
511
|
float coarse_dis_i,
|
|
512
512
|
float* simi,
|
|
@@ -160,7 +160,7 @@ struct IndexIVFInterface : Level1Quantizer {
|
|
|
160
160
|
* index maps to a list (aka inverted list or posting list), where the
|
|
161
161
|
* id of the vector is stored.
|
|
162
162
|
*
|
|
163
|
-
* The inverted list object is required only after
|
|
163
|
+
* The inverted list object is required only after training. If none is
|
|
164
164
|
* set externally, an ArrayInvertedLists is used automatically.
|
|
165
165
|
*
|
|
166
166
|
* At search time, the vector to be searched is also quantized, and
|
|
@@ -171,7 +171,7 @@ struct IndexIVFInterface : Level1Quantizer {
|
|
|
171
171
|
* lists are visited.
|
|
172
172
|
*
|
|
173
173
|
* Sub-classes implement a post-filtering of the index that refines
|
|
174
|
-
* the distance estimation from the query to
|
|
174
|
+
* the distance estimation from the query to database vectors.
|
|
175
175
|
*/
|
|
176
176
|
struct IndexIVF : Index, IndexIVFInterface {
|
|
177
177
|
/// Access to the actual data
|
|
@@ -497,12 +497,12 @@ struct InvertedListScanner {
|
|
|
497
497
|
/// compute a single query-to-code distance
|
|
498
498
|
virtual float distance_to_code(const uint8_t* code) const = 0;
|
|
499
499
|
|
|
500
|
-
/** scan a set of codes, compute distances to current query and
|
|
500
|
+
/** scan a set of codes, compute distances to current query, and
|
|
501
501
|
* update heap of results if necessary. Default implementation
|
|
502
502
|
* calls distance_to_code.
|
|
503
503
|
*
|
|
504
|
-
* @param n
|
|
505
|
-
* @param codes
|
|
504
|
+
* @param n number of codes to scan
|
|
505
|
+
* @param codes codes to scan (n * code_size)
|
|
506
506
|
* @param ids corresponding ids (ignored if store_pairs)
|
|
507
507
|
* @param distances heap distances (size k)
|
|
508
508
|
* @param labels heap labels (size k)
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
#include <faiss/impl/AuxIndexStructures.h>
|
|
16
16
|
#include <faiss/impl/FaissAssert.h>
|
|
17
|
+
#include <faiss/impl/FastScanDistancePostProcessing.h>
|
|
17
18
|
#include <faiss/impl/LookupTableScaler.h>
|
|
18
19
|
#include <faiss/impl/pq4_fast_scan.h>
|
|
19
20
|
#include <faiss/invlists/BlockInvertedLists.h>
|
|
@@ -212,7 +213,9 @@ void IndexIVFAdditiveQuantizerFastScan::estimate_norm_scale(
|
|
|
212
213
|
size_t index_nprobe = nprobe;
|
|
213
214
|
nprobe = 1;
|
|
214
215
|
CoarseQuantized cq{index_nprobe, coarse_dis.data(), coarse_ids.data()};
|
|
215
|
-
|
|
216
|
+
FastScanDistancePostProcessing empty_context{};
|
|
217
|
+
|
|
218
|
+
compute_LUT(n, x, cq, dis_tables, biases, empty_context);
|
|
216
219
|
nprobe = index_nprobe;
|
|
217
220
|
|
|
218
221
|
float scale = 0;
|
|
@@ -314,8 +317,10 @@ void IndexIVFAdditiveQuantizerFastScan::search(
|
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
NormTableScaler scaler(norm_scale);
|
|
320
|
+
FastScanDistancePostProcessing context;
|
|
321
|
+
context.norm_scaler = &scaler;
|
|
317
322
|
IndexIVFFastScan::CoarseQuantized cq{nprobe};
|
|
318
|
-
search_dispatch_implem(n, x, k, distances, labels, cq,
|
|
323
|
+
search_dispatch_implem(n, x, k, distances, labels, cq, context);
|
|
319
324
|
}
|
|
320
325
|
|
|
321
326
|
/*********************************************************
|
|
@@ -383,7 +388,8 @@ void IndexIVFAdditiveQuantizerFastScan::compute_LUT(
|
|
|
383
388
|
const float* x,
|
|
384
389
|
const CoarseQuantized& cq,
|
|
385
390
|
AlignedTable<float>& dis_tables,
|
|
386
|
-
AlignedTable<float>& biases
|
|
391
|
+
AlignedTable<float>& biases,
|
|
392
|
+
const FastScanDistancePostProcessing&) const {
|
|
387
393
|
const size_t dim12 = ksub * M;
|
|
388
394
|
const size_t ip_dim12 = aq->M * ksub;
|
|
389
395
|
const size_t nprobe = cq.nprobe;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include <faiss/IndexIVFAdditiveQuantizer.h>
|
|
13
13
|
#include <faiss/IndexIVFFastScan.h>
|
|
14
14
|
#include <faiss/impl/AdditiveQuantizer.h>
|
|
15
|
+
#include <faiss/impl/FastScanDistancePostProcessing.h>
|
|
15
16
|
#include <faiss/impl/ProductAdditiveQuantizer.h>
|
|
16
17
|
#include <faiss/utils/AlignedTable.h>
|
|
17
18
|
|
|
@@ -101,7 +102,8 @@ struct IndexIVFAdditiveQuantizerFastScan : IndexIVFFastScan {
|
|
|
101
102
|
const float* x,
|
|
102
103
|
const CoarseQuantized& cq,
|
|
103
104
|
AlignedTable<float>& dis_tables,
|
|
104
|
-
AlignedTable<float>& biases
|
|
105
|
+
AlignedTable<float>& biases,
|
|
106
|
+
const FastScanDistancePostProcessing& context) const override;
|
|
105
107
|
};
|
|
106
108
|
|
|
107
109
|
struct IndexIVFLocalSearchQuantizerFastScan
|