validate dump iteration and net_name, use device shape for trans_flag false

This commit is contained in:
John Tzanakakis 2021-06-23 17:32:07 -04:00
parent 690cf18cba
commit baad7b48d3
2 changed files with 8 additions and 6 deletions

View File

@ -317,9 +317,9 @@ void DumpJsonParser::ParseDumpPath(const nlohmann::json &content) {
void DumpJsonParser::ParseNetName(const nlohmann::json &content) { void DumpJsonParser::ParseNetName(const nlohmann::json &content) {
CheckJsonStringType(content, kNetName); CheckJsonStringType(content, kNetName);
net_name_ = content; net_name_ = content;
if (!std::all_of(net_name_.begin(), net_name_.end(), if (net_name_.empty() || !std::all_of(net_name_.begin(), net_name_.end(),
[](char c) { return ::isalpha(c) || ::isdigit(c) || c == '-' || c == '_'; })) { [](char c) { return ::isalpha(c) || ::isdigit(c) || c == '-' || c == '_'; })) {
MS_LOG(EXCEPTION) << "Dump path only support alphabets, digit or {'-', '_'}, but got:" << net_name_; 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); CheckJsonStringType(content, kIteration);
if (e2e_dump_enabled_ || async_dump_enabled_) { if (e2e_dump_enabled_ || async_dump_enabled_) {
iteration_ = content; iteration_ = content;
if (iteration_.empty()) { if (iteration_.empty() || (!std::all_of(iteration_.begin(), iteration_.end(), [](char c) {
MS_LOG(EXCEPTION) << "In async dump settings json file, iteration is empty"; return ::isdigit(c) || c == '-' || c == '|';
}) && iteration_ != "all")) {
MS_LOG(EXCEPTION) << "iteration only supports digits, {'-', '|'}, or just \"all\" but got: " << iteration_;
} }
} else { } else {
MS_LOG(EXCEPTION) << "Dump Json Parse Failed. Async or E2E should be enabled. "; MS_LOG(EXCEPTION) << "Dump Json Parse Failed. Async or E2E should be enabled. ";

View File

@ -685,7 +685,7 @@ bool AscendDeviceAddress::DumpMemToFile(const std::string &filepath, const std::
} }
std::string path = filepath + '.' + format_; std::string path = filepath + '.' + format_;
MS_LOG(INFO) << "E2E Dump path is " << path; 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; return ret;