diff --git a/mindspore/lite/tools/converter/quantizer/debug_info_manager.cc b/mindspore/lite/tools/converter/quantizer/debug_info_manager.cc index 411bc4f7616..f9c123f7ede 100644 --- a/mindspore/lite/tools/converter/quantizer/debug_info_manager.cc +++ b/mindspore/lite/tools/converter/quantizer/debug_info_manager.cc @@ -196,6 +196,10 @@ void DebugInfoManager::SaveInfo(std::ofstream &out_file, const QuantDebugInfo &i } int DebugInfoManager::SaveInfo(const std::string &file_path) { + if (file_path.empty()) { + MS_LOG(ERROR) << "path is invalid."; + return RET_ERROR; + } std::ofstream out_file; out_file.open(file_path, std::ios::out); if (!out_file.is_open()) { @@ -624,6 +628,10 @@ void DebugInfoManager::PrintQuantParam() { } int DebugInfoManager::SaveQuantParam(const std::string &file_path) { + if (file_path.empty()) { + MS_LOG(ERROR) << "path is invalid."; + return RET_ERROR; + } if (quant_params_.empty()) { return RET_OK; } @@ -697,6 +705,10 @@ void DebugInfoManager::GetOutputInfo() { } int DebugInfoManager::SaveOutputInfo(const std::string &file_path) { + if (file_path.empty()) { + MS_LOG(ERROR) << "path is invalid."; + return RET_ERROR; + } if (output_infos_.empty()) { return RET_OK; } @@ -788,6 +800,9 @@ void DebugInfoManager::CollectQuantParam(const mindspore::lite::LiteModel &quant std::string DebugInfoManager::CreateFilePath(const std::string &dir_path, const std::string &file_name) const { auto real_path = RealPath(dir_path.c_str()); + if (real_path.empty()) { + return ""; + } std::string file_path = real_path + FILE_SEPARATOR + file_name; return file_path; }