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  /// For GpuIndexFlat, store data in transposed layout?
45  int verbose;
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 
57  bool shard; ///< shard rather than copying to each GPU
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
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
bool shard
shard rather than copying to each GPU
Definition: GpuAutoTune.h:57
bool storeTransposed
For GpuIndexFlat, store data in transposed layout?
Definition: GpuAutoTune.h:44
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:71
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