Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
IVFUtils.cuh
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
9 #pragma once
10
11 #include "../GpuIndicesOptions.h"
12 #include "../utils/Tensor.cuh"
13 #include <thrust/device_vector.h>
14
15 // A collection of utility functions for IVFPQ and IVFFlat, for
16 // post-processing and k-selecting the results
17 namespace faiss { namespace gpu {
18
19 /// Function for multi-pass scanning that collects the length of
20 /// intermediate results for all (query, probe) pair
21 void runCalcListOffsets(Tensor<int, 2, true>& topQueryToCentroid,
22 thrust::device_vector<int>& listLengths,
23 Tensor<int, 2, true>& prefixSumOffsets,
24 Tensor<char, 1, true>& thrustMem,
25 cudaStream_t stream);
26
27 /// Performs a first pass of k-selection on the results
28 void runPass1SelectLists(Tensor<int, 2, true>& prefixSumOffsets,
29 Tensor<float, 1, true>& distance,
30 int nprobe,
31 int k,
32 bool chooseLargest,
33 Tensor<float, 3, true>& heapDistances,
34 Tensor<int, 3, true>& heapIndices,
35 cudaStream_t stream);
36
37 /// Performs a final pass of k-selection on the results, producing the
38 /// final indices
39 void runPass2SelectLists(Tensor<float, 2, true>& heapDistances,
40 Tensor<int, 2, true>& heapIndices,
41 thrust::device_vector<void*>& listIndices,
42 IndicesOptions indicesOptions,
43 Tensor<int, 2, true>& prefixSumOffsets,
44 Tensor<int, 2, true>& topQueryToCentroid,
45 int k,
46 bool chooseLargest,
47 Tensor<float, 2, true>& outDistances,
48 Tensor<long, 2, true>& outIndices,
49 cudaStream_t stream);
50
51 } } // namespace