Skip to content

Commit 9a2eb43

Browse files
authored
Expose get_num_threads via pybind
Differential Revision: D87510750 Pull Request resolved: #15944
1 parent eb4ebcb commit 9a2eb43

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

extension/pybindings/portable_lib.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
_load_program, # noqa: F401
6666
_load_program_from_buffer, # noqa: F401
6767
_reset_profile_results, # noqa: F401
68+
_threadpool_get_thread_count, # noqa: F401
6869
_unsafe_reset_threadpool, # noqa: F401
6970
BundledModule, # noqa: F401
7071
ExecuTorchMethod, # noqa: F401

extension/pybindings/pybindings.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,13 @@ PYBIND11_MODULE(EXECUTORCH_PYTHON_MODULE_NAME, m) {
15581558
},
15591559
py::arg("num_threads"),
15601560
call_guard);
1561+
m.def(
1562+
"_threadpool_get_thread_count",
1563+
[]() {
1564+
return ::executorch::extension::threadpool::get_threadpool()
1565+
->get_thread_count();
1566+
},
1567+
call_guard);
15611568

15621569
py::class_<PyModule>(m, "ExecuTorchModule")
15631570
.def(

extension/pybindings/pybindings.pyi

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,12 @@ def _unsafe_reset_threadpool(num_threads: int) -> None:
288288
This API is experimental and subject to change without notice.
289289
"""
290290
...
291+
292+
@experimental("This API is experimental and subject to change without notice.")
293+
def _threadpool_get_thread_count() -> int:
294+
"""
295+
.. warning::
296+
297+
This API is experimental and subject to change without notice.
298+
"""
299+
...

0 commit comments

Comments
 (0)