ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParseCast.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_Cast.hxx
"
3
#include "onnx_proto3.pb.h"
4
5
namespace
TMVA
{
6
namespace
Experimental {
7
namespace
SOFIE {
8
9
ParserFuncSignature
ParseCast
= [](
RModelParser_ONNX
&parser,
const
onnx::NodeProto &
nodeproto
) {
10
auto
input_name
=
nodeproto
.input(0);
11
if
(!parser.
IsRegisteredTensorType
(
input_name
)) {
12
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser Cast op has input tensor"
+
input_name
+
13
" but its type is not yet registered"
);
14
}
15
16
ETensorType
output_type
=
ETensorType::UNDEFINED
;
17
18
for
(
int_t
i = 0; i <
nodeproto
.attribute_size(); i++) {
19
std::string
attribute_name
=
nodeproto
.attribute(i).name();
20
if
(
attribute_name
==
"to"
) {
21
output_type
=
static_cast<
ETensorType
>
(
nodeproto
.attribute(i).i());
22
}
23
}
24
if
(
output_type
==
ETensorType::UNDEFINED
)
25
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser Cast op has invalid output type"
);
26
27
std::string
output_name
=
nodeproto
.output(0);
28
auto
op
= std::make_unique<ROperator_Cast>(
output_type
,
nodeproto
.input(0),
output_name
);
29
30
if
(!parser.
IsRegisteredTensorType
(
output_name
)) {
31
parser.
RegisterTensorType
(
output_name
,
output_type
);
32
}
33
34
return
op
;
35
};
36
37
}
// namespace SOFIE
38
}
// namespace Experimental
39
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_Cast.hxx
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:360
ROOT::Detail::TRangeCast
Definition
TCollection.h:313
TMVA::Experimental::SOFIE::RModelParser_ONNX
Definition
RModelParser_ONNX.hxx:30
TMVA::Experimental::SOFIE::RModelParser_ONNX::IsRegisteredTensorType
bool IsRegisteredTensorType(const std::string &)
Definition
RModelParser_ONNX.cxx:376
TMVA::Experimental::SOFIE::RModelParser_ONNX::RegisterTensorType
void RegisterTensorType(const std::string &, ETensorType)
Definition
RModelParser_ONNX.cxx:371
TMVA::Experimental::SOFIE::ETensorType
ETensorType
Definition
SOFIE_common.hxx:28
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::int_t
std::int64_t int_t
Definition
SOFIE_common.hxx:55
TMVA::Experimental::SOFIE::ParseCast
ParserFuncSignature ParseCast
Definition
ParseCast.cxx:9
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
tmva
sofie_parsers
src
ParseCast.cxx
ROOTmaster - Reference Guide Generated on Sat Apr 11 2026 15:06:27 (GVA Time) using Doxygen 1.10.0