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