ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParseScatterElements.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_ScatterElements.hxx
"
3
#include "
onnx.hxx
"
4
5
namespace
TMVA
{
6
namespace
Experimental {
7
namespace
SOFIE {
8
9
ParserFuncSignature
ParseScatterElements
= [](
RModelParser_ONNX
&
parser
,
const
onnx::NodeProto
&
nodeproto
) {
10
11
if
(
nodeproto
.input_size() != 3) {
12
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser ScatterElements op has invalid input size"
);
13
}
14
// data is input 0
15
if
(!
parser
.IsRegisteredTensorType(
nodeproto
.input(0))){
16
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser ScatterElements op has input tensor "
+
nodeproto
.input(0)
17
+
" but its type is not yet registered"
);
18
}
19
if
(!
parser
.IsRegisteredTensorType(
nodeproto
.input(1))){
20
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser ScatterElements op has input tensor "
+
nodeproto
.input(1)
21
+
" but its type is not yet registered"
);
22
}
23
if
(!
parser
.IsRegisteredTensorType(
nodeproto
.input(2))){
24
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser ScatterElements op has input tensor "
+
nodeproto
.input(2)
25
+
" but its type is not yet registered"
);
26
}
27
ETensorType
input_type
=
parser
.GetTensorType(
nodeproto
.input(0));
28
if
(
parser
.GetTensorType(
nodeproto
.input(2)) !=
input_type
) {
29
throw
std::runtime_error(
"TMVA::SOFIE ONNX parser ScatterElements op has input tensors of different types: "
+
30
nodeproto
.input(2) +
" : "
+
ConvertTypeToString
(
parser
.GetTensorType(
nodeproto
.input(2))) +
31
" and "
+
nodeproto
.input(0) +
" : "
+
ConvertTypeToString
(
input_type
));
32
}
33
34
int
axis = 0;
35
std::string
reduction
;
36
for
(
int
i = 0; i <
nodeproto
.attribute_size(); i++) {
37
std::string
attribute_name
=
nodeproto
.attribute(i).name();
38
if
(
attribute_name
==
"axis"
)
39
axis =
nodeproto
.attribute(i).i();
40
else
if
(
attribute_name
==
"reduction"
)
41
reduction
=
nodeproto
.attribute(i).s();
42
}
43
44
std::unique_ptr<ROperator>
op
;
45
std::string
output_name
=
nodeproto
.output(0);
46
47
op
.reset(
new
ROperator_ScatterElements
(
nodeproto
.input(0),
nodeproto
.input(1),
nodeproto
.input(2),
48
output_name
, axis,
reduction
));
49
50
// Infer the output type
51
if
(!
parser
.IsRegisteredTensorType(
output_name
)) {
52
parser
.RegisterTensorType(
output_name
,
input_type
);
53
}
54
55
return
op
;
56
};
57
58
59
}
// namespace SOFIE
60
}
// namespace Experimental
61
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_ScatterElements.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
TMVA::Experimental::SOFIE::RModelParser_ONNX
Definition
RModelParser_ONNX.hxx:30
TMVA::Experimental::SOFIE::ROperator_ScatterElements
Definition
ROperator_ScatterElements.hxx:15
TMVA::Experimental::SOFIE::onnx::NodeProto
Definition
onnx.hxx:504
TMVA::Experimental::SOFIE::ETensorType
ETensorType
Definition
SOFIE_common.hxx:29
TMVA::Experimental::SOFIE::ParserFuncSignature
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
Definition
RModelParser_ONNX.hxx:25
TMVA::Experimental::SOFIE::ConvertTypeToString
std::string ConvertTypeToString(ETensorType type)
Definition
SOFIE_common.cxx:66
TMVA::Experimental::SOFIE::ParseScatterElements
ParserFuncSignature ParseScatterElements
Definition
ParseScatterElements.cxx:9
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
onnx.hxx
tmva
sofie_parsers
src
ParseScatterElements.cxx
ROOTmaster - Reference Guide Generated on Sat Sep 5 2026 04:37:47 (GVA Time) using Doxygen 1.10.0