3#include "onnx_proto3.pb.h"
6namespace Experimental {
14 if (nodeproto.op_type() ==
"Flatten")
16 else if (nodeproto.op_type() ==
"Squeeze")
18 else if (nodeproto.op_type() ==
"Unsqueeze")
23 auto input_name = nodeproto.input(0);
25 auto shape_name = ((nodeproto.input_size() > 1) && ( opMode ==
Reshape || opMode ==
Unsqueeze || opMode ==
Squeeze) )
26 ? nodeproto.input(1) :
"";
30 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser Reshape op has input tensor" + input_name +
31 " but its type is not yet registered");
37 std::unique_ptr<ROperator> op;
38 int attr_value = (opMode ==
Reshape) ? 0 : 1;
39 if (opMode ==
Reshape && nodeproto.attribute_size() > 0)
40 attr_value = nodeproto.attribute(0).i();
42 std::vector<int64_t> attr_axes = {};
43 if (nodeproto.input_size() == 1 && (opMode ==
Squeeze || opMode ==
Unsqueeze)) {
44 std::string attribute_name = nodeproto.attribute(0).name();
45 if (attribute_name ==
"axes")
46 attr_axes = {nodeproto.attribute(0).ints().begin(), nodeproto.attribute(0).ints().end()};
49 std::string output_name = nodeproto.output(0);
52 if (attr_axes.empty())
58 throw std::runtime_error(
"TMVA::SOFIE - Unsupported - Operator Reshape does not yet support input type " +
59 std::to_string(
static_cast<int>(input_type)));
bool IsRegisteredTensorType(const std::string &)
void RegisterTensorType(const std::string &, ETensorType)
ETensorType GetTensorType(const std::string &name)
ParserFuncSignature ParseReshape
std::function< std::unique_ptr< ROperator >(RModelParser_ONNX &, const onnx::NodeProto &)> ParserFuncSignature
create variable transformations