From bfb2e09444a81207fe2c9e8dcaea27827f1a4744 Mon Sep 17 00:00:00 2001 From: limingqi107 Date: Thu, 23 Feb 2023 16:29:40 +0800 Subject: [PATCH] fix the sub parameters name empty for tuple parameter expand --- mindspore/ccsrc/backend/common/session/kernel_graph.cc | 7 +++++++ .../ccsrc/runtime/graph_scheduler/actor/actor_dump.cc | 7 ++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mindspore/ccsrc/backend/common/session/kernel_graph.cc b/mindspore/ccsrc/backend/common/session/kernel_graph.cc index c1a3c007c4a..538a5b014c7 100644 --- a/mindspore/ccsrc/backend/common/session/kernel_graph.cc +++ b/mindspore/ccsrc/backend/common/session/kernel_graph.cc @@ -415,12 +415,16 @@ CNodePtr KernelGraph::NewCNode(const CNodePtr &cnode) { ParameterPtr KernelGraph::NewParameter(const ParameterPtr ¶meter) { auto abstract = parameter == nullptr ? std::make_shared() : parameter->abstract(); auto new_parameter = NewParameter(abstract); + MS_EXCEPTION_IF_NULL(new_parameter); // if don't use default parameter = nullptr,it remarks create a new parameter from a old parameter if (parameter != nullptr) { new_parameter->set_name(parameter->name()); if (common::AnfAlgo::IsParameterWeight(parameter)) { new_parameter->set_default_param(parameter->default_param()); } + } else { + // The created parameter name is empty, so set name to ensure that the parameter name is unique. + new_parameter->set_name(new_parameter->UniqueName()); } // create kernel_info form new parameter SetKernelInfoForNode(new_parameter); @@ -430,7 +434,10 @@ ParameterPtr KernelGraph::NewParameter(const ParameterPtr ¶meter) { ParameterPtr KernelGraph::NewParameter(const abstract::AbstractBasePtr &abstract) { ParameterPtr new_parameter = add_parameter(); + MS_EXCEPTION_IF_NULL(new_parameter); new_parameter->set_abstract(abstract); + // The created parameter name is empty, so set name to ensure that the parameter name is unique. + new_parameter->set_name(new_parameter->UniqueName()); // create kernel_info form new parameter SetKernelInfoForNode(new_parameter); AnfAlgo::SetGraphId(graph_id_, new_parameter.get()); diff --git a/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc b/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc index 040e2d04d20..0b5ff276d5b 100644 --- a/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc +++ b/mindspore/ccsrc/runtime/graph_scheduler/actor/actor_dump.cc @@ -197,9 +197,10 @@ void DumpDSActor(const DataSourceActor *actor, std::ofstream &ofs) { MS_EXCEPTION_IF_NULL(data_node.first); const auto &device_tensor = AnfAlgo::GetMutableOutputAddr(data_node.first, data_node.second, false); MS_EXCEPTION_IF_NULL(device_tensor); - ofs << "\t\t\tnode_order_number:" << i << "\tnode_name:" << data_node.first->DebugString() - << "\tindex:" << data_node.second << "\tptr:" << device_tensor->GetPtr() - << "\tsize:" << device_tensor->GetSize() << "\toriginal_ref_count:" << device_tensor->original_ref_count() + ofs << "\t\t\tnode_order_number:" << i << "\tnode_name:" << data_node.first->fullname_with_scope() + << "\tdebug_name:" << data_node.first->DebugString() << "\tindex:" << data_node.second + << "\tptr:" << device_tensor->GetPtr() << "\tsize:" << device_tensor->GetSize() + << "\toriginal_ref_count:" << device_tensor->original_ref_count() << "\tdynamic_ref_count:" << device_tensor->dynamic_ref_count() << "\tflag:" << device_tensor->flag() << "\n "; }