!9455 print trace info when cpu init/run failed

From: @kisnwang
Reviewed-by: @chujinjin,@jjfeing
Signed-off-by: @jjfeing
pull/9455/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 97a10bfa7c

@ -17,6 +17,7 @@
#include "backend/session/cpu_session.h" #include "backend/session/cpu_session.h"
#include <algorithm> #include <algorithm>
#include <sstream> #include <sstream>
#include <exception>
#include "ir/anf.h" #include "ir/anf.h"
#include "utils/ms_utils.h" #include "utils/ms_utils.h"
#include "utils/trace_base.h" #include "utils/trace_base.h"
@ -262,7 +263,11 @@ void CPUSession::BuildKernel(const KernelGraph *kernel_graph) {
if (cpu_kernel == nullptr) { if (cpu_kernel == nullptr) {
KernelNotSupportException(kernel_node); KernelNotSupportException(kernel_node);
} }
try {
cpu_kernel->Init(kernel_node); cpu_kernel->Init(kernel_node);
} catch (std::exception &e) {
MS_LOG(EXCEPTION) << e.what() << "\nTrace: " << trace::DumpSourceLines(kernel_node);
}
AnfAlgo::SetKernelMod(cpu_kernel, kernel_node.get()); AnfAlgo::SetKernelMod(cpu_kernel, kernel_node.get());
MS_LOG(INFO) << "Cpu build success operator[" << kernel_name << "]."; MS_LOG(INFO) << "Cpu build success operator[" << kernel_name << "].";
} }

@ -21,6 +21,7 @@
#include <utility> #include <utility>
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <exception>
#include "backend/kernel_compiler/kernel.h" #include "backend/kernel_compiler/kernel.h"
#include "runtime/device/cpu/cpu_device_address.h" #include "runtime/device/cpu/cpu_device_address.h"
#include "utils/ms_context.h" #include "utils/ms_context.h"
@ -371,11 +372,16 @@ bool CPUKernelRuntime::Run(session::KernelGraph *kernel_graph, bool is_task_sink
MS_EXCEPTION_IF_NULL(device_address); MS_EXCEPTION_IF_NULL(device_address);
AddRuntimeAddress(device_address, &kernel_workspaces); AddRuntimeAddress(device_address, &kernel_workspaces);
} }
auto ret = kernel_mod->Launch(kernel_inputs, kernel_workspaces, kernel_outputs, 0); bool ret = true;
resource_manager_.DecreaseAddressRefCount(kernel); try {
ret = kernel_mod->Launch(kernel_inputs, kernel_workspaces, kernel_outputs, 0);
} catch (std::exception &e) {
MS_LOG(EXCEPTION) << e.what() << "\nTrace:" << trace::DumpSourceLines(kernel);
}
if (!ret) { if (!ret) {
MS_LOG(EXCEPTION) << "Launch kernel failed. Trace:" << trace::DumpSourceLines(kernel); MS_LOG(EXCEPTION) << "Launch kernel failed. Trace:" << trace::DumpSourceLines(kernel);
} }
resource_manager_.DecreaseAddressRefCount(kernel);
#ifdef ENABLE_PROFILE #ifdef ENABLE_PROFILE
double cost_time = GetTime() - start_time; double cost_time = GetTime() - start_time;
MS_LOG(INFO) << "cpu kernel: " << kernel->fullname_with_scope() << " costs " << cost_time * 1e6 << " us"; MS_LOG(INFO) << "cpu kernel: " << kernel->fullname_with_scope() << " costs " << cost_time * 1e6 << " us";

Loading…
Cancel
Save