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