3#include "onnx_proto3.pb.h"
6namespace Experimental {
12 auto input_name = nodeproto.input(0);
16 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Conv op has input tensor " + input_name +
17 " but its type is not yet registered");
20 std::unique_ptr<ROperator> op;
22 std::string attr_auto_pad =
"NOTSET";
23 std::vector<size_t> attr_dilations;
24 size_t attr_group = 0;
25 std::vector<size_t> attr_kernel_shape;
26 std::vector<size_t> attr_pads;
27 std::vector<size_t> attr_strides;
29 for (
int_t i = 0; i < nodeproto.attribute_size(); i++) {
30 std::string attribute_name = nodeproto.attribute(i).name();
31 if (attribute_name ==
"auto_pad") {
32 attr_auto_pad = nodeproto.attribute(i).s();
33 }
else if (attribute_name ==
"dilations") {
35 std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
36 }
else if (attribute_name ==
"group") {
37 attr_group = nodeproto.attribute(i).i();
38 }
else if (attribute_name ==
"kernel_shape") {
40 std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
41 }
else if (attribute_name ==
"pads") {
42 attr_pads = std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
43 }
else if (attribute_name ==
"strides") {
45 std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
47 std::cout <<
"TMVA::SOFIE Warning - Model Loading - Attribute " << attribute_name <<
" in OperatorNode "
48 << nodeproto.name() <<
" is not defined in ONNX IR and not applied!\n";
52 std::string name_b =
"";
53 if (nodeproto.input_size() > 2) {
54 name_b = nodeproto.input(2);
56 std::string output_name = nodeproto.output(0);
60 op.reset(
new ROperator_Conv<float>(attr_auto_pad, attr_dilations, attr_group, attr_kernel_shape, attr_pads,
61 attr_strides, nodeproto.input(0), nodeproto.input(1), name_b, output_name));
64 throw std::runtime_error(
"TMVA::SOFIE - Unsupported - Operator Conv does not yet support input type " +
65 std::to_string(
static_cast<int>(input_type)));
bool IsRegisteredTensorType(const std::string &)
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
ParserFuncSignature ParseConv
create variable transformations