forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpybind_workspace.h
42 lines (37 loc) · 1.18 KB
/
pybind_workspace.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
//#include <Python.h>
namespace caffe2 {
namespace python {
class C10_EXPORT BlobFetcherBase {
public:
struct FetchedBlob {
pybind11::object obj;
bool copied;
};
virtual ~BlobFetcherBase();
virtual pybind11::object Fetch(const Blob& blob) = 0;
};
C10_DECLARE_TYPED_REGISTRY(
BlobFetcherRegistry,
TypeIdentifier,
BlobFetcherBase,
std::unique_ptr);
#define REGISTER_BLOB_FETCHER(id, ...) \
C10_REGISTER_TYPED_CLASS(BlobFetcherRegistry, id, __VA_ARGS__)
inline unique_ptr<BlobFetcherBase> CreateFetcher(TypeIdentifier id) {
return BlobFetcherRegistry()->Create(id);
}
Workspace* GetCurrentWorkspace();
void SetCurrentWorkspace(Workspace* workspace);
Workspace* NewWorkspace();
Workspace* GetWorkspaceByName(const std::string& name);
std::string GetCurrentWorkspaceName();
void InsertWorkspace(const std::string& name, std::unique_ptr<Workspace> ws);
void SwitchWorkspaceInternal(const std::string& name, bool create_if_missing);
void ResetWorkspace(Workspace* workspace);
void GetWorkspaceNames(std::vector<std::string>& names);
void ClearWorkspaces();
} // namespace python
} // namespace caffe2