Skip to content

Commit d790908

Browse files
committed
Cmake
1 parent 13408fb commit d790908

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

examples/models/llama/runner/CMakeLists.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ list(
4747
)
4848
list(APPEND _llama_runner__srcs
4949
${CMAKE_CURRENT_SOURCE_DIR}/../tokenizer/llama_tiktoken.cpp
50-
)
51-
list(
52-
APPEND _llama_runner__srcs
53-
${CMAKE_CURRENT_SOURCE_DIR}/../../../../extension/llm/tokenizer/hf_tokenizer.cpp
5450
)
5551

5652
if(CMAKE_TOOLCHAIN_IOS
@@ -77,10 +73,19 @@ add_subdirectory(
7773
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/re2
7874
${CMAKE_CURRENT_BINARY_DIR}/re2
7975
)
76+
add_subdirectory(
77+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/json
78+
${CMAKE_CURRENT_BINARY_DIR}/json
79+
)
80+
target_include_directories(llama_runner
81+
PRIVATE ${CMAKE_INSTALL_PREFIX}/include
82+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/llama.cpp-unicode/include
83+
${EXECUTORCH_ROOT}/extension/llm/tokenizers/third-party/llama.cpp-unicode/src
84+
)
8085
set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag})
8186

8287
set(llama_runner_deps executorch extension_data_loader extension_module
83-
extension_tensor re2::re2
88+
extension_tensor re2::re2 nlohmann_json::nlohmann_json
8489
)
8590

8691
target_link_libraries(llama_runner PUBLIC ${llama_runner_deps})

examples/models/llama/runner/runner.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ Error Runner::load() {
8282
tokenizer_ = nullptr;
8383
// Check if tokenizer_path_ ends with ".json".
8484
if (tokenizer_path_.size() >= 5 &&
85+
8586
tokenizer_path_.compare(tokenizer_path_.size() - 5, 5, ".json") == 0) {
8687
tokenizer_ = std::make_unique<tokenizers::HFTokenizer>();
88+
ET_LOG(Info, "Loading json tokenizer");
8789
tokenizer_->load(tokenizer_path_);
8890
ET_LOG(
8991
Info, "Loaded tokenizer %s as HF tokenizer", tokenizer_path_.c_str());

examples/models/llama/runner/targets.bzl

Lines changed: 1 addition & 1 deletion
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

Lines changed: 7 additions & 0 deletions
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

0 commit comments

Comments
 (0)