Skip to content

Commit 9b69efe

Browse files
committed
Cmake
1 parent 1e9bb6e commit 9b69efe

File tree

5 files changed

+21
-2
lines changed

5 files changed

+21
-2
lines changed

examples/models/llama/runner/CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,19 @@ add_subdirectory(
7777
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/re2
7878
${CMAKE_CURRENT_BINARY_DIR}/re2
7979
)
80+
add_subdirectory(
81+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/json
82+
${CMAKE_CURRENT_BINARY_DIR}/json
83+
)
84+
target_include_directories(llama_runner
85+
PRIVATE ${CMAKE_INSTALL_PREFIX}/include
86+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/llama.cpp-unicode/include
87+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/llama.cpp-unicode/src
88+
)
8089
set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag})
8190

8291
set(llama_runner_deps executorch extension_data_loader extension_module
83-
extension_tensor re2::re2
92+
extension_tensor re2::re2 nlohmann_json::nlohmann_json
8493
)
8594

8695
target_link_libraries(llama_runner PUBLIC ${llama_runner_deps})

examples/models/llama/runner/runner.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ Error Runner::load() {
8080
tokenizer_ = nullptr;
8181
// Check if tokenizer_path_ ends with ".json".
8282
if (tokenizer_path_.size() >= 5 &&
83+
8384
tokenizer_path_.compare(tokenizer_path_.size() - 5, 5, ".json") == 0) {
8485
tokenizer_ = std::make_unique<tokenizers::HFTokenizer>();
86+
ET_LOG(Info, "Loading json tokenizer");
8587
tokenizer_->load(tokenizer_path_);
8688
ET_LOG(
8789
Info, "Loaded tokenizer %s as HF tokenizer", tokenizer_path_.c_str());

examples/models/llama/runner/targets.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def define_common_targets():
4949
"//executorch/runtime/core/exec_aten/util:tensor_util" + aten_suffix,
5050
"//executorch/examples/models/llama/tokenizer:tiktoken",
5151
"//pytorch/tokenizers:llama2c_tokenizer",
52-
"//pytorch/tokenizers:hf_tokenizer",
52+
"//pytorch/tokenizers:hf_tokenizer",
5353
] + (_get_operator_lib(aten)) + ([
5454
# Vulkan API currently cannot build on some platforms (e.g. Apple, FBCODE)
5555
# Therefore enable it explicitly for now to avoid failing tests

extension/llm/runner/CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ set(runner_deps executorch extension_data_loader extension_module
4949

5050
target_link_libraries(extension_llm_runner PUBLIC ${runner_deps})
5151

52+
target_include_directories(
53+
extension_llm_runner
54+
PUBLIC
55+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/llama.cpp-unicode/include
56+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/llama.cpp-unicode/src
57+
)
58+
5259
target_include_directories(
5360
extension_llm_runner INTERFACE ${_common_include_directories}
5461
${EXECUTORCH_ROOT}/extension/llm/tokenizers/include

extension/llm/tokenizer/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ add_subdirectory(
2828
${CMAKE_CURRENT_SOURCE_DIR}/../tokenizers/third-party/re2
2929
${CMAKE_CURRENT_BINARY_DIR}/re2
3030
)
31+
3132
set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag})
3233

3334
list(TRANSFORM _extension_llm_tokenizer__srcs PREPEND "${EXECUTORCH_ROOT}/")

0 commit comments

Comments
 (0)