From c639cca5f43864300f9507eb9a1390f7c5be930e Mon Sep 17 00:00:00 2001 From: TinaMengtingZhang Date: Thu, 6 May 2021 15:57:27 -0400 Subject: [PATCH] Check if toolkit dir exist in convert_async.py --- mindspore/ccsrc/debug/convert_async.py | 7 +++++-- mindspore/ccsrc/debug/debug_services.cc | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mindspore/ccsrc/debug/convert_async.py b/mindspore/ccsrc/debug/convert_async.py index 321d70f1e92..d944b930657 100644 --- a/mindspore/ccsrc/debug/convert_async.py +++ b/mindspore/ccsrc/debug/convert_async.py @@ -14,9 +14,12 @@ # ============================================================================ """Module to provide conversion capabalities from .timestamp async dump files to .npy.""" import site -site.addsitedir("/usr/local/Ascend/toolkit/tools/operator_cmp/compare/") -#pylint: disable=wrong-import-position import os +DIR_PATH = "/usr/local/Ascend/toolkit/tools/operator_cmp/compare/" +if not os.path.exists(DIR_PATH): + raise ValueError("Directory " + DIR_PATH + " does not exist. Please install Ascend toolkit.") +site.addsitedir(DIR_PATH) +#pylint: disable=wrong-import-position import argparse import csv from dump_data_parser import DumpDataParser diff --git a/mindspore/ccsrc/debug/debug_services.cc b/mindspore/ccsrc/debug/debug_services.cc index 359fa9b94a9..118284cdbd8 100644 --- a/mindspore/ccsrc/debug/debug_services.cc +++ b/mindspore/ccsrc/debug/debug_services.cc @@ -665,16 +665,23 @@ void DebugServices::ReadDumpedTensor(std::vector backend_name, std: } closedir(d); } else { + bool found = false; // if async mode for (const std::string &file_path : async_file_pool) { 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(); ReadTensorFromNpy(file_path, &type_name, &data_size, &shape, &buffer); AddToTensorData(backend_name[i], slot[i], iteration[i], device_id[i], root_graph_id[i], data_size, type_name, shape, buffer, result_list); } } + // If no npy file is found, add empty tensor data. + if (!found) { + AddToTensorData(backend_name[i], slot[i], iteration[i], device_id[i], root_graph_id[i], 0, type_name, shape, + buffer, result_list); + } } } }