Skip to content

Commit

Permalink
chore: move sampler compile to cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Oct 7, 2024
1 parent a70d398 commit 6e85587
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ add_subdirectory(executorch/extension/llm/third-party/abseil-cpp)
add_subdirectory(executorch/extension/llm/third-party/re2)
add_subdirectory(executorch/extension/llm/third-party/sentencepiece)

file(GLOB_RECURSE TOKENIZER_SRCS
file(GLOB TOKENIZER_SRCS
executorch/extension/llm/tokenizer/bpe_tokenizer.cpp
executorch/extension/llm/tokenizer/tiktoken.cpp
)
file(GLOB_RECURSE TOKENIZER_HDRS
file(GLOB TOKENIZER_HDRS
executorch/extension/llm/tokenizer/*.h
)
add_library(tokenizer STATIC
Expand All @@ -127,3 +127,25 @@ install(
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

# SAMPLER

file(GLOB SAMPLER_SRCS
executorch/extension/llm/sampler/sampler.cpp
)
file(GLOB SAMPLER_HDRS
executorch/extension/llm/sampler/sampler.h
)
add_library(sampler STATIC
${SAMPLER_SRCS}
${SAMPLER_HDRS}
)
target_include_directories(sampler PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(sampler PUBLIC tokenizer)

install(
TARGETS sampler
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
1 change: 1 addition & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fn main() {
link("extension_module_static");
link("extension_data_loader");
link("tokenizer");
link("sampler");

// XNNPACK
link_whole("xnnpack_backend");
Expand Down
1 change: 0 additions & 1 deletion src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use neon::types::Finalize;

cpp! {{
#include <executorch/extension/llm/sampler/sampler.h>
#include <executorch/extension/llm/sampler/sampler.cpp>
}}

cpp_class!(pub unsafe struct Sampler as "torch::executor::Sampler");
Expand Down

0 comments on commit 6e85587

Please sign in to comment.