ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParseBasicIs.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_Basic_Is.hxx
"
3
#include "
onnx.hxx
"
4
5
namespace
TMVA
{
6
namespace
Experimental {
7
namespace
SOFIE
{
8
9
template
<EBasicIsOperator Op>
10
std::unique_ptr<ROperator>
ParseBasicIs
(
RModelParser_ONNX
&
parser
,
const
onnx::NodeProto
&
nodeproto
)
11
{
12
13
std::string
input_name
=
nodeproto
.input(0);
14
if
(!
parser
.IsRegisteredTensorType(
input_name
)) {
15
throw
16
std::runtime_error(
"TMVA::SOFIE ONNX Parser "
+
IsOpTraits<Op>::Name
() +
" op has input tensor "
+
input_name
+
17
" but its type is not yet registered"
);
18
}
19
20
// get attributes for the IsInf operator
21
int
detect_negative
= 1;
22
int
detect_positive
= 1;
23
for
(
int_t
i = 0; i <
nodeproto
.attribute_size(); i++) {
24
std::string
attribute_name
=
nodeproto
.attribute(i).name();
25
if
(
attribute_name
==
"detect_negative"
)
26
detect_negative
=
nodeproto
.attribute(i).i();
27
if
(
attribute_name
==
"detect_positive"
)
28
detect_positive
=
nodeproto
.attribute(i).i();
29
}
30
31
if
(
detect_positive
== 0 &&
detect_negative
== 0)
32
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser IsInf op has invalide attributes"
);
33
34
35
std::unique_ptr<ROperator>
op
;
36
std::string
output_name
=
nodeproto
.output(0);
37
38
if
(
nodeproto
.attribute_size() == 0 || (
detect_negative
== 1 &&
detect_positive
== 1))
39
op
.reset(
new
ROperator_Basic_Is<Op>
(
input_name
,
output_name
));
40
else
if
(
nodeproto
.attribute_size() > 0) {
41
// case detect_negative or detective_positive are set
42
if
(
detect_negative
== 0)
43
op
.reset(
new
ROperator_Basic_Is<EBasicIsOperator::kIsInfPos>
(
input_name
,
output_name
));
44
else
if
(
detect_positive
== 0)
45
op
.reset(
new
ROperator_Basic_Is<EBasicIsOperator::kIsInfNeg>
(
input_name
,
output_name
));
46
}
else
47
throw
std::runtime_error(
"TMVA::SOFIE ONNX Parser "
+
IsOpTraits<Op>::Name
() +
" operator - invalid attributes"
);
48
49
// Register the output type (is always BOOL)
50
if
(!
parser
.IsRegisteredTensorType(
output_name
)) {
51
parser
.RegisterTensorType(
output_name
,
ETensorType::BOOL
);
52
}
53
54
return
op
;
55
};
56
57
void
RegisterBasicIsParsers
(
RModelParser_ONNX
&
parser
)
58
{
59
parser
.RegisterOperator(
"IsNaN"
,
ParseBasicIs<EBasicIsOperator::kIsNaN>
);
60
parser
.RegisterOperator(
"IsInf"
,
ParseBasicIs<EBasicIsOperator::kIsInf>
);
61
}
62
63
}
// namespace SOFIE
64
}
// namespace Experimental
65
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_Basic_Is.hxx
SOFIE
SOFIE
Definition
SOFIE_common_helpers.cxx:997
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::onnx::NodeProto
Definition
onnx.hxx:504
TMVA::Experimental::SOFIE::ETensorType::BOOL
@ BOOL
TMVA::Experimental::SOFIE::int_t
std::int64_t int_t
Definition
SOFIE_common.hxx:53
TMVA::Experimental::SOFIE::RegisterBasicIsParsers
void RegisterBasicIsParsers(RModelParser_ONNX &parser)
Definition
ParseBasicIs.cxx:57
TMVA::Experimental::SOFIE::ParseBasicIs
std::unique_ptr< ROperator > ParseBasicIs(RModelParser_ONNX &parser, const onnx::NodeProto &nodeproto)
Definition
ParseBasicIs.cxx:10
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
onnx.hxx
TMVA::Experimental::SOFIE::IsOpTraits
Definition
ROperator_Basic_Is.hxx:16
tmva
sofie_parsers
src
ParseBasicIs.cxx
ROOTmaster - Reference Guide Generated on Fri Oct 2 2026 04:42:49 (GVA Time) using Doxygen 1.10.0