Caffe2 - C++ API
A deep learning, cross platform ML framework
onnx_convert.h
1 #include "caffe2/core/common.h"
2 
3 class CAFFE2_API OnnxAnnotation : public nom::repr::Annotation {
4 public:
5  OnnxAnnotation() : Annotation(AnnotationKind::Onnx) {}
6  OnnxAnnotation(std::string device)
7  : Annotation(AnnotationKind::Onnx), Device(device) {}
8 
9  void setDevice(std::string device) { Device = device; }
10  const std::string getDevice() const { return Device; }
11 
12  void setOperatorDef(caffe2::OperatorDef* opDef) {
13  OpDef = opDef;
14  }
15  const caffe2::OperatorDef* getOperatorDef() const {
16  assert(OpDef && "OperatorDef was never set. Use OnnxAnnotation::setOperatorDef.");
17  return OpDef;
18  }
19  caffe2::OperatorDef* getMutableOperatorDef() {
20  assert(OpDef && "OperatorDef was never set. Use OnnxAnnotation::setOperatorDef.");
21  return OpDef;
22  }
23 
24  static bool classof(const Annotation *A) {
25  return A->getKind() == AnnotationKind::Onnx;
26  }
27 
28 private:
29  std::string Device = "";
30  caffe2::OperatorDef* OpDef = nullptr;
31 };
32 
33 CAFFE2_API nom::repr::NNModule convertToNNModule(caffe2::NetDef &net, std::unordered_map<std::string, nom::repr::NNGraph::NodeRef>* blobMapOut = nullptr);
34 
35 CAFFE2_API caffe2::NetDef convertToOnnxProto(nom::repr::NNModule&);
36 
37 CAFFE2_API std::unique_ptr<nom::repr::NeuralNetOperator> convertToOperatorDef(caffe2::OperatorDef op);
Annotations allow for generic manipulation of neural network operations.
Definition: NeuralNet.h:44
Definition: static.cpp:52