1 #ifndef CAFFE2_OPT_CONVERTER_H 2 #define CAFFE2_OPT_CONVERTER_H 4 #include "caffe2/core/common.h" 5 #include "caffe2/core/logging.h" 6 #include "caffe2/opt/annotations.h" 7 #include "caffe2/proto/caffe2_pb.h" 8 #include "nomnigraph/Graph/Graph.h" 9 #include "nomnigraph/Representations/ControlFlow.h" 10 #include "nomnigraph/Representations/NeuralNet.h" 12 #include <unordered_map> 16 CAFFE2_API
void injectDataEdgeIndicators(caffe2::NetDef* net);
17 CAFFE2_API
void removeDataEdgeIndicators(caffe2::NetDef* net);
24 const caffe2::NetDef& net,
26 std::vector<nom::repr::NNGraph::NodeRef>* =
nullptr);
32 CAFFE2_API caffe2::NetDef convertToCaffe2Proto(
nom::repr::NNModule&,
const caffe2::NetDef& oldNet);
35 CAFFE2_API std::unique_ptr<nom::repr::NeuralNetOperator> convertToNeuralNetOperator(
36 const caffe2::OperatorDef& op);
38 CAFFE2_API caffe2::OperatorDef convertToOperatorDef(
42 CAFFE2_API Caffe2Annotation* getOrAddCaffe2Annotation(
45 class CAFFE2_API Converter {
47 explicit Converter() =
default;
48 virtual std::unique_ptr<nom::repr::NeuralNetOperator>
49 convertToNeuralNetOperator(
const OperatorDef&) = 0;
51 static std::map<std::string, caffe2::Argument> getArgumentsFromOperator(
52 caffe2::OperatorDef op);
54 virtual ~Converter() {}
57 C10_DECLARE_REGISTRY(ConverterRegistry, Converter);
58 #define REGISTER_CONVERTER(name, cls) \ 59 C10_REGISTER_CLASS(ConverterRegistry, name, cls) 61 #define TRIVIAL_CONVERTER(opName) \ 62 class opName##Converter : public Converter { \ 63 std::unique_ptr<nom::repr::NeuralNetOperator> convertToNeuralNetOperator( \ 64 const OperatorDef& op) override { \ 65 return nom::util::make_unique<nom::repr::opName>(); \ 67 virtual ~opName##Converter() {} \ 73 #endif // CAFFE2_OPT_CONVERTER_H
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
repr::NNModule convertToNNModule(const caffe2::NetDef &net, bool strict, std::vector< repr::NNGraph::NodeRef > *opNodeVec)
Ingest a caffe2 protobuf model and output an NNModule.