Skip to content

s/IF_FALSE/UNLESS/ in ET_LOG macro names #8317

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

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions runtime/core/exec_aten/util/tensor_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,19 @@
*
* @param[in] cond the condition to check
*/
#define ET_LOG_AND_RETURN_IF_FALSE(cond) \
#define ET_LOG_AND_RETURN_UNLESS(cond) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These feel like they should live near

#define ET_CHECK_OR_RETURN_ERROR(cond__, error__, message__, ...) \
and be called ET_CHECK_OR_RETURN_FALSE to be consistent with the core helpers. But that's a separate issue since this PR doesn't change where they live.

do { \
if (!(cond)) { \
ET_LOG(Error, "Check failed (%s): ", #cond); \
return false; \
} \
} while (false)

/**
* DEPRECATED: please use ET_LOG_AND_RETURN_UNLESS instead.
*/
#define ET_LOG_AND_RETURN_IF_FALSE ET_LOG_AND_RETURN_UNLESS

/**
* A convenience macro to be used in utility functions that check whether input
* tensor(s) are valid, which are expected to return a boolean. Checks whether
Expand All @@ -354,14 +359,19 @@
* @param[in] cond the condition to check
* @param[in] message an additional message to log with `cond`
*/
#define ET_LOG_MSG_AND_RETURN_IF_FALSE(cond, message, ...) \
#define ET_LOG_MSG_AND_RETURN_UNLESS(cond, message, ...) \
do { \
if (!(cond)) { \
ET_LOG(Error, "Check failed (%s): " message, #cond, ##__VA_ARGS__); \
return false; \
} \
} while (false)

/**
* DEPRECATED: please use ET_LOG_AND_RETURN_UNLESS instead.
*/
#define ET_LOG_MSG_AND_RETURN_IF_FALSE ET_LOG_MSG_AND_RETURN_UNLESS

/**
* If `cond` is false, log `cond` and return from the kernel with a failure
* state set.
Expand Down
Loading