From ff5dc9963dda2f466b3b8886f10f2702c891c1ef Mon Sep 17 00:00:00 2001 From: kisnwang Date: Thu, 22 Dec 2022 23:11:04 +0800 Subject: [PATCH] execorder add dependency for seed node --- .../ccsrc/backend/common/session/exec_order_builder.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/backend/common/session/exec_order_builder.cc b/mindspore/ccsrc/backend/common/session/exec_order_builder.cc index a9bc27f0756..b61ccec6d25 100644 --- a/mindspore/ccsrc/backend/common/session/exec_order_builder.cc +++ b/mindspore/ccsrc/backend/common/session/exec_order_builder.cc @@ -148,7 +148,7 @@ void ExecOrderBuilder::FindIndependentNodes() { MS_EXCEPTION_IF_NULL(cnode); bool independent = true; auto &inputs = cnode->inputs(); - for (auto iter = inputs.begin(); iter != inputs.end(); ++iter) { + for (auto iter = inputs.rbegin(); iter != inputs.rend(); ++iter) { auto &input = *iter; MS_EXCEPTION_IF_NULL(input); if (IsTrivialNode(input)) { @@ -164,6 +164,13 @@ void ExecOrderBuilder::FindIndependentNodes() { } if (AnfUtils::IsRealKernel(node)) { to_visit.push(input); + if (!independent_nodes_.empty()) { + auto inode = independent_nodes_.top(); + node_output_edges_[input].emplace_back(inode); + node_input_edges_[inode].emplace_back(input); + node_input_num_[inode] += 1; + independent_nodes_.pop(); + } } else { vnode_to_visit.push(input); }