File tree Expand file tree Collapse file tree 4 files changed +20
-6
lines changed
examples/models/llama/runner Expand file tree Collapse file tree 4 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 47
47
)
48
48
list (APPEND _llama_runner__srcs
49
49
${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
54
50
)
55
51
56
52
if (CMAKE_TOOLCHAIN_IOS
@@ -77,10 +73,19 @@ add_subdirectory(
77
73
${EXECUTORCH_ROOT} /extension/llm/tokenizers/third-party/re2
78
74
${CMAKE_CURRENT_BINARY_DIR} /re2
79
75
)
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
+ )
80
85
set (CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag} )
81
86
82
87
set (llama_runner_deps executorch extension_data_loader extension_module
83
- extension_tensor re2::re2
88
+ extension_tensor re2::re2 nlohmann_json::nlohmann_json
84
89
)
85
90
86
91
target_link_libraries (llama_runner PUBLIC ${llama_runner_deps} )
Original file line number Diff line number Diff line change @@ -82,8 +82,10 @@ Error Runner::load() {
82
82
tokenizer_ = nullptr ;
83
83
// Check if tokenizer_path_ ends with ".json".
84
84
if (tokenizer_path_.size () >= 5 &&
85
+
85
86
tokenizer_path_.compare (tokenizer_path_.size () - 5 , 5 , " .json" ) == 0 ) {
86
87
tokenizer_ = std::make_unique<tokenizers::HFTokenizer>();
88
+ ET_LOG (Info, " Loading json tokenizer" );
87
89
tokenizer_->load (tokenizer_path_);
88
90
ET_LOG (
89
91
Info, " Loaded tokenizer %s as HF tokenizer" , tokenizer_path_.c_str ());
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def define_common_targets():
49
49
"//executorch/runtime/core/exec_aten/util:tensor_util" + aten_suffix ,
50
50
"//executorch/examples/models/llama/tokenizer:tiktoken" ,
51
51
"//pytorch/tokenizers:llama2c_tokenizer" ,
52
- "//pytorch/tokenizers:hf_tokenizer" ,
52
+ "//pytorch/tokenizers:hf_tokenizer" ,
53
53
] + (_get_operator_lib (aten )) + ([
54
54
# Vulkan API currently cannot build on some platforms (e.g. Apple, FBCODE)
55
55
# Therefore enable it explicitly for now to avoid failing tests
Original file line number Diff line number Diff line change @@ -49,6 +49,13 @@ set(runner_deps executorch extension_data_loader extension_module
49
49
50
50
target_link_libraries (extension_llm_runner PUBLIC ${runner_deps} )
51
51
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
+
52
59
target_include_directories (
53
60
extension_llm_runner INTERFACE ${_common_include_directories}
54
61
${EXECUTORCH_ROOT} /extension/llm/tokenizers/include
You can’t perform that action at this time.
0 commit comments