clean dump codex

This commit is contained in:
caifubi 2020-09-18 16:45:28 +08:00
parent cd88f58b88
commit 9ce7919712
2 changed files with 10 additions and 6 deletions

View File

@ -119,7 +119,11 @@ std::optional<std::string> 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;
}

View File

@ -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";