| 617 | } |
| 618 | |
| 619 | node_t create_graph_node(graph_t graph, const char* node_name, const char* op_name) |
| 620 | { |
| 621 | GraphExecutor* executor = reinterpret_cast<GraphExecutor*>(graph); |
| 622 | |
| 623 | if(executor->PrerunDone()) |
| 624 | { |
| 625 | set_tengine_errno(EACCES); |
| 626 | return nullptr; |
| 627 | } |
| 628 | |
| 629 | Graph* real_graph = executor->GetGraph(); |
| 630 | |
| 631 | /* check if duplicate name */ |
| 632 | if(real_graph->FindNode(node_name)) |
| 633 | { |
| 634 | set_tengine_errno(EEXIST); |
| 635 | return nullptr; |
| 636 | } |
| 637 | |
| 638 | Operator* op = OpManager::CreateOp(op_name); |
| 639 | |
| 640 | if(op == nullptr) |
| 641 | { |
| 642 | set_tengine_errno(ENOENT); |
| 643 | return nullptr; |
| 644 | } |
| 645 | |
| 646 | Node* new_node = new Node(node_name); |
| 647 | |
| 648 | if(new_node == nullptr) |
| 649 | { |
| 650 | set_tengine_errno(ENOMEM); |
| 651 | return new_node; |
| 652 | } |
| 653 | |
| 654 | new_node->SetOp(op); |
| 655 | |
| 656 | real_graph->AddNode(new_node); |
| 657 | |
| 658 | new_node->SetAttr(ATTR_API_GRAPH, executor); |
| 659 | |
| 660 | return new_node; |
| 661 | } |
| 662 | |
| 663 | node_t get_graph_node(graph_t graph, const char* node_name) |
| 664 | { |