ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParseConv.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_Conv.hxx
"
3
#include "
onnx.hxx
"
4
5
namespace
TMVA
{
6
namespace
Experimental {
7
namespace
SOFIE {
8
9
ParserFuncSignature
ParseConv
= [](
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 Conv op has input tensor "
+
input_name
+
17
" but its type is not yet registered"
);
18
}
19
20
std::unique_ptr<ROperator>
op
;
21
22
std::string
attr_auto_pad
=
"NOTSET"
;
23
std::vector<size_t>
attr_dilations
;
24
size_t
attr_group
= 0;
25
std::vector<size_t>
attr_kernel_shape
;
26
std::vector<size_t>
attr_pads
;
27
std::vector<size_t>
attr_strides
;
28
29
for
(
int_t
i = 0; i <
nodeproto
.attribute_size(); i++) {
30
std::string
attribute_name
=
nodeproto
.attribute(i).name();
31
if
(
attribute_name
==
"auto_pad"
) {
32
attr_auto_pad
=
nodeproto
.attribute(i).s();
33
}
else
if
(
attribute_name
==
"dilations"
) {
34
attr_dilations
=
35
std::vector<size_t>({
nodeproto
.attribute(i).ints().begin(),
nodeproto
.attribute(i).ints().
end
()});
36
}
else
if
(
attribute_name
==
"group"
) {
37
attr_group
=
nodeproto
.attribute(i).i();
38
}
else
if
(
attribute_name
==
"kernel_shape"
) {
39
attr_kernel_shape
=
40
std::vector<size_t>({
nodeproto
.attribute(i).ints().begin(),
nodeproto
.attribute(i).ints().
end
()});
41
}
else
if
(
attribute_name
==
"pads"
) {
42
attr_pads
= std::vector<size_t>({
nodeproto
.attribute(i).ints().begin(),
nodeproto
.attribute(i).ints().
end
()});
43
}
else
if
(
attribute_name
==
"strides"
) {
44
attr_strides
=
45
std::vector<size_t>({
nodeproto
.attribute(i).ints().begin(),
nodeproto
.attribute(i).ints().
end
()});
46
}
else
{
47
std::cout <<
"TMVA::SOFIE Warning - Model Loading - Attribute "
<<
attribute_name
<<
" in OperatorNode "
48
<<
nodeproto
.name() <<
" is not defined in ONNX IR and not applied!\n"
;
49
}
50
}
51
52
std::string
name_b
=
""
;
53
if
(
nodeproto
.input_size() > 2) {
54
name_b
=
nodeproto
.input(2);
55
}
56
std::string
output_name
=
nodeproto
.output(0);
57
58
switch
(
input_type
) {
59
case
ETensorType::FLOAT
:
60
op
.reset(
new
ROperator_Conv<float>
(
attr_auto_pad
,
attr_dilations
,
attr_group
,
attr_kernel_shape
,
attr_pads
,
61
attr_strides
,
nodeproto
.input(0),
nodeproto
.input(1),
name_b
,
output_name
));
62
break
;
63
default
:
64
throw
std::runtime_error(
"TMVA::SOFIE - Unsupported - Operator Conv does not yet support input type "
+
65
std::to_string(
static_cast<
int
>
(
input_type
)));
66
}
67
68
if
(!
parser
.IsRegisteredTensorType(
output_name
)) {
69
parser
.RegisterTensorType(
output_name
,
input_type
);
70
}
71
72
return
op
;
73
};
74
75
}
// namespace SOFIE
76
}
// namespace Experimental
77
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_Conv.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
ROOT::Detail::TRangeCast
Definition
TCollection.h:312
ROOT::RRangeCast::end
const_iterator end() const
Definition
RRangeCast.hxx:104
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::int_t
std::int64_t int_t
Definition
SOFIE_common.hxx:56
TMVA::Experimental::SOFIE::ParseConv
ParserFuncSignature ParseConv
Definition
ParseConv.cxx:9
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
onnx.hxx
tmva
sofie_parsers
src
ParseConv.cxx
ROOTmaster - Reference Guide Generated on Sun Sep 6 2026 04:47:54 (GVA Time) using Doxygen 1.10.0