Caffe2 - C++ API
A deep learning, cross platform ML framework
module.h
1 
6 #ifndef CAFFE2_CORE_MODULE_H_
7 #define CAFFE2_CORE_MODULE_H_
8 
9 #include <algorithm>
10 #include <cstdio>
11 #include <cstdlib>
12 #include <functional>
13 #include <memory>
14 #include <mutex>
15 
16 #include "caffe2/core/common.h"
17 #include <c10/util/typeid.h>
18 
19 namespace caffe2 {
20 
26 class CAFFE2_API ModuleSchema {
27  public:
28  ModuleSchema(const char* name, const char* description);
29 
30  private:
31  const char* name_;
32  const char* description_;
33 };
34 
35 
48 CAFFE2_API const CaffeMap<string, const ModuleSchema*>& CurrentModules();
49 
53 CAFFE2_API bool HasModule(const string& name);
54 
63 CAFFE2_API void LoadModule(const string& name, const string& filename="");
64 
65 
66 #define CAFFE2_MODULE(name, description) \
67  extern "C" { \
68  bool gCaffe2ModuleSanityCheck##name() { return true; } \
69  } \
70  namespace { \
71  static ::caffe2::ModuleSchema module_schema_##name(#name, description); \
72  }
73 
74 } // namespace caffe2
75 #endif // CAFFE2_CORE_MODULE_H_
bool HasModule(const string &name)
Checks whether a module is already present in the current binary.
Definition: module.cc:37
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13
void LoadModule(const string &name, const string &filename)
Load a module.
Definition: module.cc:52
const CaffeMap< string, const ModuleSchema * > & CurrentModules()
Current Modules present in the Caffe2 runtime.
Definition: module.cc:27
A module schema that can be used to store specific information about different modules.
Definition: module.h:26