Skip to content

Commit 9263d88

Browse files
dbortfacebook-github-bot
authored andcommitted
Use new threadpool namespace for all of //executorch/... (#5826)
Summary: Pull Request resolved: #5826 Migrate all `//executorch/...` code to use the new threadpool namespace. Reviewed By: mergennachin Differential Revision: D63783748 fbshipit-source-id: 19e55a47689a765f58cc4b6cdbb1907cc0d24e5c
1 parent 436afce commit 9263d88

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

backends/xnnpack/runtime/XNNCompiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,14 +1783,14 @@ ET_NODISCARD Error XNNCompiler::compileModel(
17831783
subgraph.get(),
17841784
/*weight_cache=*/nullptr, // TODO - support weight cache
17851785
workspace,
1786-
torch::executorch::threadpool::get_pthreadpool(),
1786+
::executorch::extension::threadpool::get_pthreadpool(),
17871787
runtime_flags,
17881788
&runtime_ptr);
17891789
#else
17901790
status = xnn_create_runtime_v3(
17911791
subgraph.get(),
17921792
/*weight_cache=*/nullptr, // TODO - support weight cache
1793-
torch::executorch::threadpool::get_pthreadpool(),
1793+
::executorch::extension::threadpool::get_pthreadpool(),
17941794
runtime_flags,
17951795
&runtime_ptr);
17961796
#endif

examples/models/llama2/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ int32_t main(int32_t argc, char** argv) {
6363

6464
#if defined(ET_USE_THREADPOOL)
6565
uint32_t num_performant_cores = cpu_threads == -1
66-
? torch::executorch::cpuinfo::get_num_performant_cores()
66+
? ::executorch::extension::cpuinfo::get_num_performant_cores()
6767
: static_cast<uint32_t>(cpu_threads);
6868
ET_LOG(
6969
Info, "Resetting threadpool with num threads = %d", num_performant_cores);
7070
if (num_performant_cores > 0) {
71-
torch::executorch::threadpool::get_threadpool()->_unsafe_reset_threadpool(
72-
num_performant_cores);
71+
::executorch::extension::threadpool::get_threadpool()
72+
->_unsafe_reset_threadpool(num_performant_cores);
7373
}
7474
#endif
7575
// create llama runner

examples/models/llava/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ int32_t main(int32_t argc, char** argv) {
7272

7373
#if defined(ET_USE_THREADPOOL)
7474
uint32_t num_performant_cores = cpu_threads == -1
75-
? torch::executorch::cpuinfo::get_num_performant_cores()
75+
? ::executorch::extension::cpuinfo::get_num_performant_cores()
7676
: static_cast<uint32_t>(cpu_threads);
7777
ET_LOG(
7878
Info, "Resetting threadpool with num threads = %d", num_performant_cores);
7979
if (num_performant_cores > 0) {
80-
torch::executorch::threadpool::get_threadpool()->_unsafe_reset_threadpool(
81-
num_performant_cores);
80+
::executorch::extension::threadpool::get_threadpool()
81+
->_unsafe_reset_threadpool(num_performant_cores);
8282
}
8383
#endif
8484
// create llama runner

extension/android/jni/jni_layer_llama.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ class ExecuTorchLlamaJni
9595
#if defined(ET_USE_THREADPOOL)
9696
// Reserve 1 thread for the main thread.
9797
uint32_t num_performant_cores =
98-
torch::executorch::cpuinfo::get_num_performant_cores() - 1;
98+
::executorch::extension::cpuinfo::get_num_performant_cores() - 1;
9999
if (num_performant_cores > 0) {
100100
ET_LOG(Info, "Resetting threadpool to %d threads", num_performant_cores);
101-
torch::executorch::threadpool::get_threadpool()->_unsafe_reset_threadpool(
102-
num_performant_cores);
101+
::executorch::extension::threadpool::get_threadpool()
102+
->_unsafe_reset_threadpool(num_performant_cores);
103103
}
104104
#endif
105105

extension/llm/custom_ops/op_sdpa.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ void cpu_flash_attention(
367367
int64_t qSlice = (qSize - 1) / qSplitSize + 1;
368368
#ifdef ET_USE_THREADPOOL
369369
int64_t num_thread =
370-
torch::executorch::threadpool::get_threadpool()->get_thread_count();
370+
::executorch::extension::threadpool::get_threadpool()->get_thread_count();
371371
#else
372372
int64_t num_thread = 1;
373373
#endif

extension/parallel/thread_parallel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace {
2020
thread_local int64_t thread_num_ = 0;
2121
}
2222

23-
using namespace torch::executorch::threadpool;
23+
using namespace ::executorch::extension::threadpool;
2424

2525
inline int64_t divup(int64_t x, int64_t y) {
2626
return (x + y - 1) / y;

0 commit comments

Comments
 (0)