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 } else {
33 throw std::runtime_error("TMVA::SOFIE ONNX Parser BatchNormalization op requires exactly 5 inputs, got " +
34 std::to_string(nodeproto.input_size()));
35 }
36 break;
37 default:
38 throw std::runtime_error("TMVA::SOFIE - Unsupported - Operator BatchNorm 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
#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