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