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