12 auto input_name = nodeproto.input(0);
14 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser If op has input tensor" + input_name +
15 " but its type is not yet registered");
18 if (nodeproto.attribute_size() != 2) {
19 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser If op has not 2 attributes");
23 for (
int_t i = 0; i < nodeproto.attribute_size(); i++) {
24 std::string attribute_name = nodeproto.attribute(i).name();
25 if (attribute_name ==
"then_branch") {
28 else if (attribute_name ==
"else_branch") {
32 if (else_index < 0 || then_index < 0)
33 throw std::runtime_error(
"TMVA::SOFIE ONNX Parser If has wrong attributes");
35 auto then_graph = nodeproto.attribute(then_index).g();
36 auto else_graph = nodeproto.attribute(else_index).g();
39 auto model_then = std::make_unique<RModel>(then_graph.name(),
"");
40 auto model_else = std::make_unique<RModel>(else_graph.name(),
"");
42 std::vector<std::string> outputNames;
43 for (
int i = 0; i < nodeproto.output_size(); i++) {
44 outputNames.push_back(nodeproto.output(i));
50 std::unique_ptr<ROperator> op(
new ROperator_If(input_name, outputNames, std::move(model_then), std::move(model_else)));
52 for (
size_t i = 0; i < outputNames.size(); i++) {
54 std::string out_g_name = then_graph.output(i).name();
56 std::string output_name = outputNames[i];