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