Skip to content

Commit 6cb6051

Browse files
swolchokfacebook-github-bot
authored andcommitted
Use __ET_UNLIKELY in assertion macros (#2949)
Summary: Pull Request resolved: #2949 It is supposed to be unlikely for assert/check conditions to fail; let's tell the compiler about that. Reviewed By: mergennachin Differential Revision: D55929730 fbshipit-source-id: 5677c19cd8342cbd77a9c0b973059ed3d5ee800b
1 parent b26eee8 commit 6cb6051

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

runtime/platform/assert.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
*/
3636
#define ET_CHECK_MSG(_cond, _format, ...) \
3737
({ \
38-
if (!(_cond)) { \
38+
if __ET_UNLIKELY (!(_cond)) { \
3939
ET_ASSERT_MESSAGE_EMIT(" (%s): " _format, #_cond, ##__VA_ARGS__); \
4040
torch::executor::runtime_abort(); \
4141
} \
@@ -49,7 +49,7 @@
4949
*/
5050
#define ET_CHECK(_cond) \
5151
({ \
52-
if (!(_cond)) { \
52+
if __ET_UNLIKELY (!(_cond)) { \
5353
ET_ASSERT_MESSAGE_EMIT(": %s", #_cond); \
5454
torch::executor::runtime_abort(); \
5555
} \

0 commit comments

Comments
 (0)