From 6918943f4d178355e9cae771b143aaf96e2bd00a Mon Sep 17 00:00:00 2001 From: jjfeing Date: Wed, 24 Jun 2020 14:19:36 +0800 Subject: [PATCH] fix atomic clean when output or workspace empty --- .../ccsrc/device/ascend/kernel_build_ascend.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/device/ascend/kernel_build_ascend.cc b/mindspore/ccsrc/device/ascend/kernel_build_ascend.cc index 81d5be673..bd0b43634 100644 --- a/mindspore/ccsrc/device/ascend/kernel_build_ascend.cc +++ b/mindspore/ccsrc/device/ascend/kernel_build_ascend.cc @@ -207,7 +207,7 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) { } } // process output - std::vector output_indexs; + std::vector output_indexs = {}; for (size_t i = 0; i < output_num; ++i) { auto param_output = parameters_indexs.at(input_num + workspace_num + i); if (param_output == 1) { @@ -215,9 +215,11 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) { MS_LOG(INFO) << "Atomic clear output index: " << i; } } - AnfAlgo::SetNodeAttr(kAttrAtomicOutputIndexs, MakeValue(output_indexs), kernel_node); + if (!output_indexs.empty()) { + AnfAlgo::SetNodeAttr(kAttrAtomicOutputIndexs, MakeValue(output_indexs), kernel_node); + } // process workspace - std::vector workspace_indexs; + std::vector workspace_indexs = {}; for (size_t k = 0; k < workspace_num; ++k) { auto param_workspace = parameters_indexs.at(input_num + k); if (param_workspace == 1) { @@ -225,8 +227,9 @@ static bool IsAtomicNode(const CNodePtr &kernel_node) { MS_LOG(INFO) << "Atomic clear workspace index: " << k; } } - AnfAlgo::SetNodeAttr(kAttrAtomicWorkspaceIndexs, MakeValue(workspace_indexs), kernel_node); - + if (!workspace_indexs.empty()) { + AnfAlgo::SetNodeAttr(kAttrAtomicWorkspaceIndexs, MakeValue(workspace_indexs), kernel_node); + } return !(workspace_indexs.empty() && output_indexs.empty()); } -- GitLab