From 86c69d116b587bf7e47e1ccfd0d80d2cbf908a55 Mon Sep 17 00:00:00 2001 From: limingqi107 Date: Thu, 29 Jul 2021 11:02:28 +0800 Subject: [PATCH] unified runtime bug of host device and graph kernel --- mindspore/ccsrc/backend/session/kernel_graph.cc | 6 ------ mindspore/ccsrc/runtime/framework/actor/actor_common.cc | 6 +++++- mindspore/ccsrc/runtime/framework/actor/copy_actor.cc | 7 +++++++ mindspore/core/mindrt/src/thread/actor_threadpool.cc | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/mindspore/ccsrc/backend/session/kernel_graph.cc b/mindspore/ccsrc/backend/session/kernel_graph.cc index 04ee9c7e056..a108be59a6f 100644 --- a/mindspore/ccsrc/backend/session/kernel_graph.cc +++ b/mindspore/ccsrc/backend/session/kernel_graph.cc @@ -1216,7 +1216,6 @@ void KernelGraph::UpdateGraphOutputMap(const std::vector &old_o if (old_output == new_output) { continue; } - // Update the graph output map. if (graph_output_to_front_node_map_.count(old_output) > 0) { MS_LOG(INFO) << "Replace backend output node " << old_output.first->fullname_with_scope() << " with index " @@ -1226,11 +1225,6 @@ void KernelGraph::UpdateGraphOutputMap(const std::vector &old_o graph_output_to_front_node_map_.erase(old_output); } - // Update the internal output map. - if (IsInternalOutput(old_output.first, old_output.second)) { - ReplaceInternalOutput(old_output.first, new_output.first, old_output.second, new_output.second); - } - if (old_output.first == new_output.first) { continue; } diff --git a/mindspore/ccsrc/runtime/framework/actor/actor_common.cc b/mindspore/ccsrc/runtime/framework/actor/actor_common.cc index 9af9b0216a6..fdbc11d7e50 100644 --- a/mindspore/ccsrc/runtime/framework/actor/actor_common.cc +++ b/mindspore/ccsrc/runtime/framework/actor/actor_common.cc @@ -32,7 +32,7 @@ void ComputeThreadNums(size_t *actor_thread_num, size_t *OMP_thread_num) { auto context_ptr = MsContext::GetInstance(); MS_EXCEPTION_IF_NULL(context_ptr); // The pyNative mode is the step execution strategy, so only need the kActorThreadMinNum. - if (context_ptr->get_param(MS_CTX_SAVE_GRAPHS_FLAG) == kPynativeMode) { + if (context_ptr->get_param(MS_CTX_EXECUTION_MODE) == kPynativeMode) { *actor_thread_num = kActorThreadMinNum; } else { *actor_thread_num = cpu_core_num < kActorThreadMinNum ? kActorThreadMinNum : cpu_core_num; @@ -117,6 +117,10 @@ bool IsGatherActor(const AnfNodePtr &front_node, bool Copy(DeviceTensor *dst_device_tensor, const DeviceTensor *src_device_tensor) { MS_EXCEPTION_IF_NULL(dst_device_tensor); MS_EXCEPTION_IF_NULL(src_device_tensor); + if (src_device_tensor->GetSize() != dst_device_tensor->GetSize()) { + MS_LOG(WARNING) << " Copy size is not equal, input size:" << src_device_tensor->GetSize() + << ", output size:" << dst_device_tensor->GetSize(); + } // Exist the size alignment in some device, so get the min device size. size_t copy_size = std::min(src_device_tensor->GetSize(), dst_device_tensor->GetSize()); diff --git a/mindspore/ccsrc/runtime/framework/actor/copy_actor.cc b/mindspore/ccsrc/runtime/framework/actor/copy_actor.cc index 10510227630..660c2213218 100644 --- a/mindspore/ccsrc/runtime/framework/actor/copy_actor.cc +++ b/mindspore/ccsrc/runtime/framework/actor/copy_actor.cc @@ -72,6 +72,13 @@ void CopyActor::SendMemoryFreeReq(OpContext *context) { void CopyActor::OnMemoryAllocFinish(OpContext *context) { MS_EXCEPTION_IF_NULL(context); + MS_EXCEPTION_IF_NULL(output_device_tensor_[0]); + MS_EXCEPTION_IF_NULL(input_device_tensor_[0]); + + if (input_device_tensor_[0]->GetSize() != output_device_tensor_[0]->GetSize()) { + MS_LOG(WARNING) << GetAID().Name() << " copy size is not equal, input size:" << input_device_tensor_[0]->GetSize() + << ", output size:" << output_device_tensor_[0]->GetSize(); + } if (!Copy(output_device_tensor_[0], input_device_tensor_[0])) { std::string error_info = "Copy device tensor failed: " + GetAID().Name(); diff --git a/mindspore/core/mindrt/src/thread/actor_threadpool.cc b/mindspore/core/mindrt/src/thread/actor_threadpool.cc index fb81db4e8cb..2427a84da48 100644 --- a/mindspore/core/mindrt/src/thread/actor_threadpool.cc +++ b/mindspore/core/mindrt/src/thread/actor_threadpool.cc @@ -18,7 +18,7 @@ #include "thread/core_affinity.h" namespace mindspore { -constexpr size_t MAX_READY_ACTOR_NR = 1024; +constexpr size_t MAX_READY_ACTOR_NR = 4096; void ActorWorker::CreateThread(ActorThreadPool *pool) { THREAD_RETURN_IF_NULL(pool); pool_ = pool;