faiss 0.5.3 → 0.6.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 +8 -0
- data/ext/faiss/ext.cpp +1 -1
- data/ext/faiss/extconf.rb +5 -6
- data/ext/faiss/index_binary.cpp +38 -28
- data/ext/faiss/{index.cpp → index_rb.cpp} +64 -46
- data/ext/faiss/kmeans.cpp +10 -9
- data/ext/faiss/pca_matrix.cpp +10 -8
- data/ext/faiss/product_quantizer.cpp +14 -12
- data/ext/faiss/{utils.cpp → utils_rb.cpp} +5 -3
- data/ext/faiss/{utils.h → utils_rb.h} +4 -0
- data/lib/faiss/version.rb +1 -1
- data/lib/faiss.rb +1 -1
- data/vendor/faiss/faiss/AutoTune.cpp +130 -11
- data/vendor/faiss/faiss/AutoTune.h +14 -1
- data/vendor/faiss/faiss/Clustering.cpp +59 -10
- data/vendor/faiss/faiss/Clustering.h +12 -0
- data/vendor/faiss/faiss/IVFlib.cpp +31 -28
- data/vendor/faiss/faiss/Index.cpp +20 -8
- data/vendor/faiss/faiss/Index.h +25 -3
- data/vendor/faiss/faiss/IndexAdditiveQuantizer.cpp +19 -24
- data/vendor/faiss/faiss/IndexBinary.cpp +1 -0
- data/vendor/faiss/faiss/IndexBinaryHNSW.cpp +9 -4
- data/vendor/faiss/faiss/IndexBinaryIVF.cpp +45 -11
- data/vendor/faiss/faiss/IndexFastScan.cpp +35 -22
- data/vendor/faiss/faiss/IndexFastScan.h +10 -1
- data/vendor/faiss/faiss/IndexFlat.cpp +193 -136
- data/vendor/faiss/faiss/IndexFlat.h +16 -1
- data/vendor/faiss/faiss/IndexFlatCodes.cpp +46 -22
- data/vendor/faiss/faiss/IndexFlatCodes.h +7 -1
- data/vendor/faiss/faiss/IndexHNSW.cpp +24 -50
- data/vendor/faiss/faiss/IndexHNSW.h +14 -12
- data/vendor/faiss/faiss/IndexIDMap.cpp +1 -1
- data/vendor/faiss/faiss/IndexIVF.cpp +76 -49
- data/vendor/faiss/faiss/IndexIVF.h +14 -4
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.cpp +11 -8
- data/vendor/faiss/faiss/IndexIVFAdditiveQuantizerFastScan.h +2 -2
- data/vendor/faiss/faiss/IndexIVFFastScan.cpp +25 -14
- data/vendor/faiss/faiss/IndexIVFFastScan.h +26 -22
- data/vendor/faiss/faiss/IndexIVFFlat.cpp +10 -61
- data/vendor/faiss/faiss/IndexIVFFlatPanorama.cpp +39 -111
- data/vendor/faiss/faiss/IndexIVFPQ.cpp +89 -147
- data/vendor/faiss/faiss/IndexIVFPQFastScan.cpp +37 -5
- data/vendor/faiss/faiss/IndexIVFPQR.cpp +2 -1
- data/vendor/faiss/faiss/IndexIVFRaBitQ.cpp +42 -30
- data/vendor/faiss/faiss/IndexIVFRaBitQ.h +2 -2
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.cpp +246 -97
- data/vendor/faiss/faiss/IndexIVFRaBitQFastScan.h +32 -29
- data/vendor/faiss/faiss/IndexLSH.cpp +8 -6
- data/vendor/faiss/faiss/IndexLattice.cpp +29 -24
- data/vendor/faiss/faiss/IndexNNDescent.cpp +1 -0
- data/vendor/faiss/faiss/IndexNSG.cpp +2 -1
- data/vendor/faiss/faiss/IndexNSG.h +0 -2
- data/vendor/faiss/faiss/IndexNeuralNetCodec.cpp +1 -1
- data/vendor/faiss/faiss/IndexPQ.cpp +19 -10
- data/vendor/faiss/faiss/IndexRaBitQ.cpp +26 -13
- data/vendor/faiss/faiss/IndexRaBitQ.h +2 -2
- data/vendor/faiss/faiss/IndexRaBitQFastScan.cpp +132 -78
- data/vendor/faiss/faiss/IndexRaBitQFastScan.h +14 -12
- data/vendor/faiss/faiss/IndexRefine.cpp +0 -30
- data/vendor/faiss/faiss/IndexShards.cpp +3 -4
- data/vendor/faiss/faiss/MetricType.h +16 -0
- data/vendor/faiss/faiss/VectorTransform.cpp +120 -0
- data/vendor/faiss/faiss/VectorTransform.h +23 -0
- data/vendor/faiss/faiss/clone_index.cpp +7 -4
- data/vendor/faiss/faiss/{cppcontrib/factory_tools.cpp → factory_tools.cpp} +1 -1
- data/vendor/faiss/faiss/gpu/GpuCloner.cpp +1 -1
- data/vendor/faiss/faiss/impl/AdditiveQuantizer.cpp +37 -11
- data/vendor/faiss/faiss/impl/AuxIndexStructures.h +0 -28
- data/vendor/faiss/faiss/impl/ClusteringInitialization.cpp +367 -0
- data/vendor/faiss/faiss/impl/ClusteringInitialization.h +107 -0
- data/vendor/faiss/faiss/impl/CodePacker.cpp +4 -0
- data/vendor/faiss/faiss/impl/CodePacker.h +11 -3
- data/vendor/faiss/faiss/impl/CodePackerRaBitQ.cpp +83 -0
- data/vendor/faiss/faiss/impl/CodePackerRaBitQ.h +47 -0
- data/vendor/faiss/faiss/impl/FaissAssert.h +60 -2
- data/vendor/faiss/faiss/impl/HNSW.cpp +25 -34
- data/vendor/faiss/faiss/impl/HNSW.h +8 -6
- data/vendor/faiss/faiss/impl/LocalSearchQuantizer.cpp +34 -27
- data/vendor/faiss/faiss/impl/NNDescent.cpp +1 -1
- data/vendor/faiss/faiss/impl/NSG.cpp +6 -5
- data/vendor/faiss/faiss/impl/NSG.h +17 -7
- data/vendor/faiss/faiss/impl/Panorama.cpp +53 -46
- data/vendor/faiss/faiss/impl/Panorama.h +22 -6
- data/vendor/faiss/faiss/impl/PolysemousTraining.cpp +16 -5
- data/vendor/faiss/faiss/impl/ProductQuantizer.cpp +70 -58
- data/vendor/faiss/faiss/impl/RaBitQUtils.cpp +92 -0
- data/vendor/faiss/faiss/impl/RaBitQUtils.h +93 -31
- data/vendor/faiss/faiss/impl/RaBitQuantizer.cpp +12 -28
- data/vendor/faiss/faiss/impl/RaBitQuantizer.h +3 -10
- data/vendor/faiss/faiss/impl/RaBitQuantizerMultiBit.cpp +15 -41
- data/vendor/faiss/faiss/impl/RaBitQuantizerMultiBit.h +0 -4
- data/vendor/faiss/faiss/impl/ResidualQuantizer.cpp +14 -9
- data/vendor/faiss/faiss/impl/ResultHandler.h +131 -50
- data/vendor/faiss/faiss/impl/ScalarQuantizer.cpp +67 -2358
- data/vendor/faiss/faiss/impl/ScalarQuantizer.h +0 -2
- data/vendor/faiss/faiss/impl/VisitedTable.cpp +42 -0
- data/vendor/faiss/faiss/impl/VisitedTable.h +69 -0
- data/vendor/faiss/faiss/impl/expanded_scanners.h +158 -0
- data/vendor/faiss/faiss/impl/index_read.cpp +829 -471
- data/vendor/faiss/faiss/impl/index_read_utils.h +0 -1
- data/vendor/faiss/faiss/impl/index_write.cpp +17 -8
- data/vendor/faiss/faiss/impl/lattice_Zn.cpp +47 -20
- data/vendor/faiss/faiss/impl/mapped_io.cpp +9 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.cpp +7 -2
- data/vendor/faiss/faiss/impl/pq4_fast_scan.h +11 -3
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_1.cpp +19 -13
- data/vendor/faiss/faiss/impl/pq4_fast_scan_search_qbs.cpp +29 -21
- data/vendor/faiss/faiss/impl/{code_distance/code_distance-avx2.h → pq_code_distance/pq_code_distance-avx2.cpp} +42 -215
- data/vendor/faiss/faiss/impl/{code_distance/code_distance-avx512.h → pq_code_distance/pq_code_distance-avx512.cpp} +68 -107
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-generic.cpp +141 -0
- data/vendor/faiss/faiss/impl/pq_code_distance/pq_code_distance-inl.h +23 -0
- data/vendor/faiss/faiss/impl/{code_distance/code_distance-sve.h → pq_code_distance/pq_code_distance-sve.cpp} +57 -144
- data/vendor/faiss/faiss/impl/residual_quantizer_encode_steps.cpp +9 -6
- data/vendor/faiss/faiss/impl/scalar_quantizer/codecs.h +121 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/distance_computers.h +136 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/quantizers.h +280 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/scanners.h +164 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/similarities.h +94 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx2.cpp +455 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-avx512.cpp +430 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-dispatch.h +329 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/sq-neon.cpp +467 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/training.cpp +203 -0
- data/vendor/faiss/faiss/impl/scalar_quantizer/training.h +42 -0
- data/vendor/faiss/faiss/impl/simd_dispatch.h +139 -0
- data/vendor/faiss/faiss/impl/simd_result_handlers.h +18 -18
- data/vendor/faiss/faiss/index_factory.cpp +35 -16
- data/vendor/faiss/faiss/index_io.h +29 -3
- data/vendor/faiss/faiss/invlists/BlockInvertedLists.cpp +7 -4
- data/vendor/faiss/faiss/invlists/OnDiskInvertedLists.cpp +1 -1
- data/vendor/faiss/faiss/svs/IndexSVSFaissUtils.h +9 -19
- data/vendor/faiss/faiss/svs/IndexSVSFlat.h +2 -0
- data/vendor/faiss/faiss/svs/IndexSVSVamana.h +2 -1
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.cpp +9 -1
- data/vendor/faiss/faiss/svs/IndexSVSVamanaLeanVec.h +9 -0
- data/vendor/faiss/faiss/utils/Heap.cpp +46 -0
- data/vendor/faiss/faiss/utils/Heap.h +21 -0
- data/vendor/faiss/faiss/utils/NeuralNet.cpp +10 -7
- data/vendor/faiss/faiss/utils/distances.cpp +141 -23
- data/vendor/faiss/faiss/utils/distances.h +98 -0
- data/vendor/faiss/faiss/utils/distances_dispatch.h +170 -0
- data/vendor/faiss/faiss/utils/distances_simd.cpp +74 -3511
- data/vendor/faiss/faiss/utils/extra_distances-inl.h +164 -157
- data/vendor/faiss/faiss/utils/extra_distances.cpp +52 -95
- data/vendor/faiss/faiss/utils/extra_distances.h +47 -1
- data/vendor/faiss/faiss/utils/hamming_distance/generic-inl.h +0 -1
- data/vendor/faiss/faiss/utils/partitioning.cpp +1 -1
- data/vendor/faiss/faiss/utils/pq_code_distance.h +251 -0
- data/vendor/faiss/faiss/utils/rabitq_simd.h +260 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_aarch64.cpp +150 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_arm_sve.cpp +568 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_autovec-inl.h +153 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_avx2.cpp +1185 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_avx512.cpp +1092 -0
- data/vendor/faiss/faiss/utils/simd_impl/distances_sse-inl.h +391 -0
- data/vendor/faiss/faiss/utils/simd_levels.cpp +322 -0
- data/vendor/faiss/faiss/utils/simd_levels.h +91 -0
- data/vendor/faiss/faiss/utils/simdlib_avx2.h +12 -1
- data/vendor/faiss/faiss/utils/simdlib_avx512.h +69 -0
- data/vendor/faiss/faiss/utils/simdlib_neon.h +6 -0
- data/vendor/faiss/faiss/utils/sorting.cpp +4 -4
- data/vendor/faiss/faiss/utils/utils.cpp +16 -9
- metadata +47 -18
- data/vendor/faiss/faiss/impl/code_distance/code_distance-generic.h +0 -81
- data/vendor/faiss/faiss/impl/code_distance/code_distance.h +0 -186
- /data/vendor/faiss/faiss/{cppcontrib/factory_tools.h → factory_tools.h} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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/impl/VisitedTable.h>
|
|
9
|
+
|
|
10
|
+
#include <cstring>
|
|
11
|
+
|
|
12
|
+
namespace faiss {
|
|
13
|
+
|
|
14
|
+
// The vector strategy is faster for get()/set(), but O(size) to initialize.
|
|
15
|
+
// advance() is O(1) except every 250 calls, which are O(size).
|
|
16
|
+
// The hash set strategy is a constant factor slower for get()/set(),
|
|
17
|
+
// but O(1) to construct and O(visits) to advance.
|
|
18
|
+
// A size of ~1M seems to be the threshold where the hash set wins.
|
|
19
|
+
size_t visited_table_hashset_threshold = 500000;
|
|
20
|
+
|
|
21
|
+
VisitedTable::VisitedTable(size_t size, std::optional<bool> use_hashset)
|
|
22
|
+
: visno(use_hashset.value_or(size >= visited_table_hashset_threshold)
|
|
23
|
+
? 0
|
|
24
|
+
: 1) {
|
|
25
|
+
if (visno != 0) {
|
|
26
|
+
visited.resize(size, 0);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
void VisitedTable::advance() {
|
|
31
|
+
if (visno == 0) {
|
|
32
|
+
visited_set.clear();
|
|
33
|
+
} else if (visno < 254) {
|
|
34
|
+
// 254 rather than 255 because sometimes we use visno and visno+1
|
|
35
|
+
++visno;
|
|
36
|
+
} else {
|
|
37
|
+
memset(visited.data(), 0, sizeof(visited[0]) * visited.size());
|
|
38
|
+
visno = 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
} // namespace faiss
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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_VISITED_TABLE_H
|
|
9
|
+
#define FAISS_VISITED_TABLE_H
|
|
10
|
+
|
|
11
|
+
#include <stdint.h>
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <unordered_set>
|
|
15
|
+
#include <vector>
|
|
16
|
+
|
|
17
|
+
#include <faiss/impl/platform_macros.h>
|
|
18
|
+
#include <faiss/utils/prefetch.h>
|
|
19
|
+
|
|
20
|
+
namespace faiss {
|
|
21
|
+
|
|
22
|
+
FAISS_API extern size_t visited_table_hashset_threshold;
|
|
23
|
+
|
|
24
|
+
/// A fast, reusable Visited Set for graph search algorithms.
|
|
25
|
+
struct VisitedTable {
|
|
26
|
+
std::vector<uint8_t> visited;
|
|
27
|
+
std::unordered_set<size_t> visited_set;
|
|
28
|
+
uint8_t visno; // 0 if using visited_set, 1..250 if using vector.
|
|
29
|
+
|
|
30
|
+
// If use_hashset is nullopt, the use of a hashset will be determined by
|
|
31
|
+
// size >= visited_table_hashset_threshold.
|
|
32
|
+
explicit VisitedTable(
|
|
33
|
+
size_t size,
|
|
34
|
+
std::optional<bool> use_hashset = std::nullopt);
|
|
35
|
+
|
|
36
|
+
/// set flag #no to true, return whether this changed it.
|
|
37
|
+
bool set(size_t no) {
|
|
38
|
+
if (visno == 0) {
|
|
39
|
+
return visited_set.insert(no).second;
|
|
40
|
+
} else if (visited[no] == visno) {
|
|
41
|
+
return false;
|
|
42
|
+
} else {
|
|
43
|
+
visited[no] = visno;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// get flag #no
|
|
49
|
+
bool get(size_t no) const {
|
|
50
|
+
if (visno == 0) {
|
|
51
|
+
return visited_set.count(no) != 0;
|
|
52
|
+
} else {
|
|
53
|
+
return visited[no] == visno;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
void prefetch(size_t no) const {
|
|
58
|
+
if (visno != 0) {
|
|
59
|
+
prefetch_L2(&visited[no]);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// reset all flags to false
|
|
64
|
+
void advance();
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
} // namespace faiss
|
|
68
|
+
|
|
69
|
+
#endif
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and 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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <cstdio>
|
|
11
|
+
|
|
12
|
+
#include <faiss/IndexIVF.h>
|
|
13
|
+
#include <faiss/impl/ResultHandler.h>
|
|
14
|
+
|
|
15
|
+
/* This is the inner loop of the inverted list scanners. The default version
|
|
16
|
+
* that is defined in IndexIVF.cpp works fine but it cannot inline the distance
|
|
17
|
+
* computation code by calling one or another of the run_scan_codes_* variants
|
|
18
|
+
* with the exact ScannerType and by setting distance_to_code to be a final
|
|
19
|
+
* function, the code can be inlined. The speed difference matters for very
|
|
20
|
+
* small distance computations (eg. SQ or Flat) */
|
|
21
|
+
|
|
22
|
+
namespace faiss {
|
|
23
|
+
|
|
24
|
+
namespace {
|
|
25
|
+
|
|
26
|
+
template <class ScannerType, typename C, bool store_pairs, bool use_sel>
|
|
27
|
+
size_t run_scan_codes1(
|
|
28
|
+
const ScannerType& scanner,
|
|
29
|
+
size_t list_size,
|
|
30
|
+
const uint8_t* codes,
|
|
31
|
+
const idx_t* ids,
|
|
32
|
+
ResultHandler& handler) {
|
|
33
|
+
size_t nup = 0;
|
|
34
|
+
size_t list_no = scanner.list_no;
|
|
35
|
+
size_t code_size = scanner.code_size;
|
|
36
|
+
const IDSelector* sel = scanner.sel;
|
|
37
|
+
float threshold = handler.threshold;
|
|
38
|
+
for (size_t j = 0; j < list_size; j++) {
|
|
39
|
+
if (use_sel) {
|
|
40
|
+
int64_t id = store_pairs ? lo_build(list_no, j) : ids[j];
|
|
41
|
+
// skip code without computing distance
|
|
42
|
+
if (!sel->is_member(id)) {
|
|
43
|
+
codes += code_size;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
float dis = scanner.distance_to_code(codes); // will be inlined if final
|
|
49
|
+
if (C::cmp(threshold, dis)) {
|
|
50
|
+
int64_t id = store_pairs ? lo_build(list_no, j) : ids[j];
|
|
51
|
+
handler.add_result(dis, id);
|
|
52
|
+
threshold = handler.threshold;
|
|
53
|
+
nup++;
|
|
54
|
+
}
|
|
55
|
+
codes += code_size;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return nup;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/*****************************************************************************
|
|
62
|
+
* The following functions dispatch runtime parameters to templates, with
|
|
63
|
+
* possibly some already-fixed templates.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
template <bool store_pairs, bool use_sel, class ScannerType>
|
|
67
|
+
size_t run_scan_codes_fix_store_pairs_fix_use_sel(
|
|
68
|
+
const ScannerType& scanner,
|
|
69
|
+
size_t list_size,
|
|
70
|
+
const uint8_t* codes,
|
|
71
|
+
const idx_t* ids,
|
|
72
|
+
ResultHandler& handler) {
|
|
73
|
+
if (scanner.keep_max) {
|
|
74
|
+
return run_scan_codes1<
|
|
75
|
+
ScannerType,
|
|
76
|
+
CMin<float, idx_t>,
|
|
77
|
+
store_pairs,
|
|
78
|
+
use_sel>(scanner, list_size, codes, ids, handler);
|
|
79
|
+
} else {
|
|
80
|
+
return run_scan_codes1<
|
|
81
|
+
ScannerType,
|
|
82
|
+
CMax<float, idx_t>,
|
|
83
|
+
store_pairs,
|
|
84
|
+
use_sel>(scanner, list_size, codes, ids, handler);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
template <class C, bool use_sel, class ScannerType>
|
|
89
|
+
size_t run_scan_codes_fix_C_fix_use_sel(
|
|
90
|
+
const ScannerType& scanner,
|
|
91
|
+
size_t list_size,
|
|
92
|
+
const uint8_t* codes,
|
|
93
|
+
const idx_t* ids,
|
|
94
|
+
ResultHandler& handler) {
|
|
95
|
+
if (scanner.store_pairs) {
|
|
96
|
+
return run_scan_codes1<ScannerType, C, true, use_sel>(
|
|
97
|
+
scanner, list_size, codes, ids, handler);
|
|
98
|
+
} else {
|
|
99
|
+
return run_scan_codes1<ScannerType, C, false, use_sel>(
|
|
100
|
+
scanner, list_size, codes, ids, handler);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
template <class C, class ScannerType>
|
|
105
|
+
size_t run_scan_codes_fix_C(
|
|
106
|
+
const ScannerType& scanner,
|
|
107
|
+
size_t list_size,
|
|
108
|
+
const uint8_t* codes,
|
|
109
|
+
const idx_t* ids,
|
|
110
|
+
ResultHandler& handler) {
|
|
111
|
+
if (scanner.sel) {
|
|
112
|
+
if (scanner.store_pairs) {
|
|
113
|
+
return run_scan_codes1<ScannerType, C, true, true>(
|
|
114
|
+
scanner, list_size, codes, ids, handler);
|
|
115
|
+
} else {
|
|
116
|
+
return run_scan_codes1<ScannerType, C, false, true>(
|
|
117
|
+
scanner, list_size, codes, ids, handler);
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
if (scanner.store_pairs) {
|
|
121
|
+
return run_scan_codes1<ScannerType, C, true, false>(
|
|
122
|
+
scanner, list_size, codes, ids, handler);
|
|
123
|
+
} else {
|
|
124
|
+
return run_scan_codes1<ScannerType, C, false, false>(
|
|
125
|
+
scanner, list_size, codes, ids, handler);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
template <class ScannerType>
|
|
131
|
+
size_t run_scan_codes(
|
|
132
|
+
const ScannerType& scanner,
|
|
133
|
+
size_t list_size,
|
|
134
|
+
const uint8_t* codes,
|
|
135
|
+
const idx_t* ids,
|
|
136
|
+
ResultHandler& handler) {
|
|
137
|
+
if (scanner.sel == nullptr) {
|
|
138
|
+
if (scanner.store_pairs) {
|
|
139
|
+
return run_scan_codes_fix_store_pairs_fix_use_sel<true, false>(
|
|
140
|
+
scanner, list_size, codes, ids, handler);
|
|
141
|
+
} else {
|
|
142
|
+
return run_scan_codes_fix_store_pairs_fix_use_sel<false, false>(
|
|
143
|
+
scanner, list_size, codes, ids, handler);
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
if (scanner.store_pairs) {
|
|
147
|
+
return run_scan_codes_fix_store_pairs_fix_use_sel<true, true>(
|
|
148
|
+
scanner, list_size, codes, ids, handler);
|
|
149
|
+
} else {
|
|
150
|
+
return run_scan_codes_fix_store_pairs_fix_use_sel<false, true>(
|
|
151
|
+
scanner, list_size, codes, ids, handler);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
} // anonymous namespace
|
|
157
|
+
|
|
158
|
+
} // namespace faiss
|