From 3357181d725763ef008637bcb60d339d4142c77e Mon Sep 17 00:00:00 2001 From: chujinjin Date: Tue, 10 Nov 2020 19:40:35 +0800 Subject: [PATCH] fix error when graph and pynative mode mixed excution --- mindspore/ccsrc/runtime/device/kernel_runtime.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mindspore/ccsrc/runtime/device/kernel_runtime.cc b/mindspore/ccsrc/runtime/device/kernel_runtime.cc index e634fd6c45..665d11d62f 100644 --- a/mindspore/ccsrc/runtime/device/kernel_runtime.cc +++ b/mindspore/ccsrc/runtime/device/kernel_runtime.cc @@ -845,6 +845,15 @@ bool KernelRuntime::LaunchKernel(const session::KernelGraph *graph) { MS_LOG(ERROR) << "LaunchKernelMod failed!"; return false; } + + auto ms_context = MsContext::GetInstance(); + MS_EXCEPTION_IF_NULL(ms_context); + if (ms_context->get_param(MS_CTX_EXECUTION_MODE) == kGraphMode) { + if (!SyncStream()) { + MS_LOG(ERROR) << "SyncStream failed"; + return false; + } + } return true; }