Skip to content

Commit 7cd009e

Browse files
kirklandsignfacebook-github-bot
authored andcommitted
Portable selected op workaround for arm backend (#1122)
Summary: Arm uses portable yaml, and it only needs softmax. However, now we disabled root op list, and can only support yaml, so this breaks arm build. We temporarily support yaml and ops list while we make a selective build rule for arm. Pull Request resolved: #1122 Reviewed By: larryliu0820 Differential Revision: D50936359 Pulled By: kirklandsign fbshipit-source-id: b220d3526f2a40769ebd06b492a3563da299920d
1 parent a5e5295 commit 7cd009e

File tree

6 files changed

+38
-29
lines changed

6 files changed

+38
-29
lines changed

.ci/docker/ubuntu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ RUN rm install_linter.sh utils.sh requirements-lintrunner.txt
5454
ARG ARM_SDK
5555
COPY --chown=ci-user:ci-user ./arm /opt/arm
5656
# Set up ARM SDK if needed
57-
RUN if [ -n "${ARM_SDK}" ]; then git config --global user.email "ci@example.com"; git config --global user.name "OSS CI"; bash /opt/arm/setup.sh --i-agree-to-the-contained-eula /opt/arm-sdk; chown -R ci-user:ci-user /opt/arm-sdk; fi
57+
RUN if [ -n "${ARM_SDK}" ]; then git config --global user.email "ossci@example.com"; git config --global user.name "OSS CI"; bash /opt/arm/setup.sh --i-agree-to-the-contained-eula /opt/arm-sdk; chown -R ci-user:ci-user /opt/arm-sdk; fi
5858

5959
USER ci-user
6060
CMD ["bash"]

.github/workflows/pull.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,6 @@ jobs:
106106
# Test selective build
107107
PYTHON_EXECUTABLE=python bash examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
108108
109-
test-arm-backend-delegation:
110-
name: test-arm-backend-delegation
111-
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
112-
with:
113-
runner: linux.2xlarge
114-
docker-image: executorch-ubuntu-22.04-arm-sdk
115-
submodules: 'true'
116-
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
117-
script: |
118-
# The generic Linux job chooses to use base env, not the one setup by the image
119-
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
120-
conda activate "${CONDA_ENV}"
121-
122-
source .ci/scripts/utils.sh
123-
install_flatc_from_source
124-
install_executorch
125-
# Test selective build
126-
source /opt/arm-sdk/setup_path.sh
127-
PYTHON_EXECUTABLE=python bash examples/arm/run.sh /opt/arm-sdk buck2
128-
129109
unittest:
130110
uses: ./.github/workflows/_unittest.yml
131111
with:

examples/arm/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ set(_common_compile_options -Wno-deprecated-declarations -fPIC)
3131
# Let files say "include <executorch/path/to/header.h>".
3232
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
3333

34-
find_package(executorch CONFIG REQUIRED)
34+
find_package(executorch CONFIG REQUIRED HINTS ${CMAKE_INSTALL_PREFIX})
3535
target_include_directories(executorch INTERFACE ${_common_include_directories})
3636

3737
include(${EXECUTORCH_ROOT}/build/Utils.cmake)
@@ -40,5 +40,6 @@ include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
4040
# Generate C++ bindings to register kernels into both PyTorch (for AOT) and
4141
# Executorch (for runtime). Here select all ops in functions.yaml
4242
gen_selected_ops("" "${EXECUTORCH_SELECT_OPS_LIST}" "")
43-
generate_bindings_for_kernels(${EXECUTORCH_ROOT}/kernels/portable/functions.yaml "")
44-
gen_operators_lib("arm_ops_lib" portable_kernels executorch)
43+
generate_bindings_for_kernels(
44+
${EXECUTORCH_ROOT}/kernels/portable/functions.yaml "")
45+
gen_operators_lib("portable_ops_lib" portable_kernels executorch)

examples/arm/aot_arm_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import torch
1414
import torch._export as export
1515

16-
from executorch.backends.arm.arm_backend import ArmPartitioner
16+
from executorch.backends.arm.arm_partitioner import ArmPartitioner
1717
from executorch.exir import EdgeCompileConfig
1818

1919
from ..portable.utils import export_to_edge, save_pte_program
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 8ee58a2ac02693ec5f261c866fc333d268f253d4 Mon Sep 17 00:00:00 2001
2+
From: Hansong Zhang <[email protected]>
3+
Date: Thu, 2 Nov 2023 14:48:03 -0700
4+
Subject: [PATCH] Use libportable_ops_lib instead
5+
6+
---
7+
applications/executorch_tests/CMakeLists.txt | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/applications/executorch_tests/CMakeLists.txt b/applications/executorch_tests/CMakeLists.txt
11+
index a07f22f..174b911 100644
12+
--- a/applications/executorch_tests/CMakeLists.txt
13+
+++ b/applications/executorch_tests/CMakeLists.txt
14+
@@ -43,7 +43,7 @@ message("**********************")
15+
16+
set(LIB_ET_RUNTIME "${ET_BUILD_DIR_PATH}/libexecutorch.a")
17+
set(LIB_ET_ETHOS "${ET_BUILD_DIR_PATH}/backends/arm/libexecutorch_delegate_ethos_u.a")
18+
-set(LIB_ET_OP_REGISTRATION "${ET_BUILD_DIR_PATH}/examples/arm/libarm_ops_lib.a")
19+
+set(LIB_ET_OP_REGISTRATION "${ET_BUILD_DIR_PATH}/examples/arm/libportable_ops_lib.a")
20+
set(LIB_ET_OP_KERNELS "${ET_BUILD_DIR_PATH}/kernels/portable/libportable_kernels.a")
21+
22+
add_custom_target(
23+
--
24+
2.39.3
25+

examples/arm/run.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,16 @@ function generate_pte_file() {
5454

5555
# build ExecuTorch Libraries
5656
function build_executorch() {
57+
set -x
58+
5759
[[ -d "${et_build_dir}" ]] \
5860
&& echo "[${FUNCNAME[0]}] Warn: using already existing build-dir for executorch: ${et_build_dir}!!"
5961
mkdir -p "${et_build_dir}"
6062

6163
cd "${et_root_dir}"
6264
cmake \
6365
-DBUCK2=${buck2} \
64-
-DCMAKE_INSTALL_PREFIX=cmake-out \
66+
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
6567
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
6668
-DCMAKE_BUILD_TYPE=Release \
6769
-DEXECUTORCH_ENABLE_LOGGING=ON \
@@ -74,18 +76,19 @@ function build_executorch() {
7476
echo "[${FUNCNAME[0]}] Configured CMAKE"
7577

7678
n=$(nproc)
77-
cmake --build ${et_build_dir} --target install --config Release -- -j"$((n - 5))"
79+
cmake --build ${et_build_dir} -j"$((n - 5))" --target install --config Release
7880

7981
cmake \
80-
-DCMAKE_INSTALL_PREFIX=cmake-out \
82+
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
8183
-DCMAKE_BUILD_TYPE=Release \
8284
-DEXECUTORCH_SELECT_OPS_LIST="aten::_softmax.out" \
8385
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
8486
-B"${et_build_dir}"/examples/arm \
85-
-Dexecutorch_DIR="${et_root_dir}"/build \
8687
"${et_root_dir}"/examples/arm
8788
cmake --build ${et_build_dir}/examples/arm -- -j"$((n - 5))"
8889

90+
set +x
91+
8992
cd "${et_build_dir}"
9093
echo "[${FUNCNAME[0]}] Generated static libraries for ExecuTorch:"
9194
find . -name "*.a" -exec ls -al {} \;

0 commit comments

Comments
 (0)