xref: /aosp_15_r20/external/executorch/examples/qualcomm/CMakeLists.txt (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
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
7set(CMAKE_CXX_STANDARD 17)
8# qnn_executor_runner: Like executor_runner but with QNN
9
10cmake_minimum_required(VERSION 3.19)
11project(qualcomm_runner_example)
12
13# Source root directory for executorch.
14if(NOT EXECUTORCH_ROOT)
15  set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..)
16endif()
17
18include(${EXECUTORCH_ROOT}/build/Utils.cmake)
19include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
20
21if(NOT PYTHON_EXECUTABLE)
22  resolve_python_executable()
23endif()
24
25if(NOT CMAKE_BUILD_TYPE)
26  set(CMAKE_BUILD_TYPE Debug)
27endif()
28
29# Find prebuilt libraries. executorch package should contain portable_ops_lib,
30# etdump, bundled_program.
31find_package(executorch CONFIG REQUIRED)
32target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED)
33find_package(gflags REQUIRED)
34
35set(_common_compile_options -Wno-deprecated-declarations -fPIC)
36
37# Let files say "include <executorch/path/to/header.h>".
38set(_common_include_directories ${EXECUTORCH_ROOT}/..)
39
40#
41# The `_<target>_srcs` lists are defined by including ${EXECUTORCH_SRCS_FILE}.
42#
43set(EXECUTORCH_SRCS_FILE
44    "${CMAKE_CURRENT_BINARY_DIR}/../../executorch_srcs.cmake"
45)
46extract_sources(${EXECUTORCH_SRCS_FILE})
47include(${EXECUTORCH_SRCS_FILE})
48
49get_filename_component(
50  EXECUTORCH_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE
51)
52
53# portable_ops_lib
54gen_selected_ops(LIB_NAME "full_portable_ops_lib" INCLUDE_ALL_OPS "ON")
55generate_bindings_for_kernels(
56  LIB_NAME "full_portable_ops_lib" FUNCTIONS_YAML
57  ${EXECUTORCH_ROOT}/kernels/portable/functions.yaml
58)
59gen_operators_lib(
60  LIB_NAME "full_portable_ops_lib" KERNEL_LIBS portable_kernels DEPS executorch
61)
62target_compile_options(
63  full_portable_ops_lib INTERFACE -DET_EVENT_TRACER_ENABLED
64)
65target_include_directories(
66  full_portable_ops_lib PUBLIC ${_common_include_directories}
67)
68
69# find RE2 for tokenizer
70set(ABSL_ENABLE_INSTALL ON)
71set(ABSL_PROPAGATE_CXX_STD ON)
72set(_pic_flag ${CMAKE_POSITION_INDEPENDENT_CODE})
73set(CMAKE_POSITION_INDEPENDENT_CODE ON)
74add_subdirectory(
75  ${CMAKE_CURRENT_SOURCE_DIR}/../../extension/llm/third-party/abseil-cpp
76  ${CMAKE_CURRENT_BINARY_DIR}/abseil-cpp
77)
78add_subdirectory(
79  ${CMAKE_CURRENT_SOURCE_DIR}/../../extension/llm/third-party/re2
80  ${CMAKE_CURRENT_BINARY_DIR}/re2
81)
82set(CMAKE_POSITION_INDEPENDENT_CODE ${_pic_flag})
83
84# build qnn_executor_runner
85add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/executor_runner)
86
87# build qnn_llama_runner for llama2
88add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/oss_scripts/llama2)
89
90# build qnn_llama_runner for llama3.2
91add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/oss_scripts/llama3_2)
92
93# build qaihub_llama2_7b_runner and qaihub_llama3_8b_runner
94add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/qaihub_scripts/llama)
95
96# build qaihub_stable_diffusion_runner
97add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/qaihub_scripts/stable_diffusion)
98