Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseShape.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
9ParserFuncSignature ParseShape = [](RModelParser_ONNX &parser, const onnx::NodeProto &nodeproto) {
11 auto input_name = nodeproto.input(0);
12 if (parser.IsRegisteredTensorType(input_name)) {
13 input_type = parser.GetTensorType(input_name);
14 } else {
15 throw std::runtime_error("TMVA::SOFIE ONNX Parser Shape op has input tensor" + input_name +
16 " but its type is not yet registered");
17 }
18
19 std::unique_ptr<ROperator> op;
20 std::string output_name = nodeproto.output(0);
21 int attr_start = 0;
22 int attr_end = -1;
23
24 for (int_t i = 0; i < nodeproto.attribute_size(); i++) {
25 std::string attribute_name = nodeproto.attribute(i).name();
26 if (attribute_name == "start")
27 attr_start = nodeproto.attribute(i).i();
28 if (attribute_name == "end")
29 attr_end = nodeproto.attribute(i).i();
30 }
31
32 op.reset(new ROperator_Shape(attr_start, attr_end, input_name, output_name));
33
34 if (!parser.IsRegisteredTensorType(output_name)) {
35 parser.RegisterTensorType(output_name, input_type);
36 }
37
38 return op;
39};
40
41} // namespace SOFIE
42} // namespace Experimental
43} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParseShape
Definition ParseShape.cxx:9
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations