| 
 | 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 | +unset XTENSA_CORE  | 
 | 12 | +export XTENSA_CORE=FCV_FG3GP  | 
 | 13 | +git submodule sync  | 
 | 14 | +git submodule update --init  | 
 | 15 | +./backends/cadence/install_requirements.sh  | 
 | 16 | +./install_executorch.sh  | 
 | 17 | + | 
 | 18 | +rm -rf cmake-out  | 
 | 19 | + | 
 | 20 | +STEPWISE_BUILD=false  | 
 | 21 | + | 
 | 22 | +if $STEPWISE_BUILD; then  | 
 | 23 | +    echo "Building ExecuTorch"  | 
 | 24 | +    CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DCMAKE_INSTALL_PREFIX=cmake-out \  | 
 | 25 | +        -DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake  \  | 
 | 26 | +        -DCMAKE_BUILD_TYPE=Release \  | 
 | 27 | +        -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \  | 
 | 28 | +        -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \  | 
 | 29 | +        -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \  | 
 | 30 | +        -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \  | 
 | 31 | +        -DEXECUTORCH_BUILD_CPUINFO=OFF \  | 
 | 32 | +        -DEXECUTORCH_ENABLE_LOGGING=ON \  | 
 | 33 | +        -DEXECUTORCH_USE_DL=OFF \  | 
 | 34 | +        -DEXECUTORCH_BUILD_CADENCE=OFF \  | 
 | 35 | +        -DFLATC_EXECUTABLE="$(which flatc)" \  | 
 | 36 | +        -DHAVE_FNMATCH_H=OFF \  | 
 | 37 | +        -Bcmake-out .  | 
 | 38 | + | 
 | 39 | +    echo "Building any Cadence-specific binaries on top"  | 
 | 40 | +    CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \  | 
 | 41 | +        -DCMAKE_TOOLCHAIN_FILE=/home/zonglinpeng/ws/zonglinpeng/executorch/backends/cadence/cadence.cmake \  | 
 | 42 | +        -DCMAKE_INSTALL_PREFIX=cmake-out \  | 
 | 43 | +        -DCMAKE_BUILD_TYPE=Release \  | 
 | 44 | +        -DEXECUTORCH_BUILD_HOST_TARGETS=ON \  | 
 | 45 | +        -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \  | 
 | 46 | +        -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \  | 
 | 47 | +        -DEXECUTORCH_BUILD_CADENCE=ON \  | 
 | 48 | +        -DFLATC_EXECUTABLE="$(which flatc)" \  | 
 | 49 | +        -DEXECUTORCH_ENABLE_LOGGING=ON \  | 
 | 50 | +        -DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \  | 
 | 51 | +        -DEXECUTORCH_USE_DL=OFF \  | 
 | 52 | +        -DBUILD_EXECUTORCH_PORTABLE_OPS=ON \  | 
 | 53 | +        -DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \  | 
 | 54 | +        -DPYTHON_EXECUTABLE=python3 \  | 
 | 55 | +        -DEXECUTORCH_FUSION_G3_OPT=ON \  | 
 | 56 | +        -DEXECUTORCH_BUILD_GFLAGS=ON \  | 
 | 57 | +        -DHAVE_FNMATCH_H=OFF \  | 
 | 58 | +        -Bcmake-out/backends/cadence \  | 
 | 59 | +        backends/cadence  | 
 | 60 | +    cmake --build cmake-out/backends/cadence  -j8  | 
 | 61 | +else  | 
 | 62 | +    echo "Building Cadence toolchain with ExecuTorch packages"  | 
 | 63 | +    cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"  | 
 | 64 | +    CXXFLAGS="-fno-exceptions -fno-rtti" cmake -DBUCK2="$BUCK" \  | 
 | 65 | +        -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \  | 
 | 66 | +        -DHAVE_SYS_STAT_H=ON \  | 
 | 67 | +        -DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \  | 
 | 68 | +        -DCMAKE_INSTALL_PREFIX=cmake-out \  | 
 | 69 | +        -DCMAKE_BUILD_TYPE=Release \  | 
 | 70 | +        -DEXECUTORCH_BUILD_HOST_TARGETS=ON \  | 
 | 71 | +        -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \  | 
 | 72 | +        -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \  | 
 | 73 | +        -DEXECUTORCH_BUILD_CPUINFO=OFF \  | 
 | 74 | +        -DEXECUTORCH_BUILD_FLATC=OFF \  | 
 | 75 | +        -DEXECUTORCH_BUILD_CADENCE=ON \  | 
 | 76 | +        -DFLATC_EXECUTABLE="$(which flatc)" \  | 
 | 77 | +        -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \  | 
 | 78 | +        -DEXECUTORCH_ENABLE_LOGGING=ON \  | 
 | 79 | +        -DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \  | 
 | 80 | +        -DEXECUTORCH_USE_DL=OFF \  | 
 | 81 | +        -DBUILD_EXECUTORCH_PORTABLE_OPS=ON \  | 
 | 82 | +        -DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \  | 
 | 83 | +        -DPYTHON_EXECUTABLE=python3 \  | 
 | 84 | +        -DEXECUTORCH_FUSION_G3_OPT=ON \  | 
 | 85 | +        -DHAVE_FNMATCH_H=OFF \  | 
 | 86 | +        -Bcmake-out  | 
 | 87 | +    cmake --build cmake-out --target install --config Release -j8  | 
 | 88 | +fi  | 
 | 89 | + | 
 | 90 | +echo "Run simple model to verify cmake build"  | 
 | 91 | +python3 -m examples.portable.scripts.export --model_name="add"  | 
 | 92 | +xt-run --turbo cmake-out/executor_runner  --model_path=add.pte  | 
0 commit comments