浏览代码

!9455 print trace info when cpu init/run failed

From: @kisnwang
Reviewed-by: @chujinjin,@jjfeing
Signed-off-by: @jjfeing
tags/v1.1.0
mindspore-ci-bot Gitee 5 年前
父节点
当前提交
97a10bfa7c
共有 2 个文件被更改,包括 14 次插入3 次删除
  1. +6
    -1
      mindspore/ccsrc/backend/session/cpu_session.cc
  2. +8
    -2
      mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc

+ 6
- 1
mindspore/ccsrc/backend/session/cpu_session.cc 查看文件

@@ -17,6 +17,7 @@
#include "backend/session/cpu_session.h"
#include <algorithm>
#include <sstream>
#include <exception>
#include "ir/anf.h"
#include "utils/ms_utils.h"
#include "utils/trace_base.h"
@@ -262,7 +263,11 @@ void CPUSession::BuildKernel(const KernelGraph *kernel_graph) {
if (cpu_kernel == nullptr) {
KernelNotSupportException(kernel_node);
}
cpu_kernel->Init(kernel_node);
try {
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());
MS_LOG(INFO) << "Cpu build success operator[" << kernel_name << "].";
}


+ 8
- 2
mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc 查看文件

@@ -21,6 +21,7 @@
#include <utility>
#include <algorithm>
#include <functional>
#include <exception>
#include "backend/kernel_compiler/kernel.h"
#include "runtime/device/cpu/cpu_device_address.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);
AddRuntimeAddress(device_address, &kernel_workspaces);
}
auto ret = kernel_mod->Launch(kernel_inputs, kernel_workspaces, kernel_outputs, 0);
resource_manager_.DecreaseAddressRefCount(kernel);
bool ret = true;
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) {
MS_LOG(EXCEPTION) << "Launch kernel failed. Trace:" << trace::DumpSourceLines(kernel);
}
resource_manager_.DecreaseAddressRefCount(kernel);
#ifdef ENABLE_PROFILE
double cost_time = GetTime() - start_time;
MS_LOG(INFO) << "cpu kernel: " << kernel->fullname_with_scope() << " costs " << cost_time * 1e6 << " us";


正在加载...
取消
保存