Skip to content

Commit 8115a6c

Browse files
committed
Merge remote-tracking branch 'upstream/main' into topics
2 parents 3cfda9b + 13b5605 commit 8115a6c

File tree

135 files changed

+2493
-913
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+2493
-913
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def model_should_run_on_event(model: str, event: str) -> bool:
9090
We put higher priority and fast models to pull request and rest to push.
9191
"""
9292
if event == "pull_request":
93-
return model in ["mv3", "vit", "qwen2_5"] # TODO: remove, just to test the ci
93+
return model in ["mv3", "vit"]
9494
elif event == "push":
9595
# These are super slow. Only run it periodically
9696
return model not in ["dl3", "edsr", "emformer_predict"]
@@ -104,8 +104,12 @@ def model_should_run_on_target_os(model: str, target_os: str) -> bool:
104104
For example, a big model can be disabled in macos due to the limited macos resources.
105105
"""
106106
if target_os == "macos":
107+
# Disabled in macos due to limited resources, and should stay that way even if
108+
# we otherwise re-enable.
107109
return model not in ["llava"]
108-
return True
110+
# Disabled globally because we have test-llava-runner-linux that does a more
111+
# comprehensive E2E test of llava.
112+
return model not in ["llava"]
109113

110114

111115
def export_models_for_ci() -> dict[str, dict]:

backends/arm/operator_support/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# pyre-unsafe
77

88
from . import ( # noqa
9-
bitwise_support,
109
convolution_support,
1110
pool_2d_support,
1211
reduce_sum_support,

backends/arm/operator_support/bitwise_support.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
from typing import final, Optional, Sequence, Type
1212

1313
import torch
14-
1514
import torch.fx as fx
15+
1616
from executorch.backends.arm._passes.arm_pass_utils import get_first_fake_tensor
1717
from executorch.backends.arm._passes.fuse_quantized_activation_pass import (
1818
FuseQuantizedActivationPass,
1919
)
20-
from executorch.backends.arm.tosa_specification import TosaSpecification
20+
from executorch.backends.arm.tosa_specification import Tosa_0_80, TosaSpecification
2121
from executorch.exir.dialects._ops import ops as exir_ops
2222
from torch.fx.passes.operator_support import any_chain, chain, OperatorSupportBase
2323
from torch.fx.passes.utils.source_matcher_utils import get_source_partitions
@@ -89,6 +89,7 @@ def tosa_support_factory(
8989
if not tosa_spec.support_float():
9090
negative_checks.append(NeedsDecompositionCheck())
9191
negative_checks.append(CheckProperQuantization())
92+
negative_checks.append(EthosU55NotSupported(tosa_spec))
9293
return chain(
9394
any_chain(
9495
BaseTOSASupportList(),
@@ -110,6 +111,9 @@ def is_node_supported(
110111
supported = node.op == "call_function" and node.target in [
111112
exir_ops.edge.aten.abs.default,
112113
exir_ops.edge.aten.add.Tensor,
114+
exir_ops.edge.aten.bitwise_and.Tensor,
115+
exir_ops.edge.aten.bitwise_or.Tensor,
116+
exir_ops.edge.aten.bitwise_xor.Tensor,
113117
exir_ops.edge.aten.expand_copy.default,
114118
exir_ops.edge.aten.cat.default,
115119
exir_ops.edge.aten.clamp.default,
@@ -168,6 +172,31 @@ def is_node_supported(
168172
return supported
169173

170174

175+
class EthosU55NotSupported(OperatorSupportBase):
176+
"""
177+
Certain operators are not supported on U55. These are listed in `unsupported` in
178+
is_node_supported().
179+
"""
180+
181+
def __init__(self, tosa_spec: TosaSpecification):
182+
self.tosa_spec = tosa_spec
183+
184+
def is_node_supported(
185+
self, submodules: typing.Mapping[str, torch.nn.Module], node: fx.Node
186+
) -> bool:
187+
if isinstance(self.tosa_spec, Tosa_0_80) and self.tosa_spec.is_U55_subset:
188+
unsupported_ops = [
189+
exir_ops.edge.aten.bitwise_and.Tensor,
190+
exir_ops.edge.aten.bitwise_or.Tensor,
191+
exir_ops.edge.aten.bitwise_xor.Tensor,
192+
]
193+
194+
if node.target in unsupported_ops:
195+
return False
196+
197+
return True
198+
199+
171200
class NeedsDecompositionCheck(OperatorSupportBase):
172201
"""
173202
Targeted operators need to be decomposed prior to quantization in order to get a pair of q-dq-nodes surrounding
@@ -308,11 +337,11 @@ def is_node_supported(
308337
if not input_quantized:
309338
return False
310339

311-
output_quantized = output_quantized or all(
312-
(output_node.target == self.q_op)
313-
or (not get_first_fake_tensor(output_node).dtype.is_floating_point)
314-
for output_node in node.users
340+
all_q_users = all(
341+
(output_node.target == self.q_op) for output_node in node.users
315342
)
343+
is_floating_point = get_first_fake_tensor(node).dtype.is_floating_point
344+
output_quantized = output_quantized or all_q_users or not is_floating_point
316345

317346
if not output_quantized:
318347
return False

backends/arm/scripts/build_executorch.sh

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,17 @@ et_root_dir=$(realpath ${et_root_dir})
1616
toolchain_cmake=${script_dir}/../../../examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
1717
toolchain_cmake=$(realpath ${toolchain_cmake})
1818

19-
20-
2119
et_build_root="${et_root_dir}/arm_test"
2220
build_type="Release"
21+
build_devtools=false
2322
build_with_etdump=false
2423

25-
2624
help() {
2725
echo "Usage: $(basename $0) [options]"
2826
echo "Options:"
2927
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
3028
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
29+
echo " --devtools Build Devtools libs"
3130
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
3231
exit 0
3332
}
@@ -37,32 +36,33 @@ for arg in "$@"; do
3736
-h|--help) help ;;
3837
--et_build_root=*) et_build_root="${arg#*=}";;
3938
--build_type=*) build_type="${arg#*=}";;
39+
--devtools) build_devtools=true ;;
4040
--etdump) build_with_etdump=true ;;
4141
*)
4242
;;
4343
esac
4444
done
4545

4646
et_build_dir="${et_build_root}/cmake-out"
47+
48+
# Used for flatcc host excutable if Devtools is used
4749
et_build_host_dir=${et_build_root}/cmake-out-host-tools
4850

4951
set -x
5052
cd "${et_root_dir}"
5153

52-
build_with_etdump_flags=""
5354
if [ "$build_with_etdump" = true ] ; then
5455
( set +x ;
5556
echo "--------------------------------------------------------------------------------" ;
56-
echo "Build ExecuTorch Libraries host flatcc bin ${build_type} into ${et_build_host_dir} - ${et_build_host_dir}/bin/flatcc" ;
57+
echo "Build ExecuTorch Libraries host flatcc bin ${build_type} into ${et_build_host_dir}/bin/flatcc" ;
5758
echo "--------------------------------------------------------------------------------" )
5859

59-
6060
# Build host flatcc bin
6161
# This is a way to work around that the flatcc executable get build for target (e.g. Arm) later
6262
# and get replaced. flatcc is a tool used on the host for etdump and BundleIO handling.
6363
# The way to solve this is to generate it once for the host, then copy it to ${et_build_host_dir}/bin
6464
# and later point that out with -DFLATCC_EXECUTABLE=${et_build_host_dir}/bin/flatcc later.
65-
mkdir -p ${et_build_host_dir}
65+
6666
cmake \
6767
-DCMAKE_INSTALL_PREFIX=${et_build_host_dir} \
6868
-DCMAKE_BUILD_TYPE=${build_type} \
@@ -79,25 +79,39 @@ if [ "$build_with_etdump" = true ] ; then
7979
-B"${et_build_host_dir}" \
8080
"${et_root_dir}"
8181

82-
# Copy host flatcc excutable to it's saved when we build for target (Arm) later
82+
# third-party/flatcc/bin/flatcc gets build already in the in the cmake config step above
83+
# so there is no cmake building step done
84+
85+
# Copy host flatcc excutable so it's saved when we build for target (Arm) later
86+
et_build_host_dir=$(realpath ${et_build_host_dir})
8387
mkdir -p ${et_build_host_dir}/bin
8488
cp third-party/flatcc/bin/flatcc ${et_build_host_dir}/bin
85-
86-
# Add DevTools flags use in the Target build below
87-
build_with_etdump_flags="-DEXECUTORCH_BUILD_DEVTOOLS=ON \
88-
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
89-
-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=OFF \
90-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=OFF \
91-
-DFLATCC_ALLOW_WERROR=OFF \
92-
-DFLATCC_EXECUTABLE=${et_build_host_dir}/bin/flatcc "
93-
echo "build_with_etdump_flags=$build_with_etdump_flags"
9489
fi
9590

9691
( set +x ;
9792
echo "--------------------------------------------------------------------------------" ;
9893
echo "Build ExecuTorch target libs ${build_type} into '${et_build_dir}'" ;
9994
echo "--------------------------------------------------------------------------------" )
10095

96+
build_devtools_flags=" -DEXECUTORCH_BUILD_DEVTOOLS=OFF "
97+
if [ "$build_devtools" = true ] ; then
98+
build_devtools_flags=" -DEXECUTORCH_BUILD_DEVTOOLS=ON "
99+
fi
100+
101+
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF "
102+
if [ "$build_with_etdump" = true ] ; then
103+
# Add DevTools flags use in the Target build below
104+
build_with_etdump_flags="-DEXECUTORCH_BUILD_DEVTOOLS=ON \
105+
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
106+
-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=OFF \
107+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=OFF \
108+
-DFLATCC_ALLOW_WERROR=OFF \
109+
-DFLATCC_EXECUTABLE=${et_build_host_dir}/bin/flatcc "
110+
fi
111+
112+
echo "Building with Devtools: ${build_devtools_flags} ${build_with_etdump_flags}"
113+
114+
101115
# Build
102116
cmake \
103117
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
@@ -108,6 +122,7 @@ cmake \
108122
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
109123
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
110124
-DEXECUTORCH_ENABLE_LOGGING=ON \
125+
${build_devtools_flags} \
111126
${build_with_etdump_flags} \
112127
-DFLATC_EXECUTABLE="$(which flatc)" \
113128
-B"${et_build_dir}" \

backends/arm/scripts/build_executorch_runner.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ pte_file=""
1515
target="ethos-u55-128"
1616
build_type="Release"
1717
system_config=""
18+
bundleio=false
1819
build_with_etdump=false
1920
extra_build_flags=""
2021
output_folder_set=false
2122
output_folder="."
2223
et_build_root="${et_root_dir}/arm_test"
2324
ethosu_tools_dir=${et_root_dir}/examples/arm/ethos-u-scratch
2425

26+
build_bundleio_flags=" -DET_BUNDLE_IO=OFF "
27+
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF "
28+
2529
help() {
2630
echo "Usage: $(basename $0) [options]"
2731
echo "Options:"
@@ -30,6 +34,7 @@ help() {
3034
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
3135
echo " --system_config=<CONFIG> System configuration to select from the Vela configuration file (see vela.ini). Default: Ethos_U55_High_End_Embedded for EthosU55 targets, Ethos_U85_SYS_DRAM_Mid for EthosU85 targets."
3236
echo " NOTE: If given, this option must match the given target. This option also sets timing adapter values customized for specific hardware, see ./executor_runner/CMakeLists.txt."
37+
echo " --bundleio Support both pte and Bundle IO bpte using Devtools BundelIO with Input/RefOutput included"
3338
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
3439
echo " --extra_build_flags=<FLAGS> Extra flags to pass to cmake like -DET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE=60000 Default: none "
3540
echo " --output=<FOLDER> Output folder Default: <MODEL>/<MODEL>_<TARGET INFO>.pte"
@@ -45,6 +50,7 @@ for arg in "$@"; do
4550
--target=*) target="${arg#*=}";;
4651
--build_type=*) build_type="${arg#*=}";;
4752
--system_config=*) system_config="${arg#*=}";;
53+
--bundleio) bundleio=true ;;
4854
--etdump) build_with_etdump=true ;;
4955
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
5056
--output=*) output_folder="${arg#*=}" ; output_folder_set=true ;;
@@ -64,9 +70,8 @@ et_build_dir=${et_build_root}/cmake-out
6470
et_build_dir=$(realpath ${et_build_dir})
6571

6672
if [ "$output_folder_set" = false ] ; then
67-
pte_folder=$(cd -- "$( dirname -- "${pte_file}" )" &> /dev/null && pwd)
68-
pte_short_name=$(basename -- "${pte_file}" ".pte")
69-
output_folder="$pte_folder/$pte_short_name"
73+
# remove file ending
74+
output_folder=${pte_file%.*}
7075
fi
7176

7277
if [[ ${system_config} == "" ]]
@@ -86,28 +91,32 @@ else
8691
target_cpu=cortex-m85
8792
fi
8893
echo "--------------------------------------------------------------------------------"
89-
echo "Build Arm Baremetal executor_runner for ${target} with ${pte_file} using ${system_config} to '${output_folder}/cmake-out'"
94+
echo "Build Arm Baremetal executor_runner for ${target} with ${pte_file} using ${system_config} ${extra_build_flags} to '${output_folder}/cmake-out'"
9095
echo "--------------------------------------------------------------------------------"
9196

9297
cd ${et_root_dir}/examples/arm/executor_runner
9398

94-
build_with_etdump_flags=""
99+
if [ "$bundleio" = true ] ; then
100+
build_bundleio_flags=" -DET_BUNDLE_IO=ON "
101+
fi
102+
95103
if [ "$build_with_etdump" = true ] ; then
96-
echo "Building with etdump e.g. -DEXECUTORCH_ENABLE_EVENT_TRACER=ON"
97104
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=ON "
98105
fi
99106

100-
mkdir -p "$output_folder"
107+
echo "Building with BundleIO/etdump/extra flags: ${build_bundleio_flags} ${build_with_etdump_flags} ${extra_build_flags}"
108+
mkdir -p "${output_folder}"
101109

102110
cmake \
103111
-DCMAKE_BUILD_TYPE=${build_type} \
104112
-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
105113
-DTARGET_CPU=${target_cpu} \
106114
-DET_DIR_PATH:PATH=${et_root_dir} \
107115
-DET_BUILD_DIR_PATH:PATH=${et_build_dir} \
108-
-DET_PTE_FILE_PATH:PATH="${pte_file}" \
116+
-DET_PTE_FILE_PATH:PATH="${pte_file}" \
109117
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
110118
-DETHOSU_TARGET_NPU_CONFIG=${target} \
119+
${build_bundleio_flags} \
111120
${build_with_etdump_flags} \
112121
-DPYTHON_EXECUTABLE=$(which python3) \
113122
-DSYSTEM_CONFIG=${system_config} \

backends/arm/scripts/run_fvp.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ _setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly ins
1919

2020
elf_file=""
2121
target="ethos-u55-128"
22+
timeout="240"
2223

2324
help() {
2425
echo "Usage: $(basename $0) [options]"
2526
echo "Options:"
2627
echo " --elf=<ELF_FILE> elf file to run"
2728
echo " --target=<TARGET> Target to build and run for Default: ${target}"
29+
echo " --timeout=<TIME_IN_SEC> Maximum target runtime, used to detect hanging, might need to be higer on large models Default: ${timeout}"
2830
exit 0
2931
}
3032

@@ -33,6 +35,7 @@ for arg in "$@"; do
3335
-h|--help) help ;;
3436
--elf=*) elf_file="${arg#*=}";;
3537
--target=*) target="${arg#*=}";;
38+
--timeout=*) timeout="${arg#*=}";;
3639
*)
3740
;;
3841
esac
@@ -63,6 +66,7 @@ num_macs=$(echo ${target} | cut -d - -f 3)
6366

6467
echo "--------------------------------------------------------------------------------"
6568
echo "Running ${elf_file} for ${target} run with FVP:${fvp_model} num_macs:${num_macs}"
69+
echo "WARNING: Corstone FVP is not cycle accurate and should NOT be used to determine valid runtime"
6670
echo "--------------------------------------------------------------------------------"
6771

6872
log_file=$(mktemp)
@@ -75,7 +79,7 @@ if [[ ${target} == *"ethos-u55"* ]]; then
7579
-C mps3_board.uart0.out_file='-' \
7680
-C mps3_board.uart0.shutdown_on_eot=1 \
7781
-a "${elf_file}" \
78-
--timelimit 220 2>&1 | tee ${log_file} || true # seconds
82+
--timelimit ${timeout} 2>&1 | tee ${log_file} || true # seconds
7983
echo "[${BASH_SOURCE[0]}] Simulation complete, $?"
8084
elif [[ ${target} == *"ethos-u85"* ]]; then
8185
${fvp_model} \
@@ -86,7 +90,7 @@ elif [[ ${target} == *"ethos-u85"* ]]; then
8690
-C mps4_board.uart0.out_file='-' \
8791
-C mps4_board.uart0.shutdown_on_eot=1 \
8892
-a "${elf_file}" \
89-
--timelimit 220 2>&1 | tee ${log_file} || true # seconds
93+
--timelimit ${timeout} 2>&1 | tee ${log_file} || true # seconds
9094
echo "[${BASH_SOURCE[0]}] Simulation complete, $?"
9195
else
9296
echo "Running ${elf_file} for ${target} is not supported"

0 commit comments

Comments
 (0)