diff --git a/mindspore/ccsrc/debug/common.cc b/mindspore/ccsrc/debug/common.cc index 931e6d4b858..a75b9958226 100644 --- a/mindspore/ccsrc/debug/common.cc +++ b/mindspore/ccsrc/debug/common.cc @@ -80,9 +80,9 @@ bool Common::CreateNotExistDirs(const std::string &path) { char tmp_char = temp_path[i]; temp_path[i] = '\0'; std::string path_handle(temp_path); - if (!fs->FileExist(temp_path)) { + if (!fs->FileExist(path_handle)) { MS_LOG(INFO) << "Dir " << path_handle << " does not exit, creating..."; - if (!fs->CreateDir(temp_path)) { + if (!fs->CreateDir(path_handle)) { MS_LOG(ERROR) << "Create " << path_handle << " dir error"; return false; } diff --git a/mindspore/ccsrc/debug/data_dump_parser.cc b/mindspore/ccsrc/debug/data_dump_parser.cc index 0f8e1bb598e..cd441694a01 100644 --- a/mindspore/ccsrc/debug/data_dump_parser.cc +++ b/mindspore/ccsrc/debug/data_dump_parser.cc @@ -34,7 +34,7 @@ void DataDumpParser::ResetParam() { bool DataDumpParser::DumpEnabled() const { auto enable_dump = std::getenv(kEnableDataDump); - if (!enable_dump) { + if (enable_dump == nullptr) { MS_LOG(INFO) << "[DataDump] enable dump is null. Please export ENABLE_DATA_DUMP"; return false; } @@ -55,13 +55,15 @@ bool DataDumpParser::DumpEnabled() const { std::optional DataDumpParser::GetDumpPath() const { auto dump_path = std::getenv(kDataDumpPath); - if (!dump_path) { + if (dump_path == nullptr) { MS_LOG(ERROR) << "[DataDump] dump path is null. Please export DATA_DUMP_PATH"; return {}; } std::string dump_path_str(dump_path); - if (!std::all_of(dump_path_str.begin(), dump_path_str.end(), ::isalpha)) { - MS_LOG(EXCEPTION) << "[DataDump] dump path only support alphas, but got:" << dump_path_str; + if (!std::all_of(dump_path_str.begin(), dump_path_str.end(), + [](char c) { return ::isalpha(c) || ::isdigit(c) || c == '-' || c == '_' || c == '/'; })) { + MS_LOG(EXCEPTION) << "[DataDump] dump path only support alphabets, digit or {'-', '_', '/'}, but got:" + << dump_path_str; } return dump_path_str; } diff --git a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc index a4509197cee..69b125dd024 100644 --- a/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc +++ b/mindspore/ccsrc/runtime/device/ascend/dump/data_dumper.cc @@ -242,6 +242,11 @@ void DumpKernelOutput(const CNodePtr &kernel, void *args, NotNull(reinterpret_cast(args)) + offset); + // device address data size + auto address = AnfAlgo::GetOutputAddr(kernel, i); + MS_EXCEPTION_IF_NULL(address); + output.set_size(address->GetSize()); + MS_LOG(INFO) << "[DataDump] output " << i << " address size:" << output.size(); MS_EXCEPTION_IF_NULL(task->mutable_output()); task->mutable_output()->Add(std::move(output)); offset += sizeof(void *); @@ -272,6 +277,11 @@ void DumpKernelInput(const CNodePtr &kernel, void *args, NotNulladd_dim(dim); } input.set_address(static_cast(reinterpret_cast(args)) + offset); + // device address data size + auto address = AnfAlgo::GetPrevNodeOutputAddr(kernel, i); + MS_EXCEPTION_IF_NULL(address); + input.set_size(address->GetSize()); + MS_LOG(INFO) << "[DataDump] input " << i << " address size:" << input.size(); MS_EXCEPTION_IF_NULL(task->mutable_input()); task->mutable_input()->Add(std::move(input)); offset += sizeof(void *); diff --git a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc index 6117fe5ecf0..8bd7940f3e8 100644 --- a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc +++ b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.cc @@ -144,17 +144,17 @@ bool ProfilingManager::StartupProfiling(uint32_t device_id) { nlohmann::json startCfg; startCfg["startCfg"] = devices; - if (!ProfStartUp(NOT_NULL(&startCfg))) { + if (!ProfStartUp(startCfg)) { MS_LOG(ERROR) << "ProfMgrStartUp failed."; return false; } return true; } -bool ProfilingManager::ProfStartUp(NotNull startCfg) { +bool ProfilingManager::ProfStartUp(const nlohmann::json &startCfg) { // convert json to string std::stringstream ss; - ss << *startCfg; + ss << startCfg; std::string cfg = ss.str(); MS_LOG(INFO) << "profiling config " << cfg; auto ret = rtProfilerStart(); diff --git a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.h b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.h index 73f9118c5a3..4263f2b2a23 100644 --- a/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.h +++ b/mindspore/ccsrc/runtime/device/ascend/profiling/profiling_manager.h @@ -49,7 +49,7 @@ class ProfilingManager { ~ProfilingManager() { prof_handle_ = nullptr; } private: - bool ProfStartUp(NotNull json); + bool ProfStartUp(const nlohmann::json &json); std::shared_ptr engine_0_; uint32_t device_id_; void *prof_handle_;