File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export CMAKE_OUT_DIR="cmake-out-android"
30
30
build_runner_et () {
31
31
rm -rf cmake-out-android
32
32
echo " ET BUILD DIR IS ${ET_BUILD_DIR} "
33
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK /build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23 -S . -B cmake-out-android -G Ninja
33
+ cmake -DET_USE_ADPATIVE_THREADS=ON - DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK /build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-23 -S . -B cmake-out-android -G Ninja
34
34
cmake --build cmake-out-android/ -j16 --config Release --target et_run
35
35
}
36
36
Original file line number Diff line number Diff line change @@ -48,10 +48,25 @@ if(executorch_FOUND)
48
48
49
49
cmake_print_variables (_common_include_directories )
50
50
51
+ set (_srcs runner/run.cpp )
52
+ set (_common_compile_options -D__ET__MODEL -D_GLIBCXX_USE_CXX11_ABI=1 )
53
+ if (ET_USE_ADPATIVE_THREADS )
54
+ list (APPEND _common_compile_options -DET_USE_ADPATIVE_THREADS )
55
+
56
+ set (EXECUTORCH_SRC_ROOT ${TORCHCHAT_ROOT} /${ET_BUILD_DIR}/src/executorch )
57
+ set (XNNPACK_ROOT ${EXECUTORCH_SRC_ROOT} /backends/xnnpack )
58
+ list (APPEND _srcs ${XNNPACK_ROOT} /threadpool/cpuinfo_utils.cpp )
59
+ list (APPEND _common_include_directories
60
+ ${XNNPACK_ROOT} /third-party/cpuinfo/include )
61
+
62
+ list (APPEND _common_include_directories
63
+ ${XNNPACK_ROOT} /third-party/pthreadpool/include )
64
+ endif ()
65
+
51
66
target_include_directories (executorch INTERFACE ${_common_include_directories} ) # Ideally ExecuTorch installation process would do this
52
- add_executable (et_run runner/run.cpp )
67
+ add_executable (et_run ${_srcs} )
53
68
54
- target_compile_options (et_run PUBLIC -D__ET__MODEL -D_GLIBCXX_USE_CXX11_ABI=1 )
69
+ target_compile_options (et_run PUBLIC ${_common_compile_options} )
55
70
56
71
# Link ET runtime + extensions
57
72
target_link_libraries (
Original file line number Diff line number Diff line change 26
26
#include < executorch/runtime/core/exec_aten/exec_aten.h>
27
27
#include < executorch/runtime/core/exec_aten/util/scalar_type_util.h>
28
28
29
+ #if defined(ET_USE_ADPATIVE_THREADS)
30
+ #include < executorch/backends/xnnpack/threadpool/cpuinfo_utils.h>
31
+ #include < executorch/backends/xnnpack/threadpool/threadpool.h>
32
+ #endif
33
+
29
34
using exec_aten::ScalarType;
30
35
using torch::executor::EValue;
31
36
using torch::executor::ManagedTensor;
@@ -633,6 +638,13 @@ int main(int argc, char* argv[]) {
633
638
char * system_prompt =
634
639
NULL ; // the (optional) system prompt to use in chat mode
635
640
641
+ #if defined(ET_USE_ADPATIVE_THREADS)
642
+ uint32_t num_performant_cores = torch::executorch::cpuinfo::get_num_performant_cores ();
643
+ if (num_performant_cores > 0 ) {
644
+ torch::executorch::threadpool::get_threadpool ()->_unsafe_reset_threadpool (
645
+ num_performant_cores);
646
+ }
647
+ #endif
636
648
// poor man's C argparse so we can override the defaults above from the
637
649
// command line
638
650
if (argc >= 2 ) {
You can’t perform that action at this time.
0 commit comments