/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include // A collection of utility functions for IVFPQ and IVFFlat, for // post-processing and k-selecting the results namespace faiss { namespace gpu { /// Function for multi-pass scanning that collects the length of /// intermediate results for all (query, probe) pair void runCalcListOffsets(Tensor& topQueryToCentroid, thrust::device_vector& listLengths, Tensor& prefixSumOffsets, Tensor& thrustMem, cudaStream_t stream); /// Performs a first pass of k-selection on the results void runPass1SelectLists(Tensor& prefixSumOffsets, Tensor& distance, int nprobe, int k, bool chooseLargest, Tensor& heapDistances, Tensor& heapIndices, cudaStream_t stream); /// Performs a final pass of k-selection on the results, producing the /// final indices void runPass2SelectLists(Tensor& heapDistances, Tensor& heapIndices, thrust::device_vector& listIndices, IndicesOptions indicesOptions, Tensor& prefixSumOffsets, Tensor& topQueryToCentroid, int k, bool chooseLargest, Tensor& outDistances, Tensor& outIndices, cudaStream_t stream); } } // namespace