Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseTranspose.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
9ParserFuncSignature ParseTranspose = [](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 tranpose op has input tensor" + input_name +
17 " but its type is not yet registered");
18 }
19
20 std::unique_ptr<ROperator> op;
21 std::string output_name = nodeproto.output(0);
22 std::vector<int_t> attr_perm;
23
24 if (nodeproto.attribute_size() == 1) {
25 attr_perm.assign(nodeproto.attribute(0).ints().begin(), nodeproto.attribute(0).ints().end());
26 }
27
28 switch (input_type) {
30 if (!attr_perm.empty()) {
31 op.reset(new ROperator_Transpose<float>(attr_perm, nodeproto.input(0), nodeproto.output(0)));
32 } else {
33 op.reset(new ROperator_Transpose<float>(nodeproto.input(0), nodeproto.output(0)));
34 }
35 break;
36 default:
37 throw std::runtime_error("TMVA::SOFIE - Unsupported - Operator Transpose does not yet support input type " +
38 std::to_string(static_cast<int>(input_type)));
39 }
40
41 if (!parser.IsRegisteredTensorType(output_name)) {
42 parser.RegisterTensorType(output_name, input_type);
43 }
44
45 return op;
46};
47
48} // namespace SOFIE
49} // namespace Experimental
50} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParseTranspose
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations