3#include "onnx_proto3.pb.h"
7namespace Experimental {
10template <EReduceOpMode Op>
17 if (nodeproto.op_type() ==
"ReduceMean")
19 else if (nodeproto.op_type() ==
"ReduceSumsquare")
21 else if (nodeproto.op_type() ==
"ReduceProd")
25 throw std::runtime_error(
"TN+MVA::SOFIE - Reduce op mode not supported.");
28 auto input_name = nodeproto.input(0);
32 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Reduce op has input tensor" + input_name +
33 " but its type is not yet registered");
36 std::unique_ptr<ROperator> op;
37 std::string output_name = nodeproto.output(0);
38 int attr_keepdims = 1;
40 for (
int_t i = 0; i < nodeproto.attribute_size(); i++) {
41 std::string attribute_name = nodeproto.attribute(i).name();
42 if (attribute_name ==
"keepdims")
43 attr_keepdims = nodeproto.attribute(i).i();
44 if (attribute_name ==
"axis")
45 attr_axis = nodeproto.attribute(i).i();
52 throw std::runtime_error(
"TMVA::SOFIE - Unsupported - Reduce Operator does not yet support input type " +
53 std::to_string(
static_cast<int>(input_type)));
64 return ParseReduce<EReduceOpMode::ReduceMean>(parser, nodeproto);
69 return ParseReduce<EReduceOpMode::ReduceSumsquare>(parser, nodeproto);
74 return ParseReduce<EReduceOpMode::ReduceProd>(parser, nodeproto);
bool IsRegisteredTensorType(const std::string &)
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
std::unique_ptr< ROperator > ParseReduce(RModelParser_ONNX &parser, const onnx::NodeProto &nodeproto)
ParserFuncSignature ParseReduceMean
ParserFuncSignature ParseReduceProd
ParserFuncSignature ParseReduceSumsquare
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations