Skip to content

Commit

Permalink
Add suffixes to some cmake flags. (pytorch#3485)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#3485

.

Differential Revision: D56869549
  • Loading branch information
shoumikhin authored and facebook-github-bot committed May 2, 2024
1 parent 159ca73 commit 33ca1fa
Show file tree
Hide file tree
Showing 42 changed files with 180 additions and 169 deletions.
8 changes: 4 additions & 4 deletions .ci/scripts/build_llama_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ install_executorch_and_backend_lib() {
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_QUANTIZED=ON \
-DEXECUTORCH_BUILD_BACKEND_XNNPACK=ON \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DXNNPACK_ENABLE_ARM_BF16=OFF \
-Bcmake-android-out .

Expand All @@ -42,7 +42,7 @@ build_llama_runner() {
-DANDROID_PLATFORM=android-23 \
-DCMAKE_INSTALL_PREFIX=cmake-android-out \
-DCMAKE_BUILD_TYPE=Release -DPYTHON_EXECUTABLE=python \
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-Bcmake-android-out/examples/models/llama2 examples/models/llama2

cmake --build cmake-android-out/examples/models/llama2 -j4 --config Release
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ build_cmake_xnn_executor_runner() {
&& mkdir ${CMAKE_OUTPUT_DIR} \
&& cd ${CMAKE_OUTPUT_DIR} \
&& retry cmake -DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_BUILD_BACKEND_XNNPACK=ON \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)

Expand Down
14 changes: 7 additions & 7 deletions .ci/scripts/test_llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ cmake_install_executorch_libraries() {
-DCMAKE_BUILD_TYPE=Debug \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_CUSTOM="$CUSTOM" \
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_QUANTIZED=ON \
-DEXECUTORCH_BUILD_XNNPACK="$XNNPACK" \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="$CUSTOM" \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_BACKEND_XNNPACK="$XNNPACK" \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
-Bcmake-out .
cmake --build cmake-out -j9 --target install --config Debug
Expand All @@ -88,9 +88,9 @@ cmake_build_llama_runner() {
retry cmake -DBUCK2="$BUCK" \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Debug \
-DEXECUTORCH_BUILD_CUSTOM="$CUSTOM" \
-DEXECUTORCH_BUILD_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_XNNPACK="$XNNPACK" \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="$CUSTOM" \
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
-DEXECUTORCH_BUILD_BACKEND_XNNPACK="$XNNPACK" \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
-Bcmake-out/${dir} \
${dir}
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_quantized_aot_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build_cmake_quantized_aot_lib() {
&& cd ${CMAKE_OUTPUT_DIR} \
&& retry cmake -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="$CMAKE_PREFIX_PATH" \
-DEXECUTORCH_BUILD_QUANTIZED_OPS_AOT=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON \
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)

cmake --build ${CMAKE_OUTPUT_DIR} -j4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
# Setup MacOS dependencies as there is no Docker support on MacOS atm
PYTHON_EXECUTABLE=python \
EXECUTORCH_BUILD_PYBIND=ON \
EXECUTORCH_BUILD_XNNPACK=ON \
EXECUTORCH_BUILD_BACKEND_XNNPACK=ON \
.ci/scripts/setup-linux.sh "${BUILD_TOOL}"
# Run pytest with coverage
Expand All @@ -64,7 +64,7 @@ jobs:
# Setup MacOS dependencies as there is no Docker support on MacOS atm
PYTHON_EXECUTABLE=python \
EXECUTORCH_BUILD_PYBIND=ON \
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON" \
CMAKE_ARGS="-DEXECUTORCH_BUILD_BACKEND_COREML=ON -DEXECUTORCH_BUILD_BACKEND_MPS=ON -DEXECUTORCH_BUILD_BACKEND_XNNPACK=ON" \
${CONDA_RUN} --no-capture-output \
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull.yml
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ jobs:
# build module for executorch.extension.pybindings.portable_lib
BUILD_TOOL=${{ matrix.build-tool }}
PYTHON_EXECUTABLE=python \
EXECUTORCH_BUILD_XNNPACK=ON \
EXECUTORCH_BUILD_BACKEND_XNNPACK=ON \
EXECUTORCH_BUILD_PYBIND=ON \
bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
Expand Down
76 changes: 39 additions & 37 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# it again until you pull from the upstream repo again.
#
# NOTE: Build options can be configured by passing arguments to cmake. For
# example, to enable the EXECUTORCH_BUILD_XNNPACK option, change the cmake
# command to 'cmake -DEXECUTORCH_BUILD_XNNPACK=ON ..'.
# example, to enable the EXECUTORCH_BUILD_BACKEND_XNNPACK option, change the
# cmake command to 'cmake -DEXECUTORCH_BUILD_BACKEND_XNNPACK=ON ..'.
#[[
(rm -rf cmake-out \
&& mkdir cmake-out \
Expand Down Expand Up @@ -140,11 +140,15 @@ option(EXECUTORCH_BUILD_ANDROID_JNI "Build Android JNI" OFF)
option(EXECUTORCH_BUILD_ARM_BAREMETAL
"Build the Arm Baremetal flow for Cortex-M and Ethos-U" OFF)

option(EXECUTORCH_BUILD_COREML "Build the Core ML backend" OFF)
option(EXECUTORCH_BUILD_BACKEND_COREML "Build the Core ML backend" OFF)

option(EXECUTORCH_BUILD_CUSTOM "Build the custom kernels" OFF)
option(EXECUTORCH_BUILD_BACKEND_MPS "Build the MPS backend" OFF)

option(EXECUTORCH_BUILD_CUSTOM_OPS_AOT "Build the custom ops lib for AOT" OFF)
option(EXECUTORCH_BUILD_BACKEND_QNN "Build the Qualcomm backend" OFF)

option(EXECUTORCH_BUILD_BACKEND_XNNPACK "Build the XNNPACK backend" OFF)

option(EXECUTORCH_BUILD_BACKEND_VULKAN "Build the Vulkan backend" OFF)

option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "Build the Data Loader extension"
OFF)
Expand All @@ -156,24 +160,21 @@ option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL "Build the Runner Util extension"

option(EXECUTORCH_BUILD_GTESTS "Build googletest based test binaries" OFF)

option(EXECUTORCH_BUILD_MPS "Build the MPS backend" OFF)
option(EXECUTORCH_BUILD_KERNELS_CUSTOM "Build the custom kernels" OFF)

option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)
option(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT "Build the custom ops lib for AOT"
OFF)

option(EXECUTORCH_BUILD_QNN "Build the Qualcomm backend" OFF)
option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED "Build the optimized kernels" OFF)

option(EXECUTORCH_BUILD_OPTIMIZED "Build the optimized kernels" OFF)
option(EXECUTORCH_BUILD_KERNELS_QUANTIZED "Build the quantized kernels" OFF)

option(EXECUTORCH_BUILD_QUANTIZED "Build the quantized kernels" OFF)
option(EXECUTORCH_BUILD_PYBIND "Build the Python Bindings" OFF)

option(EXECUTORCH_BUILD_SDK "Build the ExecuTorch SDK")

option(EXECUTORCH_BUILD_SIZE_TEST "Build the size test" OFF)

option(EXECUTORCH_BUILD_XNNPACK "Build the XNNPACK backend" OFF)

option(EXECUTORCH_BUILD_VULKAN "Build the Vulkan backend" OFF)

#
# pthreadpool: build pthreadpool library. Disable on unsupported platforms
#
Expand All @@ -187,12 +188,12 @@ cmake_dependent_option(
cmake_dependent_option(EXECUTORCH_BUILD_CPUINFO "Build cpuinfo library." ON
"NOT EXECUTORCH_BUILD_ARM_BAREMETAL" OFF)

if(EXECUTORCH_BUILD_CUSTOM_OPS_AOT)
set(EXECUTORCH_BUILD_CUSTOM ON)
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
endif()

if(EXECUTORCH_BUILD_CUSTOM)
set(EXECUTORCH_BUILD_OPTIMIZED ON)
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
endif()

if(EXECUTORCH_BUILD_CPUINFO)
Expand Down Expand Up @@ -245,8 +246,8 @@ if(EXECUTORCH_BUILD_PTHREADPOOL)
CACHE BOOL "")
if(APPLE)
set(PTHREADPOOL_SYNC_PRIMITIVE
"condvar"
CACHE STRING "")
"condvar"
CACHE STRING "")
endif()
add_subdirectory("${PTHREADPOOL_SOURCE_DIR}")
set(CMAKE_POSITION_INDEPENDENT_CODE
Expand Down Expand Up @@ -381,7 +382,8 @@ find_library(DL_LIBRARY_EXISTS NAMES dl)
if(DL_LIBRARY_EXISTS)
target_link_libraries(executorch_no_prim_ops PRIVATE dl) # For dladdr()
endif()
target_include_directories(executorch_no_prim_ops PUBLIC ${_common_include_directories})
target_include_directories(executorch_no_prim_ops
PUBLIC ${_common_include_directories})
target_compile_options(executorch_no_prim_ops PUBLIC ${_common_compile_options})
if(MAX_KERNEL_NUM)
target_compile_definitions(executorch_no_prim_ops
Expand All @@ -403,17 +405,17 @@ target_link_options_shared_lib(executorch)
#
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/portable)

if(EXECUTORCH_BUILD_CUSTOM)
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
# TODO: move all custom kernels to ${CMAKE_CURRENT_SOURCE_DIR}/kernels/custom
add_subdirectory(
${CMAKE_CURRENT_SOURCE_DIR}/examples/models/llama2/custom_ops)
endif()

if(EXECUTORCH_BUILD_OPTIMIZED)
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/optimized)
endif()

if(EXECUTORCH_BUILD_QUANTIZED)
if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/kernels/quantized)
endif()

Expand Down Expand Up @@ -447,14 +449,14 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
# Baseline libraries that executor_runner will link against.
set(_executor_runner_libs executorch gflags)

if(EXECUTORCH_BUILD_OPTIMIZED)
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
list(APPEND _executor_runner_libs optimized_native_cpu_ops_lib)
else()
list(APPEND _executor_runner_libs portable_ops_lib)
endif()

# Generate lib to register quantized ops
if(EXECUTORCH_BUILD_QUANTIZED)
if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
list(APPEND _executor_runner_libs quantized_ops_lib)
endif()

Expand Down Expand Up @@ -494,27 +496,27 @@ if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/runner_util)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
if(EXECUTORCH_BUILD_BACKEND_XNNPACK)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/xnnpack)
endif()

if(EXECUTORCH_BUILD_VULKAN)
if(EXECUTORCH_BUILD_BACKEND_VULKAN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
endif()

if(EXECUTORCH_BUILD_QNN)
if(EXECUTORCH_BUILD_BACKEND_QNN)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/qualcomm)
endif()

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/arm)
endif()

if(EXECUTORCH_BUILD_MPS)
if(EXECUTORCH_BUILD_BACKEND_MPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/mps)
endif()

if(EXECUTORCH_BUILD_COREML)
if(EXECUTORCH_BUILD_BACKEND_COREML)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/apple/coreml)
endif()

Expand Down Expand Up @@ -544,33 +546,33 @@ if(EXECUTORCH_BUILD_PYBIND)
util
torch)

if(EXECUTORCH_BUILD_COREML)
if(EXECUTORCH_BUILD_BACKEND_COREML)
list(APPEND _dep_libs coremldelegate)
endif()

if(EXECUTORCH_BUILD_MPS)
if(EXECUTORCH_BUILD_BACKEND_MPS)
list(APPEND _dep_libs mpsdelegate)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
if(EXECUTORCH_BUILD_BACKEND_XNNPACK)
# need to explicitly specify XNNPACK here otherwise uses XNNPACK symbols
# from libtorch_cpu
list(APPEND _dep_libs xnnpack_backend XNNPACK)
endif()

