ROOT
master
Reference Guide
Loading...
Searching...
No Matches
ParseGather.cxx
Go to the documentation of this file.
1
#include "
TMVA/RModelParser_ONNX.hxx
"
2
#include "
TMVA/ROperator_Gather.hxx
"
3
#include "onnx_proto3.pb.h"
4
#include <stdexcept>
5
6
namespace
TMVA
{
7
namespace
Experimental {
8
namespace
SOFIE {
9
10
ParserFuncSignature
ParseGather
= [](
RModelParser_ONNX
&parser,
const
onnx::NodeProto &
nodeproto
) {
11
ETensorType
input_type
=
ETensorType::UNDEFINED
;
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 Gather op has input tensor"
+
input_name
+
17
" but its type is not yet registered"
);
18
}
19
20
ETensorType
indices_type
=
ETensorType::UNDEFINED
;
21
auto
indices_name
=
nodeproto
.input(1);
22
// indices_type can be an initialized tensor, no need to emit an error if it is not registered
23
if
(parser.
IsRegisteredTensorType
(
indices_name
)) {
24
indices_type
= parser.
GetTensorType
(
indices_name
);
25
if
(
indices_type
!=
ETensorType::INT64
&&
indices_type
!=
ETensorType::INT32
) {
26
throw
27
std::runtime_error(
"TMVA::SOFIE ONNX Parser Gather op Indices tensor type not supported."
);
28
}
29
}
30
31
std::unique_ptr<ROperator>
op
;
32
std::string
output_name
=
nodeproto
.output(0);
33
int64_t
attr_axis
= 0;
34
if
(
nodeproto
.attribute_size() == 1) {
35
attr_axis
=
nodeproto
.attribute(0).i();
36
}
37
38
op
.reset(
new
ROperator_Gather
(
attr_axis
,
input_name
,
indices_name
,
nodeproto
.output(0)));
39
40
if
(!parser.
IsRegisteredTensorType
(
output_name
)) {
41
parser.
RegisterTensorType
(
output_name
,
input_type
);
42
}
43
44
return
op
;
45
};
46
47
}
// namespace SOFIE
48
}
// namespace Experimental
49
}
// namespace TMVA
RModelParser_ONNX.hxx
ROperator_Gather.hxx
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TMVA::Experimental::SOFIE::RModelParser_ONNX
Definition
RModelParser_ONNX.hxx:28
TMVA::Experimental::SOFIE::RModelParser_ONNX::IsRegisteredTensorType
bool IsRegisteredTensorType(const std::string &)
Definition
RModelParser_ONNX.cxx:269
TMVA::Experimental::SOFIE::RModelParser_ONNX::RegisterTensorType
void RegisterTensorType(const std::string &, ETensorType)
Definition
RModelParser_ONNX.cxx:264
TMVA::Experimental::SOFIE::RModelParser_ONNX::GetTensorType
ETensorType GetTensorType(const std::string &name)
Definition
RModelParser_ONNX.cxx:274
TMVA::Experimental::SOFIE::ROperator_Gather
Definition
ROperator_Gather.hxx:17
TMVA::Experimental::SOFIE::ParseGather
ParserFuncSignature ParseGather
Definition
ParseGather.cxx:10
TMVA::Experimental::SOFIE::ETensorType
ETensorType
Definition
SOFIE_common.hxx:28
TMVA::Experimental::SOFIE::ETensorType::UNDEFINED
@ UNDEFINED
TMVA::Experimental::SOFIE::ETensorType::INT64
@ INT64
TMVA::Experimental::SOFIE::ETensorType::INT32
@ INT32
TMVA::Experimental::SOFIE::ParserFuncSignature
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
Definition
RModelParser_ONNX.hxx:23
TMVA
create variable transformations
Definition
GeneticMinimizer.h:22
tmva
sofie_parsers
src
ParseGather.cxx
ROOT master - Reference Guide Generated on Sun Apr 20 2025 15:38:18 (GVA Time) using Doxygen 1.10.0