Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
operator_meta.h
Go to the documentation of this file.
1 
16 #pragma once
17 
18 #include <functional>
19 #include "caffe2/core/logging.h"
20 #include "caffe2/core/registry.h"
21 #include "caffe2/proto/caffe2.pb.h"
22 
23 namespace caffe2 {
24 
26  std::function<void(NetDef*, const OperatorDef&)>;
27 
64  public:
65  class Register {
66  public:
67  Register(const std::string& name, ReferenceImplementation func) {
68  CAFFE_ENFORCE(!ReferenceImplementationRegistry::getMap().count(name));
70  }
71  };
72 
73  static void Append(NetDef* net, const OperatorDef& op);
74  static NetDef ConvertNet(const NetDef& net);
75 
76  private:
78  static CaffeMap<std::string, ReferenceImplementation>& getMap();
79 };
80 
81 #define TC_REFERENCE_IMPLEMENTATION(name, func) \
82  static ::caffe2::ReferenceImplementationRegistry::Register \
83  CAFFE_ANONYMOUS_VARIABLE(tc_ref##name)(#name, func);
84 } // namespace caffe2
Definition: operator_meta.h:63
std::function< void(NetDef *, const OperatorDef &)> ReferenceImplementation
Definition: operator_meta.h:26
static NetDef ConvertNet(const NetDef &net)
Register(const std::string &name, ReferenceImplementation func)
Definition: operator_meta.h:67
static CaffeMap< std::string, ReferenceImplementation > & getMap()
static void Append(NetDef *net, const OperatorDef &op)