提交 099186cd 编写于 作者: M minqiyang

Support one argument PADDLE_ENFORCE

test=develop
上级 4af97c69
...@@ -258,21 +258,33 @@ inline void throw_on_error(T e) { ...@@ -258,21 +258,33 @@ inline void throw_on_error(T e) {
#define PADDLE_THROW(...) \ #define PADDLE_THROW(...) \
throw ::paddle::platform::EnforceNotMet(__FILE__, __LINE__, __VA_ARGS__) throw ::paddle::platform::EnforceNotMet(__FILE__, __LINE__, __VA_ARGS__)
#define PADDLE_JUDGE #define PADDLE_THROW_ERROR(COND, ...) \
PADDLE_THROW_I(__VA_ARGS__, \
#define __PADDLE_UNARY_COMPARE(COND, ...) \ ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
do { \ ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
auto __cond = COND; \ ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
if (UNLIKELY(::paddle::platform::is_error(__cond))) { \ ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(__cond, ##__VA_ARGS__); \ ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
} \ ::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND, __VA_ARGS__), \
::paddle::platform::throw_on_error(COND))
#define PADDLE_THROW_I(_, _9, _8, _7, _6, _5, _4, _3, _2, X_, ...) X_;
#define __PADDLE_UNARY_COMPARE(COND, ...) \
do { \
auto __cond = COND; \
if (UNLIKELY(::paddle::platform::is_error(__cond))) { \
PADDLE_THROW_ERROR(COND, __VA_ARGS__); \
} \
} while (0) } while (0)
#ifndef REPLACE_ENFORCE_GLOG #ifndef REPLACE_ENFORCE_GLOG
#define PADDLE_ENFORCE(COND, ...) \ #define PADDLE_ENFORCE(COND, ...) \
do { \ do { \
try { \ try { \
__PADDLE_UNARY_COMPARE(COND, ##__VA_ARGS__); \ __PADDLE_UNARY_COMPARE(COND, __VA_ARGS__); \
} catch (...) { \ } catch (...) { \
throw ::paddle::platform::EnforceNotMet(std::current_exception(), \ throw ::paddle::platform::EnforceNotMet(std::current_exception(), \
__FILE__, __LINE__); \ __FILE__, __LINE__); \
...@@ -280,7 +292,7 @@ inline void throw_on_error(T e) { ...@@ -280,7 +292,7 @@ inline void throw_on_error(T e) {
} while (0) } while (0)
#else #else
#define PADDLE_ENFORCE(COND, ...) __PADDLE_UNARY_COMPARE(COND, ##__VA_ARGS__); #define PADDLE_ENFORCE(COND, ...) __PADDLE_UNARY_COMPARE(COND, __VA_ARGS__);
#endif // REPLACE_ENFORCE_GLOG #endif // REPLACE_ENFORCE_GLOG
#define PADDLE_THROW_EOF() \ #define PADDLE_THROW_EOF() \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册