ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParsePad.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_Pad.hxx
"
3
#include "
onnx.hxx
"
4
5
namespace
TMVA
{
6
namespace
Experimental {
7
namespace
SOFIE {
8
9
ParserFuncSignature
ParsePad
= [](
RModelParser_ONNX
&
parser
,
const
onnx::NodeProto
&
nodeproto
) {
10
ETensorType
input_type
;
11
12
std::string
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 Pad op has input tensor"
+
input_name
+
17
" but its type is not yet registered"
);
18
}
19
20
if
(
nodeproto
.input_size() < 2) {
21
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser Pad op has invalid input size < 2"
);
22
}
23
24
// pads is second inputs
25
std::string
pads_name
=
nodeproto
.input(1);
26
if
(!
parser
.IsRegisteredTensorType(
pads_name
)) {
27
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser Pad op has input tensor"
+
pads_name
+
28
" but its type is not yet registered"
);
29
}
30
// in case of optional inputs
31
std::string
cvalue_name
;
32
if
(
nodeproto
.input_size() > 2) {
33
cvalue_name
=
nodeproto
.input(2);
34
}
35
std::string
axes_name
;
36
if
(
nodeproto
.input_size() > 3) {
37
axes_name
=
nodeproto
.input(3);
38
}
39
40
// get attributes
41
std::string
mode
=
"constant"
;
42
if
(
nodeproto
.attribute_size() > 0 ) {
43
std::string
attribute_name
=
nodeproto
.attribute(0).name();
44
if
(
attribute_name
==
"mode"
) {
45
mode
=
nodeproto
.attribute(0).s();
46
}
47
}
48
std::string
output_name
=
nodeproto
.output(0);
49
50
std::unique_ptr<ROperator>
op
;
51
switch
(
input_type
) {
52
case
ETensorType::FLOAT
:
53
op
.reset(
new
ROperator_Pad<float>
(
input_name
,
pads_name
,
cvalue_name
,
axes_name
,
output_name
,
mode
));
54
break
;
55
default
:
56
throw
std::runtime_error(
"TMVA::SOFIE - Unsupported - Operator Pad does not yet support input type "
+
57
std::to_string(
static_cast<
int
>
(
input_type
)));
58
}
59
60
if
(!
parser
.IsRegisteredTensorType(
output_name
)) {
61
parser
.RegisterTensorType(
output_name
,
input_type
);
62
}
63
64
return
op
;
65
};
66
67
}
// namespace SOFIE
68
}
// namespace Experimental
69
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_Pad.hxx
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:359
mode
Option_t Option_t TPoint TPoint const char mode
Definition
TGWin32VirtualXProxy.cxx:68
ROOT::Detail::TRangeCast
Definition
TCollection.h:312
TMVA::Experimental::SOFIE::RModelParser_ONNX
Definition
RModelParser_ONNX.hxx:30
TMVA::Experimental::SOFIE::onnx::NodeProto
Definition
onnx.hxx:504
TMVA::Experimental::SOFIE::ETensorType
ETensorType
Definition
SOFIE_common.hxx:29
TMVA::Experimental::SOFIE::ETensorType::FLOAT
@ FLOAT
TMVA::Experimental::SOFIE::ParserFuncSignature
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
Definition
RModelParser_ONNX.hxx:25
TMVA::Experimental::SOFIE::ParsePad
ParserFuncSignature ParsePad
Definition
ParsePad.cxx:9
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
onnx.hxx
tmva
sofie_parsers
src
ParsePad.cxx
ROOTmaster - Reference Guide Generated on Sat Sep 5 2026 04:37:47 (GVA Time) using Doxygen 1.10.0