!23242 Fix wrong device target bug when multi-target scene.

Merge pull request !23242 from liangzelang/opt_loadinputs
This commit is contained in:
i-robot 2021-09-11 08:31:03 +00:00 committed by Gitee
commit 6b0e8fef6b
2 changed files with 5 additions and 2 deletions

View File

@ -459,7 +459,7 @@ void AscendSession::LoadInputData(const std::shared_ptr<KernelGraph> &kernel_gra
tensor->set_sync_status(kNoNeedSync);
}
if (device_memcpy_nums > 0) {
auto runtime_instance = device::KernelRuntimeManager::Instance().GetCurrentKernelRuntime();
auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id_);
MS_EXCEPTION_IF_NULL(runtime_instance);
auto compute_stream = runtime_instance->compute_stream();
auto model_stream = runtime_instance->GetModelStream(kernel_graph->graph_id());

View File

@ -98,7 +98,10 @@ bool AsyncMemcpy(void *dst, uint64_t dst_size, const void *src, uint64_t src_siz
MS_LOG(INFO) << "dst addr is same with src addr, no need memcpy data.";
return true;
}
auto runtime_instance = device::KernelRuntimeManager::Instance().GetCurrentKernelRuntime();
auto ms_context = MsContext::GetInstance();
MS_EXCEPTION_IF_NULL(ms_context);
auto device_id = ms_context->get_param<uint32_t>(MS_CTX_DEVICE_ID);
auto runtime_instance = device::KernelRuntimeManager::Instance().GetKernelRuntime(kAscendDevice, device_id);
MS_EXCEPTION_IF_NULL(runtime_instance);
auto ret = runtime_instance->MemcpyAsync(dst, src, src_size, static_cast<int32_t>(RT_MEMCPY_DEVICE_TO_DEVICE));
if (!ret) {