From 9c1a7ff6405dfa14a9eb33aa9c8014c5d97f52ea Mon Sep 17 00:00:00 2001 From: Parastoo Ashtari Date: Fri, 3 Dec 2021 14:03:31 -0500 Subject: [PATCH] use S_ISREG instead of DT_REG for files --- mindspore/ccsrc/debug/debug_services.cc | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/debug/debug_services.cc b/mindspore/ccsrc/debug/debug_services.cc index 749da6e1906..5cfa80490c4 100644 --- a/mindspore/ccsrc/debug/debug_services.cc +++ b/mindspore/ccsrc/debug/debug_services.cc @@ -688,7 +688,10 @@ void DebugServices::ProcessConvertToHostFormat(const std::vector &f } struct dirent *dir = nullptr; while ((dir = readdir(d_handle)) != nullptr) { - if (dir->d_type == DT_REG) { + struct stat st; + std::string name = real_dump_iter_dir + std::string("/") + std::string(dir->d_name); + int ret = stat(name.c_str(), &st); + if (ret == 0 && S_ISREG(st.st_mode)) { std::string candidate = dir->d_name; for (const std::string &file_to_find : files_after_convert_in_dir) { std::string file_n = file_to_find; @@ -782,7 +785,10 @@ void DebugServices::ProcessConvertList(const std::string &prefix_dump_file_name, DIR *d = opendir(specific_dump_dir.c_str()); struct dirent *dir = nullptr; while ((dir = readdir(d)) != nullptr) { - if (dir->d_type != DT_REG) { + struct stat st; + std::string name = specific_dump_dir + std::string("/") + std::string(dir->d_name); + int ret = stat(name.c_str(), &st); + if (!(ret == 0 && S_ISREG(st.st_mode))) { continue; } std::string file_name = dir->d_name; @@ -997,7 +1003,10 @@ void DebugServices::ReadDumpedTensorSync(const std::string &prefix_dump_file_nam } else { struct dirent *dir = nullptr; while ((dir = readdir(d)) != nullptr) { - if (dir->d_type == DT_REG) { + struct stat st; + std::string name = abspath + std::string("/") + std::string(dir->d_name); + int ret = stat(name.c_str(), &st); + if (ret == 0 && S_ISREG(st.st_mode)) { std::string file_name = dir->d_name; std::string stripped_file_name = GetStrippedFilename(file_name); if (stripped_file_name.empty()) { @@ -1143,7 +1152,10 @@ void DebugServices::ProcessTensorDataSync(const std::vectord_type == DT_REG) { + struct stat st; + std::string name = abspath + std::string("/") + std::string(dir->d_name); + int ret = stat(name.c_str(), &st); + if (ret == 0 && S_ISREG(st.st_mode)) { std::string file_name = dir->d_name; for (auto &node : proto_to_dump) { std::string dump_name = std::get<1>(node); @@ -1338,7 +1350,10 @@ bool DebugServices::CheckOpOverflow(std::string node_name_to_find, unsigned int } else { struct dirent *dir = nullptr; while ((dir = readdir(d)) != nullptr) { - if (dir->d_type == DT_REG) { + struct stat st; + std::string name = abspath + std::string("/") + std::string(dir->d_name); + int ret = stat(name.c_str(), &st); + if (ret == 0 && S_ISREG(st.st_mode)) { // form fully qualified filename std::string file_path = overflow_bin_path; std::string file_name = dir->d_name;