Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseArgMax.cxx
Go to the documentation of this file.
3#include "onnx.hxx"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
10 auto input_name = nodeproto.input(0);
11 if (!parser.IsRegisteredTensorType(input_name)) {
12 throw std::runtime_error("TMVA::SOFIE ONNX Parser ArgMax op has input tensor " + input_name +
13 " but its type is not yet registered");
14 }
15
16 // default values as in the ONNX specification
17 int64_t attr_axis = 0;
18 int attr_keepdims = 1;
19 int attr_select_last_index = 0;
20 for (int i = 0; i < nodeproto.attribute_size(); i++) {
21 const std::string &attribute_name = nodeproto.attribute(i).name();
22 if (attribute_name == "axis")
23 attr_axis = nodeproto.attribute(i).i();
24 else if (attribute_name == "keepdims")
25 attr_keepdims = nodeproto.attribute(i).i();
26 else if (attribute_name == "select_last_index")
27 attr_select_last_index = nodeproto.attribute(i).i();
28 }
29
30 std::string output_name = nodeproto.output(0);
31 std::unique_ptr<ROperator> op(
32 new ROperator_ArgMax(attr_axis, attr_keepdims, attr_select_last_index, input_name, output_name));
33
34 // the output contains indices, so it is always INT64
35 if (!parser.IsRegisteredTensorType(output_name)) {
36 parser.RegisterTensorType(output_name, ETensorType::INT64);
37 }
38
39 return op;
40};
41
42} // namespace SOFIE
43} // namespace Experimental
44} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
ParserFuncSignature ParseArgMax
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations