| 627 | } |
| 628 | |
| 629 | void SubgraphTask::Init(GraphTask* graph_tsk) |
| 630 | { |
| 631 | graph_task = graph_tsk; |
| 632 | Graph* graph = graph_task->GetGraph(); |
| 633 | const ExecAttr* p_exec_attr = graph_task->GetExecAttr(); |
| 634 | |
| 635 | exec_priority = p_exec_attr->priority; |
| 636 | |
| 637 | // check if it is a global output task |
| 638 | for(auto e : sub_graph->output_nodes) |
| 639 | { |
| 640 | for(auto m : graph->output_nodes) |
| 641 | { |
| 642 | if(e == m) |
| 643 | { |
| 644 | is_output_task = true; |
| 645 | break; |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | |
| 650 | saved_input_wait_count_ = 0; |
| 651 | |
| 652 | // for input nodes, calculate the input_wait_mask |
| 653 | for(Node* node : sub_graph->input_nodes) |
| 654 | { |
| 655 | std::uint64_t mask = 0; |
| 656 | |
| 657 | for(unsigned int i = 0; i < node->GetInputNum(); i++) |
| 658 | { |
| 659 | NodePort* port = node->GetInputPort(i); |
| 660 | Tensor* tensor = port->tensor; |
| 661 | |
| 662 | if(tensor->GetType() == kVarTensor) |
| 663 | { |
| 664 | /* check if parent is in the same graph or not */ |
| 665 | Node* parent = tensor->producer->owner; |
| 666 | bool parent_in_graph = false; |
| 667 | |
| 668 | for(unsigned int i = 0; i < sub_graph->seq_nodes.size(); i++) |
| 669 | { |
| 670 | if(parent == sub_graph->seq_nodes[i]) |
| 671 | { |
| 672 | parent_in_graph = true; |
| 673 | break; |
| 674 | } |
| 675 | } |
| 676 | |
| 677 | if(!parent_in_graph) |
| 678 | mask |= 1 << port->port_index; |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | if(mask) |
| 683 | { |
| 684 | SetNodeInputWaitMask(node, mask); |
| 685 | CreateNodeInputWaitCounter(node); |
| 686 | auto p_counter = GetNodeInputWaitCounter(node); |
no test coverage detected