From baad7b48d3f687e644be690a404eac8a384bde48 Mon Sep 17 00:00:00 2001 From: John Tzanakakis Date: Wed, 23 Jun 2021 17:32:07 -0400 Subject: [PATCH] validate dump iteration and net_name, use device shape for trans_flag false --- mindspore/ccsrc/debug/data_dump/dump_json_parser.cc | 12 +++++++----- .../runtime/device/ascend/ascend_device_address.cc | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc b/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc index c9b8231deac..4e49fd52d10 100644 --- a/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc +++ b/mindspore/ccsrc/debug/data_dump/dump_json_parser.cc @@ -317,9 +317,9 @@ void DumpJsonParser::ParseDumpPath(const nlohmann::json &content) { void DumpJsonParser::ParseNetName(const nlohmann::json &content) { CheckJsonStringType(content, kNetName); net_name_ = content; - if (!std::all_of(net_name_.begin(), net_name_.end(), - [](char c) { return ::isalpha(c) || ::isdigit(c) || c == '-' || c == '_'; })) { - MS_LOG(EXCEPTION) << "Dump path only support alphabets, digit or {'-', '_'}, but got:" << net_name_; + if (net_name_.empty() || !std::all_of(net_name_.begin(), net_name_.end(), + [](char c) { return ::isalpha(c) || ::isdigit(c) || c == '-' || c == '_'; })) { + MS_LOG(EXCEPTION) << "net_name only supports alphabetic, digit, or {'-', '_'}, but got: " << net_name_; } } @@ -327,8 +327,10 @@ void DumpJsonParser::ParseIteration(const nlohmann::json &content) { CheckJsonStringType(content, kIteration); if (e2e_dump_enabled_ || async_dump_enabled_) { iteration_ = content; - if (iteration_.empty()) { - MS_LOG(EXCEPTION) << "In async dump settings json file, iteration is empty"; + if (iteration_.empty() || (!std::all_of(iteration_.begin(), iteration_.end(), [](char c) { + return ::isdigit(c) || c == '-' || c == '|'; + }) && iteration_ != "all")) { + MS_LOG(EXCEPTION) << "iteration only supports digits, {'-', '|'}, or just \"all\" but got: " << iteration_; } } else { MS_LOG(EXCEPTION) << "Dump Json Parse Failed. Async or E2E should be enabled. "; diff --git a/mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc b/mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc index 04215057e6f..5832e9c5052 100644 --- a/mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc +++ b/mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc @@ -685,7 +685,7 @@ bool AscendDeviceAddress::DumpMemToFile(const std::string &filepath, const std:: } std::string path = filepath + '.' + format_; MS_LOG(INFO) << "E2E Dump path is " << path; - ret = DumpJsonParser::DumpToFile(path, host_tmp.data(), size_, host_shape_, type_id_); + ret = DumpJsonParser::DumpToFile(path, host_tmp.data(), size_, host_shape, type_id_); } return ret;