Skip to content

Commit 1ac6ee5

Browse files
authored
fix hifi and g3 build errors, fix cpu build errors
Differential Revision: D66672887 Pull Request resolved: #7162
1 parent cd306d3 commit 1ac6ee5

File tree

3 files changed

+96
-4
lines changed

3 files changed

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

backends/cadence/build_cadence_xtensa.sh renamed to backends/cadence/build_cadence_hifi4.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
set -euo pipefail
99

1010
unset CMAKE_PREFIX_PATH
11+
unset XTENSA_CORE
12+
export XTENSA_CORE=nxp_rt600_RI23_11_newlib
1113
git submodule sync
1214
git submodule update --init
1315
./install_requirements.sh
@@ -53,7 +55,7 @@ if $STEPWISE_BUILD; then
5355
-DHAVE_FNMATCH_H=OFF \
5456
-Bcmake-out/backends/cadence \
5557
backends/cadence
56-
cmake --build cmake-out/backends/cadence -j16
58+
cmake --build cmake-out/backends/cadence -j8
5759
else
5860
echo "Building Cadence toolchain with ExecuTorch packages"
5961
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
@@ -79,7 +81,7 @@ else
7981
-DEXECUTORCH_NNLIB_OPT=ON \
8082
-DHAVE_FNMATCH_H=OFF \
8183
-Bcmake-out
82-
cmake --build cmake-out --target install --config Release -j16
84+
cmake --build cmake-out --target install --config Release -j8
8385
fi
8486

8587
echo "Run simple model to verify cmake build"

backends/cadence/hifi/operators/op_mean.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ Tensor& mean_dim_out(
145145
ET_SWITCH_REALHB_TYPES(in.scalar_type(), ctx, "mean.out", CTYPE_IN, [&] {
146146
ET_SWITCH_FLOATH_TYPES(out.scalar_type(), ctx, "mean.out", CTYPE_OUT, [&] {
147147
CTYPE_OUT* out_data = out.mutable_data_ptr<CTYPE_OUT>();
148-
const size_t num =
149-
torch::executor::exeget_reduced_dim_product(in, dim_list);
148+
const size_t num = torch::executor::get_reduced_dim_product(in, dim_list);
150149
for (size_t out_ix = 0; out_ix < out.numel(); ++out_ix) {
151150
CTYPE_OUT sum = 0;
152151
if (in.numel() > 0) {

0 commit comments

Comments
 (0)