|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 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 | +cmake_minimum_required(VERSION 3.24) |
| 8 | +project(whisper_runner) |
| 9 | + |
| 10 | +set(CMAKE_CXX_STANDARD 17) |
| 11 | +set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 12 | + |
| 13 | +set(EXECUTORCH_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../..") |
| 14 | +include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) |
| 15 | + |
| 16 | +# Let files say "include <executorch/path/to/header.h>" |
| 17 | +set(_common_include_directories ${EXECUTORCH_ROOT}/..) |
| 18 | + |
| 19 | +# Need this for gflags for some reason |
| 20 | +set(gflags_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../../third-party/gflags) |
| 21 | +find_package(gflags REQUIRED) |
| 22 | + |
| 23 | +list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/../../..) |
| 24 | +find_package(executorch CONFIG REQUIRED FIND_ROOT_PATH_BOTH) |
| 25 | +executorch_target_link_options_shared_lib(executorch) |
| 26 | + |
| 27 | +set(link_libraries executorch gflags) |
| 28 | +set(_srcs multimodal.cpp) |
| 29 | + |
| 30 | +list( |
| 31 | + APPEND |
| 32 | + link_libraries |
| 33 | + optimized_native_cpu_ops_lib |
| 34 | + quantized_ops_lib |
| 35 | + custom_ops |
| 36 | + cpublas |
| 37 | + eigen_blas |
| 38 | +) |
| 39 | +executorch_target_link_options_shared_lib(optimized_native_cpu_ops_lib) |
| 40 | +executorch_target_link_options_shared_lib(quantized_ops_lib) |
| 41 | +executorch_target_link_options_shared_lib(custom_ops) |
| 42 | + |
| 43 | +# XNNPACK |
| 44 | +if(TARGET xnnpack_backend) |
| 45 | + set(xnnpack_backend_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod) |
| 46 | + if(TARGET kleidiai) |
| 47 | + list(APPEND xnnpack_backend_libs kleidiai) |
| 48 | + endif() |
| 49 | + list(APPEND link_libraries ${xnnpack_backend_libs}) |
| 50 | + executorch_target_link_options_shared_lib(xnnpack_backend) |
| 51 | +endif() |
| 52 | + |
| 53 | +# Add LLM runner and extension module |
| 54 | +if(NOT TARGET extension_llm_runner) |
| 55 | + message( |
| 56 | + FATAL_ERROR |
| 57 | + "ExecuTorch must be installed with EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER enabled." |
| 58 | + ) |
| 59 | +endif() |
| 60 | + |
| 61 | +# Needed for cpuinfo where it uses android specific log lib |
| 62 | +if(ANDROID) |
| 63 | + list(APPEND link_libraries log) |
| 64 | +endif() |
| 65 | + |
| 66 | +# Add the required ExecuTorch extensions for multimodal LLM runner |
| 67 | +list( |
| 68 | + APPEND |
| 69 | + link_libraries |
| 70 | + extension_llm_runner |
| 71 | + extension_module |
| 72 | + extension_data_loader |
| 73 | + extension_tensor |
| 74 | + extension_flat_tensor |
| 75 | +) |
| 76 | + |
| 77 | +# Link CUDA backend |
| 78 | +if(EXECUTORCH_BUILD_CUDA) |
| 79 | + find_package(CUDAToolkit REQUIRED) |
| 80 | + list(APPEND link_libraries aoti_cuda) |
| 81 | + executorch_target_link_options_shared_lib(aoti_cuda) |
| 82 | +endif() |
| 83 | + |
| 84 | +if(EXECUTORCH_BUILD_METAL) |
| 85 | + list(APPEND link_libraries metal_backend) |
| 86 | + executorch_target_link_options_shared_lib(metal_backend) |
| 87 | +endif() |
| 88 | + |
| 89 | +# Add tokenizers |
| 90 | +list(APPEND link_libraries tokenizers::tokenizers) |
| 91 | + |
| 92 | +add_executable(whisper_runner runner.cpp main.cpp) |
| 93 | + |
| 94 | +target_include_directories(whisper_runner PUBLIC ${_common_include_directories}) |
| 95 | + |
| 96 | +target_link_libraries( |
| 97 | + whisper_runner |
| 98 | + PUBLIC |
| 99 | + ${link_libraries} |
| 100 | +) |
| 101 | +target_compile_options(whisper_runner PUBLIC ${_common_compile_options}) |
0 commit comments