Faiss

- Main Page
- Namespaces
- Classes
- Files

- File List

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