Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hifi and g3 build errors, fix cpu build errors #7162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backends/cadence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ include(${EXECUTORCH_ROOT}/build/Utils.cmake)

# Let files say "include <executorch/path/to/header.h>".
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
set(TARGET_DIR reference)

if(EXECUTORCH_CADENCE_CPU_RUNNER)
include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
Expand Down Expand Up @@ -61,6 +60,9 @@ if(EXECUTORCH_CADENCE_CPU_RUNNER)
${_common_include_directories}
)

set(TARGET_DIR reference)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels)

target_link_libraries(
cadence_runner
executorch
Expand Down
91 changes: 91 additions & 0 deletions backends/cadence/build_cadence_fusionG3.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

set -euo pipefail

unset CMAKE_PREFIX_PATH
unset XTENSA_CORE
export XTENSA_CORE=FCV_FG3GP
git submodule sync
git submodule update --init
./install_requirements.sh

rm -rf cmake-out

STEPWISE_BUILD=false

if $STEPWISE_BUILD; then
echo "Building ExecuTorch"
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
-DEXECUTORCH_BUILD_CPUINFO=OFF \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_USE_DL=OFF \
-DEXECUTORCH_BUILD_CADENCE=OFF \
-DFLATC_EXECUTABLE="$(which flatc)" \
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out .

echo "Building any Cadence-specific binaries on top"
cmake -DBUCK2="$BUCK" \
-DCMAKE_TOOLCHAIN_FILE=/home/zonglinpeng/ws/zonglinpeng/executorch/backends/cadence/cadence.cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
-DEXECUTORCH_BUILD_CADENCE=ON \
-DFLATC_EXECUTABLE="$(which flatc)" \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
-DEXECUTORCH_USE_DL=OFF \
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
-DPYTHON_EXECUTABLE=python3 \
-DEXECUTORCH_FUSION_G3_OPT=ON \
-DEXECUTORCH_BUILD_GFLAGS=ON \
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out/backends/cadence \
backends/cadence
cmake --build cmake-out/backends/cadence -j8
else
echo "Building Cadence toolchain with ExecuTorch packages"
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
cmake -DBUCK2="$BUCK" \
-DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
-DHAVE_SYS_STAT_H=ON \
-DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
-DEXECUTORCH_BUILD_CPUINFO=OFF \
-DEXECUTORCH_BUILD_FLATC=OFF \
-DEXECUTORCH_BUILD_CADENCE=ON \
-DFLATC_EXECUTABLE="$(which flatc)" \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
-DEXECUTORCH_USE_DL=OFF \
-DBUILD_EXECUTORCH_PORTABLE_OPS=ON \
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=OFF \
-DPYTHON_EXECUTABLE=python3 \
-DEXECUTORCH_FUSION_G3_OPT=ON \
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out
cmake --build cmake-out --target install --config Release -j8
fi

echo "Run simple model to verify cmake build"
python3 -m examples.portable.scripts.export --model_name="add"
xt-run --turbo cmake-out/executor_runner --model_path=add.pte
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
set -euo pipefail

unset CMAKE_PREFIX_PATH
unset XTENSA_CORE
export XTENSA_CORE=nxp_rt600_RI23_11_newlib
git submodule sync
git submodule update --init
./install_requirements.sh
Expand Down Expand Up @@ -53,7 +55,7 @@ if $STEPWISE_BUILD; then
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out/backends/cadence \
backends/cadence
cmake --build cmake-out/backends/cadence -j16
cmake --build cmake-out/backends/cadence -j8
else
echo "Building Cadence toolchain with ExecuTorch packages"
cmake_prefix_path="${PWD}/cmake-out/lib/cmake/ExecuTorch;${PWD}/cmake-out/third-party/gflags"
Expand All @@ -79,7 +81,7 @@ else
-DEXECUTORCH_NNLIB_OPT=ON \
-DHAVE_FNMATCH_H=OFF \
-Bcmake-out
cmake --build cmake-out --target install --config Release -j16
cmake --build cmake-out --target install --config Release -j8
fi

echo "Run simple model to verify cmake build"
Expand Down
3 changes: 1 addition & 2 deletions backends/cadence/hifi/operators/op_mean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ Tensor& mean_dim_out(
ET_SWITCH_REALHB_TYPES(in.scalar_type(), ctx, "mean.out", CTYPE_IN, [&] {
ET_SWITCH_FLOATH_TYPES(out.scalar_type(), ctx, "mean.out", CTYPE_OUT, [&] {
CTYPE_OUT* out_data = out.mutable_data_ptr<CTYPE_OUT>();
const size_t num =
torch::executor::exeget_reduced_dim_product(in, dim_list);
const size_t num = torch::executor::get_reduced_dim_product(in, dim_list);
for (size_t out_ix = 0; out_ix < out.numel(); ++out_ix) {
CTYPE_OUT sum = 0;
if (in.numel() > 0) {
Expand Down
Loading