-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enforce add more helpers #3233
Enforce add more helpers #3233
Conversation
paddle/platform/enforce.h
Outdated
@@ -162,5 +162,11 @@ inline void throw_on_error(T e) { | |||
} \ | |||
} while (0) | |||
|
|||
#define PADDLE_ENFORCE_EQ(__VAL0, __VAL1, ...) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this kind of macros EQ
, NE
, NOTNULL
necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed with @Superjom, it's important to use PADDLE_ENFORCE_EQ
to print the mismatch value for users to debug if the error exists.
paddle/platform/enforce.h
Outdated
@@ -162,5 +162,11 @@ inline void throw_on_error(T e) { | |||
} \ | |||
} while (0) | |||
|
|||
#define PADDLE_ENFORCE_EQ(__VAL0, __VAL1, ...) \ | |||
PADDLE_ENFORCE((__VAL0) == (__VAL1), \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Superjom like Glog, there is a bug might trigger a compilation warning/error.
we might need to fix it.
template<typename T1, typename T2>
struct min_type {
static const bool t1_to_t2 = std::is_convertible<T1, T2>::value;
typedef typename std::conditional<t1_to_t2, T2, T1>::type type;
};
typedef typename min_type<decltype(__VAL0), decltype(__VAL1)>::type T;
PADDLE_ENFORCE(T(__VAL0) == T(__VAL1), ...
* update mot doc config, test=document_fix * update citations, test=document_fix * update title, test=document_fix
fix #3229
Will wait for more reviewing suggestions before add other enforces.
reference
https://caffe2.ai/doxygen-c/html/logging_8h_source.html
same usages.