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