未验证 提交 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,
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) {
#ifndef REPLACE_ENFORCE_GLOG
throw std::runtime_error(msg);
......@@ -215,14 +219,6 @@ inline void throw_on_error(bool stat, const std::string& msg) {
#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
#define __THROW_ERROR_INTERNAL__(...) \
do { \
......@@ -271,18 +267,21 @@ struct EnforceNotMet : public std::exception {
} \
} while (0)
#else
#define PADDLE_ENFORCE(COND, ...) \
do { \
auto __cond__ = (COND); \
if (UNLIKELY(::paddle::platform::is_error(__cond__))) { \
try { \
::paddle::platform::throw_on_error( \
::paddle::platform::ErrorSummary(__VA_ARGS__)); \
} catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \
} \
} \
#define PADDLE_ENFORCE(COND, ...) \
do { \
auto __cond__ = (COND); \
if (UNLIKELY(::paddle::platform::is_error(__cond__))) { \
try { \
::paddle::platform::throw_on_error( \
__cond__, \
::paddle::platform::build_ex_string( \
__cond__, \
::paddle::platform::ErrorSummary(__VA_ARGS__).ToString())); \
} catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \
} \
} \
} while (0)
#endif
......@@ -414,7 +413,8 @@ inline bool is_error(cudnnStatus_t stat) {
}
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) {
......@@ -451,7 +451,7 @@ inline std::string build_ex_string(cublasStatus_t stat,
} else if (stat == CUBLAS_STATUS_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) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册