Faiss
 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
32  /// how should indices be stored on GpuIndexIVFPQ?
33  IndicesOptions indicesOptions;
34  /// is the coarse quantizer in float16?
36  /// for GpuIndexIVFFlat, is storage in float16?
37  /// for GpuIndexIVFPQ, are intermediate calculations in float16?
38  bool useFloat16;
39  /// use precomputed tables?
41  /// reserve vectors in the invfiles?
43  int verbose;
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 
55  bool shard; ///< shard rather than copying to each GPU
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
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
bool shard
shard rather than copying to each GPU
Definition: GpuAutoTune.h:55
void initialize(const faiss::Index *index) override
initialize with reasonable parameters for the index
set some options on how to copy to GPU
Definition: GpuAutoTune.h:31
bool usePrecomputed
use precomputed tables?
Definition: GpuAutoTune.h:40
void set_index_parameter(faiss::Index *index, const std::string &name, double val) const override
set a combination of parameters on an index
parameter space and setters for GPU indexes
Definition: GpuAutoTune.h:69
IndicesOptions indicesOptions
how should indices be stored on GpuIndexIVFPQ?
Definition: GpuAutoTune.h:33
bool useFloat16CoarseQuantizer
is the coarse quantizer in float16?
Definition: GpuAutoTune.h:35
long reserveVecs
reserve vectors in the invfiles?
Definition: GpuAutoTune.h:42