Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
ParseReduce.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4#include <stdexcept>
5
6namespace TMVA {
7namespace Experimental {
8namespace SOFIE {
9
10template <EReduceOpMode Op>
11std::unique_ptr<ROperator> ParseReduce(RModelParser_ONNX &parser, const onnx::NodeProto &nodeproto)
12{
14
16
17 if (nodeproto.op_type() == "ReduceMean")
19 else if (nodeproto.op_type() == "ReduceSumsquare")
21 else if (nodeproto.op_type() == "ReduceProd")
23
24 if (op_mode == InvalidReduceOp) {
25 throw std::runtime_error("TN+MVA::SOFIE - Reduce op mode not supported.");
26 }
27
28 auto input_name = nodeproto.input(0);
31 } else {
32 throw std::runtime_error("TMVA::SOFIE ONNX Parser Reduce op has input tensor" + input_name +
33 " but its type is not yet registered");
34 }
35
36 std::unique_ptr<ROperator> op;
37 std::string output_name = nodeproto.output(0);
38 int attr_keepdims = 1;
39 int attr_axis = 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();
46 }
47 switch (input_type) {
50 break;
51 default:
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)));
54 }
55
58 }
59 return op;
60}
61
62// Parse ReduceMean
66
67// Parse ReduceSumsquare
71
72// Parse ReduceProd
76
77} // namespace SOFIE
78} // namespace Experimental
79} // namespace TMVA
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
ParserFuncSignature ParseReduceProd
ParserFuncSignature ParseReduceSumsquare
create variable transformations