|
| 1 | +# Copyright (c) Qualcomm Innovation Center, Inc. |
| 2 | +# All rights reserved |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +# preprocess qaihub runner src files for llama2,3 |
| 8 | +set(_qaihub_llama_runner__srcs ${_llama_runner__srcs}) |
| 9 | +list(TRANSFORM _qaihub_llama_runner__srcs PREPEND "${EXECUTORCH_SOURCE_DIR}/") |
| 10 | +list(FILTER _qaihub_llama_runner__srcs EXCLUDE REGEX ".*(/runner/).*") |
| 11 | +list(PREPEND _qaihub_llama_runner__srcs |
| 12 | + ${CMAKE_CURRENT_LIST_DIR}/runner/runner.cpp |
| 13 | + ${CMAKE_CURRENT_LIST_DIR}/runner/runner.h |
| 14 | + ${CMAKE_CURRENT_LIST_DIR}/runner/io_memory.cpp |
| 15 | + ${CMAKE_CURRENT_LIST_DIR}/runner/io_memory.h |
| 16 | +) |
| 17 | + |
| 18 | + |
| 19 | +# preprocess qaihub llama2 7b runner src files |
| 20 | +set(_qaihub_llama2_7b_runner__srcs ${_qaihub_llama_runner__srcs}) |
| 21 | + |
| 22 | +list(PREPEND _qaihub_llama2_7b_runner__srcs |
| 23 | + ${CMAKE_CURRENT_LIST_DIR}/llama2/qaihub_llama2_7b_runner.cpp |
| 24 | +) |
| 25 | + |
| 26 | +# build qaihub llama2 7b runner |
| 27 | +add_executable(qaihub_llama2_7b_runner ${_qaihub_llama2_7b_runner__srcs}) |
| 28 | +target_include_directories(qaihub_llama2_7b_runner |
| 29 | + PUBLIC ${_common_include_directories} |
| 30 | +) |
| 31 | +target_link_libraries(qaihub_llama2_7b_runner |
| 32 | + qnn_executorch_backend |
| 33 | + executorch_no_prim_ops |
| 34 | + extension_data_loader |
| 35 | + extension_module |
| 36 | + gflags |
| 37 | +) |
| 38 | +target_compile_options(qaihub_llama2_7b_runner |
| 39 | + PUBLIC ${_common_compile_options} |
| 40 | +) |
| 41 | + |
| 42 | + |
| 43 | +# preprocess qaihub llama3 8b runner src files |
| 44 | +set(_qaihub_llama3_8b_runner__srcs ${_qaihub_llama_runner__srcs}) |
| 45 | + |
| 46 | +list(PREPEND _qaihub_llama3_8b_runner__srcs |
| 47 | + ${CMAKE_CURRENT_LIST_DIR}/llama3/qaihub_llama3_8b_runner.cpp |
| 48 | +) |
| 49 | + |
| 50 | +# Adding a compile option to differentiate llama2 with llama3 logic |
| 51 | +list(APPEND _common_compile_options -DQAIHUB_LLAMA3_RUNNER) |
| 52 | + |
| 53 | +# find RE2 for tokenizer |
| 54 | +set(ABSL_ENABLE_INSTALL ON) |
| 55 | +set(ABSL_PROPAGATE_CXX_STD ON) |
| 56 | +set(_pic_flag ${CMAKE_POSITION_INDEPENDENT_CODE}) |
| 57 | +set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 58 | +add_subdirectory( |
| 59 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../extension/llm/third-party/abseil-cpp |
| 60 | + ${CMAKE_CURRENT_BINARY_DIR}/abseil-cpp |
| 61 | +) |
| 62 | +add_subdirectory( |
| 63 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../extension/llm/third-party/re2 |
| 64 | + ${CMAKE_CURRENT_BINARY_DIR}/re2 |
| 65 | +) |
| 66 | +set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag}) |
| 67 | + |
| 68 | + |
| 69 | +list(APPEND _qaihub_llama3_8b_runner__srcs |
| 70 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../../../extension/llm/tokenizer/tiktoken.cpp |
| 71 | +) |
| 72 | +list(APPEND _qaihub_llama3_8b_runner__srcs |
| 73 | + ${CMAKE_CURRENT_SOURCE_DIR}/../../../models/llama2/tokenizer/llama_tiktoken.cpp |
| 74 | +) |
| 75 | +set(_preprocessor_flag -DET_USE_TIKTOKEN) |
| 76 | + |
| 77 | + |
| 78 | +# build qaihub llama3 8b runner |
| 79 | +add_executable(qaihub_llama3_8b_runner ${_qaihub_llama3_8b_runner__srcs}) |
| 80 | +target_include_directories(qaihub_llama3_8b_runner |
| 81 | + PUBLIC ${_common_include_directories} |
| 82 | +) |
| 83 | + |
| 84 | +target_link_libraries(qaihub_llama3_8b_runner |
| 85 | + qnn_executorch_backend |
| 86 | + executorch_no_prim_ops |
| 87 | + extension_data_loader |
| 88 | + extension_module |
| 89 | + gflags |
| 90 | + re2::re2 |
| 91 | +) |
| 92 | +target_compile_options(qaihub_llama3_8b_runner |
| 93 | + PUBLIC ${_common_compile_options} |
| 94 | +) |
0 commit comments