Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseExpand.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
9ParserFuncSignature ParseExpand = [](RModelParser_ONNX &parser, const onnx::NodeProto &nodeproto) {
10 std::unique_ptr<ROperator> op;
11
13 const std::string input_name = nodeproto.input(0);
14 if (parser.IsRegisteredTensorType(input_name)) {
15 input_type = parser.GetTensorType(input_name);
16 } else {
17 throw std::runtime_error(
18 "TMVA::SOFIE ONNX Parser Expand op has input tensor " + input_name +
19 " but its type is not yet registered");
20 }
21
22 const std::string shape_name = nodeproto.input(1);
23 if (parser.IsRegisteredTensorType(shape_name)) {
24 if (parser.GetTensorType(shape_name) != ETensorType::INT64) {
25 throw
26 std::runtime_error("TMVA::SOFIE - ONNX Parser Expand Op shape type not supported");
27 }
28 } else {
29 throw std::runtime_error(
30 "TMVA::SOFIE ONNX Parser Sign op has input tensor " + input_name +
31 " but its type is not yet registered");
32 }
33
34 const std::string output_name = nodeproto.output(0);
35 switch (input_type) {
37 op.reset(new ROperator_Expand<float>(input_name, shape_name, output_name));
38 break;
39 default:
40 throw std::runtime_error("TMVA::SOFIE - Unsupported - Expand Operator does "
41 "not support imput type " +
42 std::to_string(static_cast<int>(input_type)));
43 }
44 if (!parser.IsRegisteredTensorType(output_name)) {
45 parser.RegisterTensorType(output_name, input_type);
46 }
47 return op;
48};
49
50
51} // namespace SOFIE
52} // namespace Experimental
53} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParseExpand
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations