From 9ce7919712f04045419902169eb3c2759ba42e43 Mon Sep 17 00:00:00 2001 From: caifubi Date: Fri, 18 Sep 2020 16:45:28 +0800 Subject: [PATCH] clean dump codex --- mindspore/ccsrc/debug/common.cc | 6 +++++- .../ccsrc/runtime/device/ascend/dump/data_dumper.cc | 10 +++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mindspore/ccsrc/debug/common.cc b/mindspore/ccsrc/debug/common.cc index 36b3675338..f3abbbc566 100644 --- a/mindspore/ccsrc/debug/common.cc +++ b/mindspore/ccsrc/debug/common.cc @@ -119,7 +119,11 @@ std::optional Common::GetConfigFile(const std::string &env) { MS_LOG(ERROR) << dump_config_file << " not exist."; return {}; } - auto suffix = dump_config_file.substr(dump_config_file.find_last_of('.') + 1); + auto point_pos = dump_config_file.find_last_of('.'); + if (point_pos == std::string::npos) { + MS_LOG(EXCEPTION) << "Invalid json file name:" << dump_config_file; + } + auto suffix = dump_config_file.substr(point_pos + 1); if (suffix != "json") { MS_LOG(EXCEPTION) << "[DataDump] dump config file suffix only support json! But got:." << suffix; } diff --git a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc index 6afb36724e..58e7f23446 100644 --- a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc +++ b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc @@ -333,15 +333,15 @@ void DataDumper::RtLoadDumpData(const aicpu::dump::OpMappingInfo &dump_info, voi MS_LOG(EXCEPTION) << "[DataDump] Protobuf SerializeToString failed, proto size %zu."; } - rtError_t rt_ret = rtMalloc(ptr, proto_size, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - MS_LOG(EXCEPTION) << "[DataDump] Call rtMalloc failed"; - } - if (ptr == nullptr) { MS_LOG(ERROR) << "[DataDump] rtMalloc failed, ptr is nullptr"; return; } + + rtError_t rt_ret = rtMalloc(ptr, proto_size, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + MS_LOG(EXCEPTION) << "[DataDump] Call rtMalloc failed"; + } rt_ret = rtMemcpy(*ptr, proto_size, proto_str.c_str(), proto_size, RT_MEMCPY_HOST_TO_DEVICE); if (rt_ret != RT_ERROR_NONE) { MS_LOG(EXCEPTION) << "[DataDump] Call rtMemcpy failed";