8000 Replace [[unlikely]] with unlikely(x) (#130816) · pytorch/pytorch@32f9a80 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 32f9a80

Browse files
Danielmicpytorchmergebot
authored andcommitted
Replace [[unlikely]] with unlikely(x) (#130816)
Do not use `[[unlikely]]` as its c++20 language features, see https://en.cppreference.com/w/cpp/language/attributes/likely Fixes #130815 Pull Request resolved: #130816 Approved by: https://github.com/jgong5, https://github.com/jansel, https://github.com/malfet
1 parent 8c8eb96 commit 32f9a80

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

torch/_inductor/codecache.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,25 +2561,25 @@ class CppPythonBindingsCodeCache(CppCodeCache):
25612561
}
25622562
template <> inline long parse_arg<long>(PyObject* args, size_t n) {
25632563
auto result = PyLong_AsSsize_t(PyTuple_GET_ITEM(args, n));
2564-
if(result == -1 && PyErr_Occurred())
2565-
[[unlikely]] throw std::runtime_error("expected int arg");
2564+
if(unlikely(result == -1 && PyErr_Occurred()))
2565+
throw std::runtime_error("expected int arg");
25662566
return result;
25672567
}
25682568
template <> inline uintptr_t parse_arg<uintptr_t>(PyObject* args, size_t n) {
25692569
auto result = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, n));
2570-
if(result == reinterpret_cast<void*>(-1) && PyErr_Occurred())
2571-
[[unlikely]] throw std::runtime_error("expected int arg");
2570+
if(unlikely(result == reinterpret_cast<void*>(-1) && PyErr_Occurred()))
2571+
throw std::runtime_error("expected int arg");
25722572
return reinterpret_cast<uintptr_t>(result);
25732573
}
25742574
25752575
%s
25762576
25772577
static PyObject* %s_py(PyObject* self, PyObject* args) {
25782578
try {
2579-
if(!PyTuple_CheckExact(args))
2580-
[[unlikely]] throw std::runtime_error("tuple args required");
2581-
if(PyTuple_GET_SIZE(args) != %s)
2582-
[[unlikely]] throw std::runtime_error("requires %s args");
2579+
if(unlikely(!PyTuple_CheckExact(args)))
2580+
throw std::runtime_error("tuple args required");
2581+
if(unlikely(PyTuple_GET_SIZE(args) != %s))
2582+
throw std::runtime_error("requires %s args");
25832583
%s
25842584
} catch(std::exception const& e) {
25852585
PyErr_SetString(PyExc_RuntimeError, e.what());

0 commit comments

Comments
 (0)
0