diff --git a/mindspore/ccsrc/debug/debug_services.cc b/mindspore/ccsrc/debug/debug_services.cc index d3417b2629a..5423a5ef6c7 100644 --- a/mindspore/ccsrc/debug/debug_services.cc +++ b/mindspore/ccsrc/debug/debug_services.cc @@ -43,6 +43,7 @@ namespace mindspore { #endif static constexpr const char *constant_prefix = "Default--data-"; +static constexpr const char *kNpyExt = ".npy"; namespace { #ifdef __APPLE__ @@ -815,7 +816,6 @@ void DebugServices::ReadTensorFromNpy(const std::string &tensor_name, const std: * converted npy file name into AsyncFilePool. It's for Ascend async dump only. */ void DebugServices::ConvertToHostFormat(const DirMap &dir_to_files_map, AsyncFilePool *const result_list) { - std::string file_format = "npy"; for (auto const &d : dir_to_files_map) { std::vector files_to_convert_in_dir; std::vector files_after_convert_in_dir; @@ -845,7 +845,7 @@ void DebugServices::ConvertToHostFormat(const DirMap &dir_to_files_map, AsyncFil MS_LOG(EXCEPTION) << "Failed to convert async dump data: " << e.what(); } } - ProcessConvertToHostFormat(files_after_convert_in_dir, dump_key, result_list, file_format); + ProcessConvertToHostFormat(files_after_convert_in_dir, dump_key, result_list); } } } @@ -858,8 +858,7 @@ void DebugServices::ConvertToHostFormat(const DirMap &dir_to_files_map, AsyncFil * append into AsyncFilePool. It's for Ascend async dump only. */ void DebugServices::ProcessConvertToHostFormat(const std::vector &files_after_convert_in_dir, - const std::string &dump_key, AsyncFilePool *const result_list, - const std::string &file_format) { + const std::string &dump_key, AsyncFilePool *const result_list) { std::string real_dump_iter_dir = RealPath(dump_key); DIR *d_handle = opendir(real_dump_iter_dir.c_str()); if (d_handle == nullptr) { @@ -884,7 +883,7 @@ void DebugServices::ProcessConvertToHostFormat(const std::vector &f if (last_slash_pos != std::string::npos) { file_n = file_to_find.substr(last_slash_pos + 1); } - if (candidate.find(file_n) != std::string::npos && candidate.rfind(file_format) != std::string::npos) { + if (candidate.find(file_n) != std::string::npos && candidate.rfind(kNpyExt) != std::string::npos) { // we found a converted file for this op std::string found_file = dump_key + "/" + candidate; result_list->insert(found_file); @@ -927,7 +926,6 @@ std::string GetNodeNameWithoutScope(const std::string &dump_style_name) { void DebugServices::ConvertReadTensors(std::vector backend_name, std::vector slot, std::vector device_id, std::vector iteration, std::vector root_graph_id, AsyncFilePool *const result_list) { - std::string file_format = "npy"; DirMap dir_to_files_map; for (unsigned int i = 0; i < backend_name.size(); i++) { // form prefix of the tensor file to read from graph pb node name @@ -954,7 +952,7 @@ void DebugServices::ConvertReadTensors(std::vector backend_name, st MS_LOG(INFO) << "Directory does not exist in ConvertReadTensors."; return; } - ProcessConvertList(prefix_dump_file_name, file_format, specific_dump_dir, &dir_to_files_map, result_list); + ProcessConvertList(prefix_dump_file_name, specific_dump_dir, &dir_to_files_map, result_list); (void)closedir(d); } ConvertToHostFormat(dir_to_files_map, result_list); @@ -962,7 +960,6 @@ void DebugServices::ConvertReadTensors(std::vector backend_name, st void DebugServices::ConvertWatchPointNodes(const std::vector> &proto_dump, const std::string &specific_dump_dir, AsyncFilePool *const result_list) { - std::string file_format = "npy"; DirMap dir_to_files_map; for (const auto &node : proto_dump) { std::string dump_name = std::get<1>(node); @@ -974,15 +971,14 @@ void DebugServices::ConvertWatchPointNodes(const std::vector &files_after_convert_in_dir, - const std::string &dump_key, AsyncFilePool *const result_list, - const std::string &file_format); + const std::string &dump_key, AsyncFilePool *const result_list); void ConvertReadTensors(std::vector backend_name, std::vector slot, std::vector device_id, std::vector iteration, @@ -382,9 +381,8 @@ class DebugServices { void ConvertWatchPointNodes(const std::vector> &proto_dump, const std::string &specific_dump_dir, AsyncFilePool *const result_list); - void ProcessConvertList(const std::string &prefix_dump_file_name, const std::string &file_format, - const std::string &specific_dump_dir, DirMap *dir_to_files_map, - AsyncFilePool *const result_list); + void ProcessConvertList(const std::string &prefix_dump_file_name, const std::string &specific_dump_dir, + DirMap *dir_to_files_map, AsyncFilePool *const result_list); void GetTensorDataInfoAsync(const std::vector> &proto_dump, const std::string &specific_dump_dir, uint32_t iteration, uint32_t device_id,