ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParseConcat.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_Concat.hxx
"
3
#include "
onnx.hxx
"
4
5
namespace
TMVA
{
6
namespace
Experimental {
7
namespace
SOFIE {
8
9
ParserFuncSignature
ParseConcat
= [](
RModelParser_ONNX
&
parser
,
const
onnx::NodeProto
&
nodeproto
) {
10
ETensorType
input_type
=
ETensorType::UNDEFINED
;
11
std::vector<std::string>
inputs
;
12
size_t
size
=
nodeproto
.input_size();
13
inputs
.reserve(
size
);
14
for
(
int
i = 0; i <
nodeproto
.input_size(); ++i) {
15
auto
input_name
=
nodeproto
.input(i);
16
if
(
parser
.IsRegisteredTensorType(
input_name
)) {
17
if
(i == 0)
18
input_type
=
parser
.GetTensorType(
input_name
);
19
else
20
assert
(
parser
.GetTensorType(
input_name
) ==
input_type
);
21
}
else
{
22
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser Concat op has input tensor"
+
input_name
+
23
" but its type is not yet registered"
);
24
}
25
inputs
.emplace_back(
input_name
);
26
}
27
28
std::unique_ptr<ROperator>
op
;
29
std::string
output_name
=
nodeproto
.output(0);
30
31
int
attr_axis
= 0;
32
int
attr_new_axis
= 0;
33
for
(
int_t
i = 0; i <
nodeproto
.attribute_size(); i++) {
34
std::string
attribute_name
=
nodeproto
.attribute(i).name();
35
if
(
attribute_name
==
"axis"
)
36
attr_axis
=
nodeproto
.attribute(i).i();
37
else
if
(
attribute_name
==
"new_axis"
)
// this is for ConcatFromSequence (that is equivalent to np.stack)
38
attr_new_axis
=
nodeproto
.attribute(i).i();
39
}
40
//switch (input_type) {
41
//case ETensorType::FLOAT:
42
op
.reset(
new
ROperator_Concat
(
inputs
,
attr_axis
,
attr_new_axis
,
output_name
));
43
//break;
44
//default:
45
// throw std::runtime_error("TMVA::SOFIE - Unsupported - Operator Concat does not yet support input type " +
46
// std::to_string(static_cast<int>(input_type)));
47
// }
48
49
if
(!
parser
.IsRegisteredTensorType(
output_name
)) {
50
parser
.RegisterTensorType(
output_name
,
input_type
);
51
}
52
return
op
;
53
};
54
55
}
// namespace SOFIE
56
}
// namespace Experimental
57
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_Concat.hxx
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
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_Concat
Definition
ROperator_Concat.hxx:20
TMVA::Experimental::SOFIE::onnx::NodeProto
Definition
onnx.hxx:504
TMVA::Experimental::SOFIE::ETensorType
ETensorType
Definition
SOFIE_common.hxx:29
TMVA::Experimental::SOFIE::ETensorType::UNDEFINED
@ UNDEFINED
TMVA::Experimental::SOFIE::ParserFuncSignature
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
Definition
RModelParser_ONNX.hxx:25
TMVA::Experimental::SOFIE::ParseConcat
ParserFuncSignature ParseConcat
Definition
ParseConcat.cxx:9
TMVA::Experimental::SOFIE::int_t
std::int64_t int_t
Definition
SOFIE_common.hxx:56
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
onnx.hxx
tmva
sofie_parsers
src
ParseConcat.cxx
ROOTmaster - Reference Guide Generated on Sat Sep 5 2026 04:37:47 (GVA Time) using Doxygen 1.10.0