3#include "onnx_proto3.pb.h"
6namespace Experimental {
13 if (nodeproto.op_type() ==
"MaxPool")
15 else if (nodeproto.op_type() ==
"AveragePool")
17 else if (nodeproto.op_type() ==
"GlobalAveragePool")
22 auto input_name = nodeproto.input(0);
26 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Pool op has input tensor " + input_name +
27 " but its type is not yet registered");
30 std::unique_ptr<ROperator> op;
34 for (
int_t i = 0; i < nodeproto.attribute_size(); i++) {
35 std::string attribute_name = nodeproto.attribute(i).name();
36 if (attribute_name ==
"auto_pad") {
37 attr.auto_pad = nodeproto.attribute(i).s();
38 }
else if (attribute_name ==
"ceil_mode") {
39 attr.ceil_mode = nodeproto.attribute(i).i();
40 }
else if (attribute_name ==
"count_include_pad" && op_mode ==
AveragePool) {
41 attr.count_include_pad = nodeproto.attribute(i).i();
42 }
else if (attribute_name ==
"storage_order" && op_mode ==
MaxPool) {
43 attr.storage_order = nodeproto.attribute(i).i();
44 }
else if (attribute_name ==
"dilations" && op_mode ==
MaxPool) {
46 std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
47 }
else if (attribute_name ==
"kernel_shape") {
49 std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
50 }
else if (attribute_name ==
"pads") {
51 attr.pads = std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
52 }
else if (attribute_name ==
"strides") {
54 std::vector<size_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
56 std::cout <<
"TMVA::SOFIE Warning - Model Loading - Attribute " << attribute_name <<
" in OperatorNode "
57 << nodeproto.name() <<
" is not defined in ONNX IR and not applied!\n";
61 std::string output_name = nodeproto.output(0);
65 throw std::runtime_error(
"TMVA::SOFIE - Unsupported - Operator Pool does not yet support input type " +
66 std::to_string(
static_cast<int>(input_type)));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t attr
bool IsRegisteredTensorType(const std::string &)
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParsePool
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations