Skip to content

Commit 3b3ac8a

Browse files
committed
[executorch] Use __ET_UNLIKELY in assertion macros
It is supposed to be unlikely for assert/check conditions to fail; let's tell the compiler about that. Differential Revision: [D55929730](https://our.internmc.facebook.com/intern/diff/D55929730/) ghstack-source-id: 221859993 Pull Request resolved: #2949
1 parent 9fd1a0e commit 3b3ac8a

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)