Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
IndexWrapper.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 "../IndexProxy.h"
13 #include "../StandardGpuResources.h"
14 #include <functional>
15 #include <memory>
16 #include <vector>
17
18 namespace faiss { namespace gpu {
19
20 // If we want to run multi-GPU, create a proxy to wrap the indices.
21 // If we don't want multi-GPU, don't involve the proxy, so it doesn't
22 // affect the timings.
23 template <typename GpuIndex>
24 struct IndexWrapper {
25 std::vector<std::unique_ptr<faiss::gpu::StandardGpuResources>> resources;
26 std::vector<std::unique_ptr<GpuIndex>> subIndex;
27 std::unique_ptr<faiss::gpu::IndexProxy> proxyIndex;
28
29 IndexWrapper(
30 int numGpus,
31 std::function<std::unique_ptr<GpuIndex>(GpuResources*, int)> init);
32 faiss::Index* getIndex();
33
34 void runOnIndices(std::function<void(GpuIndex*)> f);
35 void setNumProbes(int nprobe);
36 };
37
38 } }
39
40 #include "IndexWrapper-inl.h"
faiss::gpu::GpuResources
Definition: GpuResources.h:22
faiss::gpu::GpuIndex
Definition: GpuIndex.h:34
faiss::Index
Definition: Index.h:62
faiss::gpu::IndexWrapper
Definition: IndexWrapper.h:24