Faiss
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
gpu
GpuDistance.h
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 "../Index.h"
12
13
namespace
faiss {
namespace
gpu {
14
15
class
GpuResources;
16
17
/// A wrapper for gpu/impl/Distance.cuh to expose direct brute-force k-nearest
18
/// neighbor searches on an externally-provided region of memory (e.g., from a
19
/// pytorch tensor).
20
/// The data (vectors, queries, outDistances, outIndices) can be resident on the
21
/// GPU or the CPU, but all calculations are performed on the GPU. If the result
22
/// buffers are on the CPU, results will be copied back when done.
23
///
24
/// All GPU computation is performed on the current CUDA device, and ordered
25
/// with respect to resources->getDefaultStreamCurrentDevice().
26
///
27
/// For each vector in `queries`, searches all of `vectors` to find its k
28
/// nearest neighbors with respect to the given metric
29
void
bruteForceKnn(GpuResources* resources,
30
faiss::MetricType
metric,
31
// If vectorsRowMajor is true, this is
32
// numVectors x dims, with dims innermost; otherwise,
33
// dims x numVectors, with numVectors innermost
34
const
float
* vectors,
35
bool
vectorsRowMajor,
36
int
numVectors,
37
// If queriesRowMajor is true, this is
38
// numQueries x dims, with dims innermost; otherwise,
39
// dims x numQueries, with numQueries innermost
40
const
float
* queries,
41
bool
queriesRowMajor,
42
int
numQueries,
43
int
dims,
44
int
k,
45
// A region of memory size numQueries x k, with k
46
// innermost (row major)
47
float
* outDistances,
48
// A region of memory size numQueries x k, with k
49
// innermost (row major)
50
faiss::Index::idx_t
* outIndices);
51
52
} }
// namespace
faiss::Index::idx_t
long idx_t
all indices are this type
Definition:
Index.h:62
faiss::MetricType
MetricType
Some algorithms support both an inner product version and a L2 search version.
Definition:
Index.h:44
Generated by
1.8.5