Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ParseCast.cxx
Go to the documentation of this file.
3#include "onnx_proto3.pb.h"
4
5namespace TMVA {
6namespace Experimental {
7namespace SOFIE {
8
9ParserFuncSignature 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 std::unique_ptr<ROperator> op;
17 std::string attr_type;
18
19 for (int_t i = 0; i < nodeproto.attribute_size(); i++) {
20 std::string attribute_name = nodeproto.attribute(i).name();
21 if (attribute_name == "to")
22 attr_type = ConvertTypeToString(static_cast<ETensorType>(nodeproto.attribute(i).i()));
23 }
24
25 std::string output_name = nodeproto.output(0);
26 op.reset(new ROperator_Cast(attr_type, nodeproto.input(0), output_name));
27
28 if (!parser.IsRegisteredTensorType(output_name)) {
29 ETensorType output_type = ConvertStringToType(attr_type);
30 parser.RegisterTensorType(output_name, output_type);
31 }
32
33 return op;
34};
35
36} // namespace SOFIE
37} // namespace Experimental
38} // namespace TMVA
void RegisterTensorType(const std::string &, ETensorType)
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
ParserFuncSignature ParseCast
Definition ParseCast.cxx:9
std::string ConvertTypeToString(ETensorType type)
ETensorType ConvertStringToType(std::string type)
create variable transformations