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