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")
23 else if (nodeproto.op_type() ==
"ReduceSum")
27 throw std::runtime_error(
"TMVA::SOFIE - Reduce op mode not supported.");
30 auto input_name = nodeproto.input(0);
34 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Reduce op has input tensor" + input_name +
35 " but its type is not yet registered");
38 std::string axes_name;
39 if (nodeproto.input_size() > 1) {
40 axes_name = nodeproto.input(1);
42 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Reduce op has input tensor" + axes_name +
43 " but its type is not yet registered");
47 std::unique_ptr<ROperator> op;
48 std::string output_name = nodeproto.output(0);
49 int attr_keepdims = 1;
50 std::vector<int64_t> attr_axes;
51 for (
int_t i = 0; i < nodeproto.attribute_size(); i++) {
52 std::string attribute_name = nodeproto.attribute(i).name();
53 if (attribute_name ==
"keepdims")
54 attr_keepdims = nodeproto.attribute(i).i();
55 if (attribute_name ==
"axes") {
57 std::vector<int64_t>({nodeproto.attribute(i).ints().begin(), nodeproto.attribute(i).ints().end()});
65 throw std::runtime_error(
"TMVA::SOFIE - Unsupported - Reduce Operator does not yet support input type " +
66 std::to_string(
static_cast<int>(input_type)));
77 return ParseReduce<EReduceOpMode::ReduceMean>(parser, nodeproto);
82 return ParseReduce<EReduceOpMode::ReduceSumSquare>(parser, nodeproto);
87 return ParseReduce<EReduceOpMode::ReduceProd>(parser, nodeproto);
92 return ParseReduce<EReduceOpMode::ReduceSum>(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
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
ParserFuncSignature ParseReduceSum
ParserFuncSignature ParseReduceSumSquare
create variable transformations