|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# This source code is licensed under the BSD-style license found in the |
| 6 | +# LICENSE file in the root directory of this source tree. |
| 7 | + |
| 8 | +set -euo pipefail |
| 9 | + |
| 10 | +unset CMAKE_PREFIX_PATH |
| 11 | +git submodule sync |
| 12 | +git submodule update --init |
| 13 | +./install_requirements.sh |
| 14 | + |
| 15 | +rm -rf cmake-out |
| 16 | + |
| 17 | +STEPWISE_BUILD=false |
| 18 | + |
| 19 | +if $STEPWISE_BUILD; then |
| 20 | + echo "Building ExecuTorch" |
| 21 | + cmake -DCMAKE_INSTALL_PREFIX=cmake-out \ |
| 22 | + -DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ |
| 23 | + -DCMAKE_BUILD_TYPE=Release \ |
| 24 | + -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \ |
| 25 | + -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ |
| 26 | + -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \ |
| 27 | + -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ |
| 28 | + -DEXECUTORCH_BUILD_CPUINFO=OFF \ |
| 29 | + -DEXECUTORCH_ENABLE_LOGGING=ON \ |
| 30 | + -DEXECUTORCH_USE_DL=OFF \ |
| 31 | + -DEXECUTORCH_BUILD_CADENCE=OFF \ |
| 32 | + -DFLATC_EXECUTABLE="$(which flatc)" \ |
| 33 | + -Bcmake-out . |
| 34 | + |
| 35 | + echo "Building any Cadence-specific binaries on top" |
| 36 | + cmake -DBUCK2="$BUCK" \ |
| 37 | + -DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ |
| 38 | + -DCMAKE_INSTALL_PREFIX=cmake-out \ |
| 39 | + -DCMAKE_BUILD_TYPE=Release \ |
| 40 | + -DEXECUTORCH_BUILD_HOST_TARGETS=ON \ |
| 41 | + -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ |
| 42 | + -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ |
| 43 | + -DEXECUTORCH_BUILD_CADENCE=ON \ |
| 44 | + -DFLATC_EXECUTABLE="$(which flatc)" \ |
| 45 | + -DEXECUTORCH_ENABLE_LOGGING=ON \ |
| 46 | + -DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \ |
| 47 | + -DEXECUTORCH_USE_DL=OFF \ |
| 48 | + -DBUILD_EXECUTORCH_PORTABLE_OPS=ON \ |
| 49 | + -DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \ |
| 50 | + -DPYTHON_EXECUTABLE=python3 \ |
| 51 | + -DEXECUTORCH_NNLIB_OPT=ON \ |
| 52 | + -DEXECUTORCH_BUILD_GFLAGS=ON \ |
| 53 | + -DHAVE_FNMATCH_H=OFF \ |
| 54 | + -Bcmake-out/backends/cadence \ |
| 55 | + backends/cadence |
| 56 | + cmake --build cmake-out/backends/cadence -j16 |
| 57 | +else |
| 58 | + echo "Building Cadence toolchain with ExecuTorch packages" |
| 59 | + cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags" |
| 60 | + cmake -DBUCK2="$BUCK" \ |
| 61 | + -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \ |
| 62 | + -DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \ |
| 63 | + -DCMAKE_INSTALL_PREFIX=cmake-out \ |
| 64 | + -DCMAKE_BUILD_TYPE=Release \ |
| 65 | + -DEXECUTORCH_BUILD_HOST_TARGETS=ON \ |
| 66 | + -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \ |
| 67 | + -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \ |
| 68 | + -DEXECUTORCH_BUILD_CADENCE=OFF \ |
| 69 | + -DFLATC_EXECUTABLE="$(which flatc)" \ |
| 70 | + -DEXECUTORCH_ENABLE_LOGGING=ON \ |
| 71 | + -DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \ |
| 72 | + -DEXECUTORCH_USE_DL=OFF \ |
| 73 | + -DBUILD_EXECUTORCH_PORTABLE_OPS=ON \ |
| 74 | + -DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \ |
| 75 | + -DPYTHON_EXECUTABLE=python3 \ |
| 76 | + -DEXECUTORCH_NNLIB_OPT=ON \ |
| 77 | + -DEXECUTORCH_BUILD_GFLAGS=ON \ |
| 78 | + -DHAVE_FNMATCH_H=OFF \ |
| 79 | + -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \ |
| 80 | + -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ |
| 81 | + -DEXECUTORCH_BUILD_CPUINFO=OFF \ |
| 82 | + -Bcmake-out |
| 83 | + cmake --build cmake-out --target install --config Release -j16 |
| 84 | +fi |
| 85 | + |
| 86 | +echo "Run simple model to verify cmake build" |
| 87 | +python3 -m examples.portable.scripts.export --model_name="add" |
| 88 | +xt-run --turbo cmake-out/executor_runner --model_path=add.pte |
0 commit comments