Skip to content
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

Merged
merged 6 commits into from
Aug 4, 2017

Conversation

Superjomn
Copy link
Contributor

@Superjomn Superjomn commented Aug 4, 2017

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.

@@ -162,5 +162,11 @@ inline void throw_on_error(T e) {
} \
} while (0)

#define PADDLE_ENFORCE_EQ(__VAL0, __VAL1, ...) \
Copy link
Contributor

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?

Copy link
Contributor

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.

@@ -162,5 +162,11 @@ inline void throw_on_error(T e) {
} \
} while (0)

#define PADDLE_ENFORCE_EQ(__VAL0, __VAL1, ...) \
PADDLE_ENFORCE((__VAL0) == (__VAL1), \
Copy link
Contributor

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), ...

@gangliao gangliao merged commit 548b72a into PaddlePaddle:develop Aug 4, 2017
@Superjomn Superjomn deleted the enforce_add_more_helpers branch August 5, 2017 09:09
heavengate pushed a commit to heavengate/Paddle that referenced this pull request Aug 16, 2021
* update mot doc config, test=document_fix

* update citations, test=document_fix

* update title, test=document_fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add PADDLE_ENFORCE_EQ and other macros like CAFFE_ENFORCE_EQ
2 participants