Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseSelu.cxx
Go to the documentation of this file.
3#include "onnx.hxx"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
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 selu op has input tensor" + input_name +
17 " but its type is not yet registered");
18 }
19
20 std::unique_ptr<ROperator> op;
21
22 // default values from the ONNX specification
23 float attr_alpha = 1.67326319217681884765625;
24 float attr_gamma = 1.05070102214813232421875;
25
26 for (int_t i = 0; i < nodeproto.attribute_size(); i++) {
27 std::string attribute_name = nodeproto.attribute(i).name();
28 if (attribute_name == "alpha")
29 attr_alpha = nodeproto.attribute(i).f();
30 else if (attribute_name == "gamma")
31 attr_gamma = nodeproto.attribute(i).f();
32 }
33
34 std::string output_name = nodeproto.output(0);
35 switch (input_type) {
36 case ETensorType::FLOAT: op.reset(new ROperator_Selu<float>(attr_alpha, attr_gamma, input_name, output_name)); break;
37 default:
38 throw std::runtime_error("TMVA::SOFIE - Unsupported - Operator Selu does not yet support input type " +
39 std::to_string(static_cast<int>(input_type)));
40 }
41
42 if (!parser.IsRegisteredTensorType(output_name)) {
43 parser.RegisterTensorType(output_name, input_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 ParseSelu
Definition ParseSelu.cxx:9
create variable transformations