Skip to content

Commit 54b1e6c

Browse files
Fix MTK build scripts (#13061)
### Summary - Fix MTK llama runner build fails
1 parent 8651d31 commit 54b1e6c

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

backends/mediatek/scripts/mtk_build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ cmake -DCMAKE_INSTALL_PREFIX="${build_dir}" \
2525
-DANDROID_ABI=arm64-v8a \
2626
-DANDROID_NATIVE_API_LEVEL=26 \
2727
-DANDROID_PLATFORM=android-26 \
28+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
29+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
2831
-DEXECUTORCH_BUILD_NEURON=ON \
2932
-B"${build_dir}"
3033

examples/mediatek/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ endif()
2929
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
3030

3131
# Let files say "include <executorch/path/to/header.h>".
32-
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
32+
set(_common_include_directories ${EXECUTORCH_ROOT}/..
33+
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
34+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/include
35+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/json/single_include)
3336

3437
#
3538
# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
@@ -71,9 +74,13 @@ if(${ANDROID})
7174

7275
target_link_libraries(
7376
mtk_executor_runner ${_executor_runner_libs} executorch neuron_backend
77+
executorch_core
78+
extension_evalue_util
79+
extension_runner_util
7480
gflags
7581
)
7682
target_compile_options(mtk_executor_runner PUBLIC ${_common_compile_options})
83+
add_compile_definitions(C10_USING_CUSTOM_GENERATED_MACROS)
7784

7885
set(_mtk_oss_executor_runner__srcs ${_executor_runner__srcs})
7986
list(
@@ -104,6 +111,7 @@ if(${ANDROID})
104111

105112
target_link_libraries(mtk_oss_executor_runner
106113
${_executor_runner_libs}
114+
extension_module
107115
executorch
108116
neuron_backend
109117
gflags
@@ -142,13 +150,18 @@ if(${ANDROID})
142150
target_include_directories(
143151
tokenizer PUBLIC ${_common_include_directories} ${THIRD_PARTY_ABSL_DIR}
144152
${THIRD_PARTY_RE2_DIR} ${LLAMA2_TOKENIZER_DIR}/include
153+
${CMAKE_CURRENT_BINARY_DIR}/tokenizers/third-party/pcre2
154+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/include
145155
)
146156
target_link_libraries(tokenizer PRIVATE re2::re2)
147157
target_sources(
148158
tokenizer
149159
PRIVATE
150160
${LLAMA2_TOKENIZER_DIR}/src/tiktoken.cpp
151161
${LLAMA2_TOKENIZER_DIR}/src/llama2c_tokenizer.cpp
162+
${LLAMA2_TOKENIZER_DIR}/src/regex.cpp
163+
${LLAMA2_TOKENIZER_DIR}/src/bpe_tokenizer_base.cpp
164+
${LLAMA2_TOKENIZER_DIR}/src/re2_regex.cpp
152165
${CMAKE_CURRENT_SOURCE_DIR}/../models/llama/tokenizer/llama_tiktoken.cpp
153166
)
154167

examples/mediatek/executor_runner/mtk_llama_executor_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ Error inference(
285285
std::unique_ptr<Tokenizer> load_tokenizer() {
286286
std::unique_ptr<Tokenizer> tokenizer;
287287
if (FLAGS_tokenizer_type == "bpe") {
288-
tokenizer = std::make_unique<BPETokenizer>();
288+
tokenizer = std::make_unique<Llama2cTokenizer>();
289289
} else if (FLAGS_tokenizer_type == "tiktoken") {
290290
tokenizer = example::get_tiktoken_for_llama();
291291
}

examples/mediatek/mtk_build_examples.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ main() {
2828
-DANDROID_ABI=arm64-v8a \
2929
-DANDROID_NATIVE_API_LEVEL=26 \
3030
-DANDROID_PLATFORM=android-26 \
31+
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
32+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3134
-DEXECUTORCH_BUILD_NEURON=ON \
3235
-B"${build_dir}"
3336

@@ -48,7 +51,6 @@ main() {
4851
-DANDROID_NATIVE_API_LEVEL=26 \
4952
-DANDROID_PLATFORM=android-26 \
5053
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
51-
-DNEURON_BUFFER_ALLOCATOR_LIB="$NEURON_BUFFER_ALLOCATOR_LIB" \
5254
-B"${example_build_dir}" \
5355
$EXECUTORCH_ROOT/$example_dir
5456

0 commit comments

Comments
 (0)