From dbc6147e9b5ff599f6f35b9299674fe0d7e7bd82 Mon Sep 17 00:00:00 2001 From: laiyongqiang Date: Wed, 28 Oct 2020 09:37:09 +0800 Subject: [PATCH] fix bug when add atomic clean for getnext's output --- .../runtime/device/ascend/kernel_build_ascend.cc | 13 +++++++++---- mindspore/ccsrc/runtime/device/kernel_adjust.cc | 6 ++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc b/mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc index 01b0114909..7cb248bc43 100644 --- a/mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc +++ b/mindspore/ccsrc/runtime/device/ascend/kernel_build_ascend.cc @@ -234,10 +234,15 @@ std::map> GetCommunicationOpInputInfo( for (size_t i = 0; i < input_num; i++) { auto input_node = kernel->input(i + 1); auto kernel_input = AnfAlgo::VisitKernelWithReturnType(input_node, 0, true); - if (AnfAlgo::IsCommunicationOp(kernel_input.first)) { - // no need to add atomic for communication op's output - MS_LOG(INFO) << "No need to add atomic clean for communication op " - << kernel_input.first->fullname_with_scope() << "'s output"; + if (!kernel_input.first->isa()) { + continue; + } + auto cnode = kernel_input.first->cast(); + if (AnfAlgo::IsCommunicationOp(cnode) || AnfAlgo::IsIndependentNode(cnode) || + AnfAlgo::GetCNodeName(cnode) == kGetNextOpName) { + // no need to add atomic for communication/independent/getnext op 's output + MS_LOG(INFO) << "No need to add atomic clean for op " << kernel_input.first->fullname_with_scope() + << "'s output"; continue; } MS_LOG(INFO) << "Add atomic clean for single communication op input, comm:" << kernel->fullname_with_scope() diff --git a/mindspore/ccsrc/runtime/device/kernel_adjust.cc b/mindspore/ccsrc/runtime/device/kernel_adjust.cc index a77089314b..64bc184252 100644 --- a/mindspore/ccsrc/runtime/device/kernel_adjust.cc +++ b/mindspore/ccsrc/runtime/device/kernel_adjust.cc @@ -280,6 +280,12 @@ void KernelAdjust::InsertSwitchLoop(const std::shared_ptr for (size_t idx = i + 1; idx < orders.size(); idx++) { cur_cnode = orders[idx]; if (AnfAlgo::HasNodeAttr(kAttrLabelForInsertStreamActive, cur_cnode)) { + auto pre_node = orders[idx - 1]; + auto pre_kernel_name = AnfAlgo::GetCNodeName(pre_node); + if (pre_kernel_name == kAtomicAddrCleanOpName) { + other_list.pop_back(); + memcpy_list.push_back(pre_node); + } memcpy_list.emplace_back(cur_cnode); } else { other_list.emplace_back(cur_cnode);