diff --git a/mindspore/ccsrc/debug/data_dump/npy_header.cc b/mindspore/ccsrc/debug/data_dump/npy_header.cc index def70dc6b61..6f4e42e9e14 100644 --- a/mindspore/ccsrc/debug/data_dump/npy_header.cc +++ b/mindspore/ccsrc/debug/data_dump/npy_header.cc @@ -113,7 +113,7 @@ void int_to_byte(size_t number, char *byte, size_t length) { std::string GenerateNpyHeader(const ShapeVector &shape, TypeId type_id, bool fortran_order) { auto type_desc = type_desc_map.find(type_id); if (type_desc == type_desc_map.end()) { - MS_LOG(WARNING) << "Not support dump the " << TypeIdToType(type_id)->ToString() << " data to npy file."; + MS_LOG(INFO) << "Not support dump the " << TypeIdToType(type_id)->ToString() << " data to npy file."; return std::string(); } diff --git a/mindspore/ccsrc/debug/debug_services.cc b/mindspore/ccsrc/debug/debug_services.cc index ef0654d93bb..de6330e63a1 100644 --- a/mindspore/ccsrc/debug/debug_services.cc +++ b/mindspore/ccsrc/debug/debug_services.cc @@ -636,16 +636,22 @@ void DebugServices::AddToTensorData(const std::string &backend_name, const std:: void DebugServices::SetPrefixToCheck(std::string *prefix_dump_file_name, std::string *dump_style_kernel_name, size_t slot) { + std::string dump_style_name_part = *dump_style_kernel_name; + std::size_t last_scope_marker; + std::string delim; if (is_sync_mode) { - std::string dump_style_name_part = *dump_style_kernel_name; - std::size_t last_scope_marker = dump_style_kernel_name->rfind("--"); - if (last_scope_marker != std::string::npos) { - dump_style_name_part = dump_style_kernel_name->substr(last_scope_marker + 2); - } - *prefix_dump_file_name = dump_style_name_part + ".output." + std::to_string(slot); + delim = "--"; } else { - *prefix_dump_file_name = *dump_style_kernel_name; + delim = "_"; } + last_scope_marker = dump_style_kernel_name->rfind(delim); + if (last_scope_marker != std::string::npos) { + dump_style_name_part = dump_style_kernel_name->substr(last_scope_marker + delim.size()); + } + if (is_sync_mode) { + dump_style_name_part += ".output." + std::to_string(slot); + } + *prefix_dump_file_name = dump_style_name_part; } void DebugServices::ReadDumpedTensor(std::vector backend_name, std::vector slot, @@ -728,10 +734,7 @@ void DebugServices::ReadDumpedTensor(std::vector backend_name, std: bool found = false; // if async mode for (const std::string &file_path : async_file_pool) { - size_t first_dot_pos = file_path.find('.'); - size_t second_dot_pos = file_path.find('.', first_dot_pos + 1); - std::string file_path_op_name = file_path.substr(first_dot_pos + 1, second_dot_pos - first_dot_pos - 1); - if (file_path_op_name == prefix_dump_file_name && + if (file_path.find(prefix_dump_file_name) != std::string::npos && file_path.find(".output." + std::to_string(slot[i])) != std::string::npos) { found = true; shape.clear(); @@ -761,8 +764,8 @@ std::string DebugServices::GetStrippedFilename(const std::string &file_name) { // Look for the second dot's position from the back to avoid issue due to dots in the node name. size_t second_dot = fifth_dot; - const int8_t kSeconeDotPosition = 2; - for (int8_t pos = 5; pos > kSeconeDotPosition; pos--) { + const int8_t kSecondDotPosition = 2; + for (int8_t pos = 5; pos > kSecondDotPosition; pos--) { second_dot = file_name.rfind(".", second_dot - 1); } diff --git a/mindspore/offline_debug/mi_validator_helpers.py b/mindspore/offline_debug/mi_validator_helpers.py index abc4b38223f..643626fbbe0 100644 --- a/mindspore/offline_debug/mi_validator_helpers.py +++ b/mindspore/offline_debug/mi_validator_helpers.py @@ -48,6 +48,11 @@ def check_uint64(arg, arg_name=""): check_value(arg, [UINT64_MIN, UINT64_MAX]) +def check_iteration(arg, arg_name=""): + type_check(arg, (int,), arg_name) + check_value(arg, [-1, UINT64_MAX]) + + def check_dir(dataset_dir): if not os.path.isdir(dataset_dir) or not os.access(dataset_dir, os.R_OK): raise ValueError("The folder {} does not exist or permission denied!".format(dataset_dir)) diff --git a/mindspore/offline_debug/mi_validators.py b/mindspore/offline_debug/mi_validators.py index 669c99be774..8c48416a6f2 100644 --- a/mindspore/offline_debug/mi_validators.py +++ b/mindspore/offline_debug/mi_validators.py @@ -18,7 +18,7 @@ Validator Functions for Offline Debugger APIs. from functools import wraps import mindspore.offline_debug.dbg_services as cds -from mindspore.offline_debug.mi_validator_helpers import parse_user_args, type_check, type_check_list, check_dir, check_uint32, check_uint64 +from mindspore.offline_debug.mi_validator_helpers import parse_user_args, type_check, type_check_list, check_dir, check_uint32, check_uint64, check_iteration def check_init(method): @@ -114,7 +114,7 @@ def check_check_watchpoints(method): def new_method(self, *args, **kwargs): [iteration], _ = parse_user_args(method, *args, **kwargs) - check_uint32(iteration, "iteration") + check_iteration(iteration, "iteration") return method(self, *args, **kwargs) @@ -159,7 +159,7 @@ def check_tensor_info_init(method): type_check(node_name, (str,), "node_name") check_uint32(slot, "slot") - check_uint32(iteration, "iteration") + check_iteration(iteration, "iteration") check_uint32(device_id, "device_id") check_uint32(root_graph_id, "root_graph_id") type_check(is_parameter, (bool,), "is_parameter")