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 /// For GpuIndexFlat, store data in transposed layout?
44 bool storeTransposed;
45 int verbose;
46 GpuClonerOptions ();
47 };
48
49
50 /// converts any CPU index that can be converted to GPU
51 faiss::Index * index_cpu_to_gpu(
52 GpuResources* resources, int device,
53 const faiss::Index *index,
54 const GpuClonerOptions *options = nullptr);
55
56 struct GpuMultipleClonerOptions: GpuClonerOptions {
57 bool shard; ///< shard rather than copying to each GPU
58 GpuMultipleClonerOptions ();
59 };
60
61
62 faiss::Index * index_cpu_to_gpu_multiple(
63 std::vector<GpuResources*> & resources,
64 std::vector<int> &devices,
65 const faiss::Index *index,
66 const GpuMultipleClonerOptions *options = nullptr);
67
68
69
70 /// parameter space and setters for GPU indexes
71 struct GpuParameterSpace: faiss::ParameterSpace {
72 /// initialize with reasonable parameters for the index
73 void initialize (const faiss::Index * index) override;
74
75 /// set a combination of parameters on an index
76 void set_index_parameter (
77 faiss::Index * index, const std::string & name,
78 double val) const override;
79 };
80
81
82
83 } } // namespace
faiss::gpu::GpuMultipleClonerOptions::shard
bool shard
shard rather than copying to each GPU
Definition: GpuAutoTune.h:57
faiss::gpu::GpuClonerOptions::storeTransposed
bool storeTransposed
For GpuIndexFlat, store data in transposed layout?
Definition: GpuAutoTune.h:44
faiss::gpu::GpuParameterSpace::initialize
void initialize(const faiss::Index *index) override
initialize with reasonable parameters for the index
Definition: GpuAutoTune.cpp:281
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:56
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:314
faiss::gpu::GpuParameterSpace
parameter space and setters for GPU indexes
Definition: GpuAutoTune.h:71
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