未验证 提交 fbb42173 编写于 作者: C Chen Weihang 提交者: GitHub

fix no hint problem when use ENFORCE for cuda, test=develop (#21994)

上级 e66f92d1
...@@ -207,6 +207,10 @@ inline std::string GetTraceBackString(StrType&& what, const char* file, ...@@ -207,6 +207,10 @@ inline std::string GetTraceBackString(StrType&& what, const char* file,
inline bool is_error(bool stat) { return !stat; } inline bool is_error(bool stat) { return !stat; }
inline std::string build_ex_string(bool stat, const std::string& msg) {
return msg;
}
inline void throw_on_error(bool stat, const std::string& msg) { inline void throw_on_error(bool stat, const std::string& msg) {
#ifndef REPLACE_ENFORCE_GLOG #ifndef REPLACE_ENFORCE_GLOG
throw std::runtime_error(msg); throw std::runtime_error(msg);
...@@ -215,14 +219,6 @@ inline void throw_on_error(bool stat, const std::string& msg) { ...@@ -215,14 +219,6 @@ inline void throw_on_error(bool stat, const std::string& msg) {
#endif #endif
} }
inline void throw_on_error(const platform::ErrorSummary& error) {
#ifndef REPLACE_ENFORCE_GLOG
throw std::runtime_error(error.ToString());
#else
LOG(FATAL) << error.ToString();
#endif
}
// Note: This Macro can only be used within enforce.h // Note: This Macro can only be used within enforce.h
#define __THROW_ERROR_INTERNAL__(...) \ #define __THROW_ERROR_INTERNAL__(...) \
do { \ do { \
...@@ -277,7 +273,10 @@ struct EnforceNotMet : public std::exception { ...@@ -277,7 +273,10 @@ struct EnforceNotMet : public std::exception {
if (UNLIKELY(::paddle::platform::is_error(__cond__))) { \ if (UNLIKELY(::paddle::platform::is_error(__cond__))) { \
try { \ try { \
::paddle::platform::throw_on_error( \ ::paddle::platform::throw_on_error( \
::paddle::platform::ErrorSummary(__VA_ARGS__)); \ __cond__, \
::paddle::platform::build_ex_string( \
__cond__, \
::paddle::platform::ErrorSummary(__VA_ARGS__).ToString())); \
} catch (...) { \ } catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \ throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
...@@ -414,7 +413,8 @@ inline bool is_error(cudnnStatus_t stat) { ...@@ -414,7 +413,8 @@ inline bool is_error(cudnnStatus_t stat) {
} }
inline std::string build_ex_string(cudnnStatus_t stat, const std::string& msg) { inline std::string build_ex_string(cudnnStatus_t stat, const std::string& msg) {
return msg + "\n [" + platform::dynload::cudnnGetErrorString(stat) + "]"; return msg + "\n [Hint: " + platform::dynload::cudnnGetErrorString(stat) +
"]";
} }
inline void throw_on_error(cudnnStatus_t stat, const std::string& msg) { inline void throw_on_error(cudnnStatus_t stat, const std::string& msg) {
...@@ -451,7 +451,7 @@ inline std::string build_ex_string(cublasStatus_t stat, ...@@ -451,7 +451,7 @@ inline std::string build_ex_string(cublasStatus_t stat,
} else if (stat == CUBLAS_STATUS_LICENSE_ERROR) { } else if (stat == CUBLAS_STATUS_LICENSE_ERROR) {
err = "CUBLAS: license error."; err = "CUBLAS: license error.";
} }
return msg + "\n [" + err + "]"; return msg + "\n [Hint: " + err + "]";
} }
inline void throw_on_error(cublasStatus_t stat, const std::string& msg) { inline void throw_on_error(cublasStatus_t stat, const std::string& msg) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册