if(EXECUTORCH_BUILD_QUANTIZED)
if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
target_link_options_shared_lib(quantized_ops_lib)
list(APPEND _dep_libs quantized_kernels quantized_ops_lib)
endif()

# TODO(larryliu): Fix macOS 2 dylibs having 2 sets of static variables issue
if(EXECUTORCH_BUILD_CUSTOM_OPS_AOT AND NOT APPLE)
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT AND NOT APPLE)
list(APPEND _dep_libs custom_ops_aot_lib)
endif()
# TODO(laryliu): Fix linux duplicate registation problem. In GH CI worker
# libcustom_ops.a doesn't dedup with the one indirectly linked from
# libcustom_ops_aot_lib.a
if(EXECUTORCH_BUILD_CUSTOM AND APPLE)
if(EXECUTORCH_BUILD_KERNELS_CUSTOM AND APPLE)
target_link_options_shared_lib(custom_ops)
list(APPEND _dep_libs custom_ops)
endif()
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/coreml/scripts/build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ cmake "$EXECUTORCH_ROOT_PATH" -B"$CMAKE_EXECUTORCH_BUILD_DIR_PATH" \
-DDEPLOYMENT_TARGET=13.0 \
-DFLATC_EXECUTABLE="$(which flatc)" \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_BUILD_XNNPACK=OFF \
-DEXECUTORCH_BUILD_BACKEND_XNNPACK=OFF \
-DEXECUTORCH_BUILD_GFLAGS=OFF

