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()});
60 op.reset(
new ROperator_Reduce<Op>(attr_keepdims, attr_axes, input_name, axes_name, output_name));