Skip to content

Commit 832f410

Browse files
committed
Update
[ghstack-poisoned]
2 parents 8dc7ba0 + 7f5cfd3 commit 832f410

File tree

175 files changed

+2918
-1400
lines changed

Some content is hidden

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

175 files changed

+2918
-1400
lines changed

.ci/scripts/gather_test_models.py

Lines changed: 1 addition & 1 deletion
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"]
93+
return model in ["mv3", "vit", "qwen2_5"] # TODO: remove, just to test the ci
9494
elif event == "push":
9595
# These are super slow. Only run it periodically
9696
return model not in ["dl3", "edsr", "emformer_predict"]

.ci/scripts/test_model.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,17 @@ test_model() {
9191
# Install requirements for llama vision.
9292
bash examples/models/llama3_2_vision/install_requirements.sh
9393
fi
94-
# python3 -m examples.portable.scripts.export --model_name="llama2" should works too
94+
if [[ "${MODEL_NAME}" == "qwen2_5" ]]; then
95+
# Install requirements for export_llama
96+
bash examples/models/llama/install_requirements.sh
97+
# Test export_llama script: python3 -m examples.models.llama.export_llama.
98+
# Use Llama random checkpoint with Qwen 2.5 1.5b model configuration.
99+
"${PYTHON_EXECUTABLE}" -m examples.models.llama.export_llama --model "${MODEL_NAME}" -c examples/models/llama/params/demo_rand_params.pth -p examples/models/qwen2_5/1_5b_config.json
100+
rm "./${MODEL_NAME}.pte"
101+
return # Skip running with portable executor runnner since portable doesn't support Qwen's biased linears.
102+
fi
103+
104+
# Export a basic .pte and run the model.
95105
"${PYTHON_EXECUTABLE}" -m examples.portable.scripts.export --model_name="${MODEL_NAME}" "${STRICT}"
96106
run_portable_executor_runner
97107
}

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/examples/llm_manual @larryliu0820
3333
/examples/llm_pte_finetuning @JacobSzwejbka
3434
/examples/mediatek @cccclai
35-
/examples/models @lucylq
35+
/examples/models @lucylq @jackzhxng
3636
/examples/portable @larryliu0820 @manuelcandales
3737
/examples/qualcomm @cccclai
3838
/examples/selective_build @lucylq @larryliu0820 @JacobSzwejbka

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
@@ -90,6 +90,7 @@ def tosa_support_factory(
9090
if not tosa_spec.support_float():
9191
negative_checks.append(NeedsDecompositionCheck())
9292
negative_checks.append(CheckProperQuantization())
93+
negative_checks.append(EthosU55NotSupported(tosa_spec))
9394
return chain(
9495
any_chain(
9596
BaseTOSASupportList(),
@@ -111,6 +112,9 @@ def is_node_supported(
111112
supported = node.op == "call_function" and node.target in [
112113
exir_ops.edge.aten.abs.default,
113114
exir_ops.edge.aten.add.Tensor,
115+
exir_ops.edge.aten.bitwise_and.Tensor,
116+
exir_ops.edge.aten.bitwise_or.Tensor,
117+
exir_ops.edge.aten.bitwise_xor.Tensor,
114118
exir_ops.edge.aten.expand_copy.default,
115119
exir_ops.edge.aten.cat.default,
116120
exir_ops.edge.aten.clamp.default,
@@ -170,6 +174,31 @@ def is_node_supported(
170174
return supported
171175

172176

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

313-
output_quantized = output_quantized or all(
314-
(output_node.target == self.q_op)
315-
or (not get_first_fake_tensor(output_node).dtype.is_floating_point)
316-
for output_node in node.users
342+
all_q_users = all(
343+
(output_node.target == self.q_op) for output_node in node.users
317344
)
345+
is_floating_point = get_first_fake_tensor(node).dtype.is_floating_point
346+
output_quantized = output_quantized or all_q_users or not is_floating_point
318347

319348
if not output_quantized:
320349
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} \

0 commit comments

Comments
 (0)