Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
GpuAutoTune.h
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 "../Index.h"
15 #include "../AutoTune.h"
16 #include "GpuIndex.h"
17 #include "GpuIndicesOptions.h"
18
19 namespace faiss { namespace gpu {
20
21 class GpuResources;
22
23
24 // to support auto-tuning we need cloning to/from CPU
25
26 /// converts any GPU index inside gpu_index to a CPU index
27 faiss::Index * index_gpu_to_cpu(const faiss::Index *gpu_index);
28
29
30 /// set some options on how to copy to GPU
31 struct GpuClonerOptions {
32 /// how should indices be stored on GpuIndexIVFPQ?
33 IndicesOptions indicesOptions;
34 /// is the coarse quantizer in float16?
35 bool useFloat16CoarseQuantizer;
36 /// for GpuIndexIVFFlat, is storage in float16?
37 /// for GpuIndexIVFPQ, are intermediate calculations in float16?
38 bool useFloat16;
39 /// use precomputed tables?
40 bool usePrecomputed;
41 /// reserve vectors in the invfiles?
42 long reserveVecs;
43 int verbose;
44 GpuClonerOptions ();
45 };
46
47
48 /// converts any CPU index that can be converted to GPU
49 faiss::Index * index_cpu_to_gpu(
50 GpuResources* resources, int device,
51 const faiss::Index *index,
52 const GpuClonerOptions *options = nullptr);
53
54 struct GpuMultipleClonerOptions: GpuClonerOptions {
55 bool shard; ///< shard rather than copying to each GPU
56 GpuMultipleClonerOptions ();
57 };
58
59
60 faiss::Index * index_cpu_to_gpu_multiple(
61 std::vector<GpuResources*> & resources,
62 std::vector<int> &devices,
63 const faiss::Index *index,
64 const GpuMultipleClonerOptions *options = nullptr);
65
66
67
68 /// parameter space and setters for GPU indexes
69 struct GpuParameterSpace: faiss::ParameterSpace {
70 /// initialize with reasonable parameters for the index
71 void initialize (const faiss::Index * index) override;
72
73 /// set a combination of parameters on an index
74 void set_index_parameter (
75 faiss::Index * index, const std::string & name,
76 double val) const override;
77 };
78
79
80
81 } } // namespace
faiss::gpu::GpuMultipleClonerOptions::shard
bool shard
shard rather than copying to each GPU
Definition: GpuAutoTune.h:55
faiss::gpu::GpuParameterSpace::initialize
void initialize(const faiss::Index *index) override
initialize with reasonable parameters for the index
Definition: GpuAutoTune.cpp:275
faiss::gpu::GpuClonerOptions
set some options on how to copy to GPU
Definition: GpuAutoTune.h:31
faiss::gpu::GpuClonerOptions::usePrecomputed
bool usePrecomputed
use precomputed tables?
Definition: GpuAutoTune.h:40
faiss::gpu::GpuResources
Definition: GpuResources.h:24
faiss::gpu::GpuMultipleClonerOptions
Definition: GpuAutoTune.h:54
faiss::gpu::GpuParameterSpace::set_index_parameter
void set_index_parameter(faiss::Index *index, const std::string &name, double val) const override
set a combination of parameters on an index
Definition: GpuAutoTune.cpp:308
faiss::gpu::GpuParameterSpace
parameter space and setters for GPU indexes
Definition: GpuAutoTune.h:69
faiss::gpu::GpuClonerOptions::useFloat16
bool useFloat16
Definition: GpuAutoTune.h:38
faiss::gpu::GpuClonerOptions::indicesOptions
IndicesOptions indicesOptions
how should indices be stored on GpuIndexIVFPQ?
Definition: GpuAutoTune.h:33
faiss::gpu::GpuClonerOptions::useFloat16CoarseQuantizer
bool useFloat16CoarseQuantizer
is the coarse quantizer in float16?
Definition: GpuAutoTune.h:35
faiss::ParameterSpace
Definition: AutoTune.h:133
faiss::Index
Definition: Index.h:61
faiss::gpu::GpuClonerOptions::reserveVecs
long reserveVecs
reserve vectors in the invfiles?
Definition: GpuAutoTune.h:42