Skip to content

Commit 7c13f3b

Browse files
larryliu0820malfet
authored andcommitted
Fix runner-et on Mac and Android (#490)
* Fix runner-et on Mac and Android * Fix typo * Avoid fatal message * Change fatal to warning
1 parent 6590950 commit 7c13f3b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

runner/et.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
2727
SET(CMAKE_INSTALL_PREFIX ${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/install CACHE PATH "Setting it to a default value" FORCE)
2828
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
2929

30+
# Building for Android. Since Android overwrites CMAKE_FIND_ROOT_PATH normal
31+
# CMAKE_INSTALL_PREFIX won't work. Redirect CMAKE_FIND_ROOT_PATH to it.
32+
# This should check any cross compilation but let's do Android for now
33+
if(ANDROID)
34+
set(CMAKE_FIND_ROOT_PATH "${CMAKE_INSTALL_PREFIX}")
35+
endif()
36+
3037
include(CMakePrintHelpers)
3138
include(runner/Utils.cmake)
3239

@@ -76,7 +83,7 @@ if(executorch_FOUND)
7683
endif()
7784

7885
target_link_libraries(et_run PRIVATE
79-
"$<LINK_LIBRARY:WHOLE_ARCHIVE,${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/install/libcustom_ops.a>")
86+
"$<LINK_LIBRARY:WHOLE_ARCHIVE,${TORCHCHAT_ROOT}/${ET_BUILD_DIR}/install/lib/libcustom_ops.a>")
8087
# This one is needed for cpuinfo where it uses android specific log lib
8188
if(ANDROID)
8289
target_link_libraries(et_run PRIVATE log)
@@ -97,4 +104,6 @@ if(executorch_FOUND)
97104
# This works on mac, but appears to run into issues on linux
98105
# It is needed to solve:
99106
# E 00:00:00.055965 executorch:method.cpp:536] Missing operator: [8] llama::sdpa_with_kv_cache.out
107+
else()
108+
MESSAGE(WARNING "ExecuTorch package not found")
100109
endif()

scripts/build_native.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ fi
7676
cmake -S . -B ./cmake-out -DCMAKE_PREFIX_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'` -G Ninja
7777
cmake --build ./cmake-out --target "${TARGET}"_run
7878

79-
printf "Build finished. Please run: \n./cmake-out model.<pte|so> -z tokenizer.model -i <prompt>"
79+
printf "Build finished. Please run: \n./cmake-out/${TARGET}_run model.<pte|so> -z tokenizer.model -i <prompt>"

0 commit comments

Comments
 (0)