cmake --build "$CMAKE_EXECUTORCH_BUILD_DIR_PATH" -j9 -t executorch
Expand Down
4 changes: 2 additions & 2 deletions backends/qualcomm/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ if [ "$BUILD_AARCH64" = true ]; then
# If we build debug type, we need to change flatcc to flatcc_d
cmake .. \
-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT \
-DEXECUTORCH_BUILD_QNN=ON \
-DEXECUTORCH_BUILD_BACKEND_QNN=ON \
-DEXECUTORCH_BUILD_SDK=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
Expand Down Expand Up @@ -108,7 +108,7 @@ if [ "$BUILD_X86_64" = true ]; then
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
-DEXECUTORCH_BUILD_QNN=ON \
-DEXECUTORCH_BUILD_BACKEND_QNN=ON \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DBUCK2=$BUCK2 \
-S $PRJ_ROOT \
Expand Down
4 changes: 2 additions & 2 deletions backends/qualcomm/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Make sure `buck2` is under a directory in `PATH`.
cd $EXECUTORCH_ROOT
mkdir build_x86_64
cd build_x86_64
cmake .. -DEXECUTORCH_BUILD_QNN=ON -DQNN_SDK_ROOT=${QNN_SDK_ROOT}
cmake .. -DEXECUTORCH_BUILD_BACKEND_QNN=ON -DQNN_SDK_ROOT=${QNN_SDK_ROOT}
cmake --build . -t "PyQnnManagerAdaptor" "PyQnnWrapperAdaptor" -j8

# install Python APIs to correct import path
Expand All @@ -94,7 +94,7 @@ cd build_android
# build executorch & qnn_executorch_backend
cmake .. \
-DCMAKE_INSTALL_PREFIX=$PWD \
-DEXECUTORCH_BUILD_QNN=ON \
-DEXECUTORCH_BUILD_BACKEND_QNN=ON \
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI='arm64-v8a' \
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# ~~~
# It should also be cmake-lint clean.
#
# The targets in this file will be built if EXECUTORCH_BUILD_VULKAN is ON
# The targets in this file will be built if EXECUTORCH_BUILD_BACKEND_VULKAN is ON

cmake_minimum_required(VERSION 3.19)

Expand Down
4 changes: 2 additions & 2 deletions backends/vulkan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ and test on a local Android device. Android devices have built in support for
Vulkan, and the Android NDK ships with a GLSL compiler, which is needed to
compile the Vulkan Compute Library's GLSL compute shaders.

The Vulkan Delegate libraries can be built by setting `-DEXECUTORCH_BUILD_VULKAN=ON`
The Vulkan Delegate libraries can be built by setting `-DEXECUTORCH_BUILD_BACKEND_VULKAN=ON`
when building with CMake.

First, make sure that you have the Android NDK installed - Android NDK r25c is
Expand All @@ -161,7 +161,7 @@ Delegate:
pp cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$ANDROID_ABI \
-DEXECUTORCH_BUILD_VULKAN=ON \
-DEXECUTORCH_BUILD_BACKEND_VULKAN=ON \
-DPYTHON_EXECUTABLE=python \
-Bcmake-android-out && \
cmake --build cmake-android-out -j16 --target install)
Expand Down
2 changes: 1 addition & 1 deletion backends/vulkan/cmake/ShaderLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# ~~~
# It should also be cmake-lint clean.
#
# The targets in this file will be built if EXECUTORCH_BUILD_VULKAN is ON
# The targets in this file will be built if EXECUTORCH_BUILD_BACKEND_VULKAN is ON

if(ANDROID)
if(NOT ANDROID_NDK)
Expand Down

0 comments on commit 33ca1fa

Please sign in to comment.