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) {
10 auto input_name = nodeproto.input(0);
11 if (!parser.IsRegisteredTensorType(input_name)) {
12 throw std::runtime_error("TMVA::SOFIE ONNX Parser Shape op has input tensor" + input_name +
13 " but its type is not yet registered");
14 }
15
16 std::unique_ptr<ROperator> op;
17 std::string output_name = nodeproto.output(0);
18 int attr_start = 0;
19 int attr_end = INT_MAX; // cannot use 0 or -1 as default
20
21 for (int_t i = 0; i < nodeproto.attribute_size(); i++) {
22 std::string attribute_name = nodeproto.attribute(i).name();
23 if (attribute_name == "start")
24 attr_start = nodeproto.attribute(i).i();
25 if (attribute_name == "end")
26 attr_end = nodeproto.attribute(i).i();
27 }
28
29 op.reset(new ROperator_Shape(attr_start, attr_end, input_name, output_name));
30
31 // output of Shpe is always an int64 tensor
32 if (!parser.IsRegisteredTensorType(output_name)) {
33 parser.RegisterTensorType(output_name, ETensorType::INT64);
34 }
35
36 return op;
37};
38
39} // namespace SOFIE
40} // namespace Experimental
41} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
ParserFuncSignature ParseShape
Definition ParseShape.cxx:9
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations