Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseBatchNormalization.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
9ParserFuncSignature ParseBatchNormalization = [](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 BatchNorm 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 float fepsilon = 1e-05;
23 float fmomentum = 0.9;
24 std::size_t ftraining_mode = 0;
25
26 switch (input_type) {
28 if (nodeproto.input_size() == 5) {
29 op.reset(new ROperator_BatchNormalization<float>(fepsilon, fmomentum, ftraining_mode, nodeproto.input(0),
30 nodeproto.input(1), nodeproto.input(2), nodeproto.input(3),
31 nodeproto.input(4), output_name));
32 }
33 break;
34 default:
35 throw std::runtime_error("TMVA::SOFIE - Unsupported - Operator BatchNorm does not yet support input type " +
36 std::to_string(static_cast<int>(input_type)));
37 }
38
39 if (!parser.IsRegisteredTensorType(output_name)) {
40 parser.RegisterTensorType(output_name, input_type);
41 }
42
43 return op;
44};
45
46} // namespace SOFIE
47} // namespace Experimental
48} // namespace TMVA
#define e(i)
Definition RSha256.hxx:103
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParseBatchNormalization
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations