Skip to content

Commit da132c3

Browse files
author
Github Executorch
committed
Summary: Fix CI job: test-arm-backend (test_run_ethosu_fvp) / linux-job.
Add 'qdq_fusion_pass' flag to run.sh & aot_arm_compiler. This allows certain CI jobs not to fail as we conditionally allow fusion op to be enabled / disabled with this flag. Note that since the fusion op passes are still WIP and not all ops are yet supported, it is good to rely on this flag until we have full fledged support for fusion ops. Test Plan: 1. examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=qops --bundleio --no_delegate --portable_kernels="aten::sub.out,aten::add.out,aten::mul.out" --qdq_fusion_op=true // The above fails as 'QuantOpTest' has mixed binary operations. 2. examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=qops --bundleio --no_delegate --portable_kernels="aten::sub.out,aten::add.out,aten::mul.out" --> passes (as default flag value is set to false) Reviewers: Subscribers: Tasks: Tags:
1 parent 7097ee1 commit da132c3

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

examples/arm/aot_arm_compiler.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,12 @@ def get_args():
600600
action="store_false",
601601
help="Disable strict checking while exporting models.",
602602
)
603+
parser.add_argument(
604+
"--enable_qdq_fusion_pass",
605+
action="store",
606+
default=False,
607+
help="Skip the QuantizedOpFusionPass fusion step (default: False)",
608+
)
603609
args = parser.parse_args()
604610

605611
if args.evaluate and (
@@ -791,14 +797,20 @@ def to_edge_no_delegate(exported_program, args, model: torch.nn.Module, example_
791797
return model_int8, edge
792798

793799

794-
def transform_for_cortex_m_backend(edge):
800+
def transform_for_cortex_m_backend(edge, args):
795801
# Let's make sure we are using optimized Cortex M backend
796802
# NB: If we can't find and replace ops those are expected to be replaced,
797803
# bad things will happen at runtime, like "missing operator" errors!
798-
# Instantiate the pass
799-
replace_quant_pass = ReplaceQuantNodesPass()
800-
quantized_op_fusion_pass = QuantizedOpFusionPass()
801-
edge = edge.transform([replace_quant_pass, quantized_op_fusion_pass])
804+
805+
# Instantiate the mandatory ReplaceQuantNodesPass
806+
passes = [ReplaceQuantNodesPass()]
807+
808+
# Conditionally add the QuantizedOpFusionPass
809+
if args.enable_qdq_fusion_pass.lower() == "true":
810+
passes.append(QuantizedOpFusionPass())
811+
812+
# Apply the passes
813+
edge = edge.transform(passes)
802814

803815
return edge
804816

@@ -835,7 +847,7 @@ def transform_for_cortex_m_backend(edge):
835847
)
836848

837849
# Transform so we can use ops from the Cortex M backend
838-
edge = transform_for_cortex_m_backend(edge)
850+
edge = transform_for_cortex_m_backend(edge, args)
839851

840852
dump_delegation_info(edge, args.intermediates)
841853

examples/arm/run.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ethos_u_scratch_dir=${script_dir}/ethos-u-scratch
4040
scratch_dir_set=false
4141
toolchain=arm-none-eabi-gcc
4242
select_ops_list="aten::_softmax.out"
43+
qdq_fusion_op=false
4344

4445
function help() {
4546
echo "Usage: $(basename $0) [options]"
@@ -69,6 +70,7 @@ function help() {
6970
echo " --pte_placement=<elf|ADDR> Ethos-U: Control if runtime has PTE baked into the elf or if its placed in memory outside of the elf, defaults to ${pte_placement}"
7071
echo " --et_build_root=<FOLDER> Executorch build output root folder to use, defaults to ${et_build_root}"
7172
echo " --scratch-dir=<FOLDER> Path to your Ethos-U scrach dir if you not using default ${ethos_u_scratch_dir}"
73+
echo " --qdq_fusion_op=<true/false> Enable/Disable QDQ fusion op"
7274
exit 0
7375
}
7476

@@ -96,6 +98,7 @@ for arg in "$@"; do
9698
--pte_placement=*) pte_placement="${arg#*=}";;
9799
--et_build_root=*) et_build_root="${arg#*=}";;
98100
--scratch-dir=*) ethos_u_scratch_dir="${arg#*=}" ; scratch_dir_set=true ;;
101+
--qdq_fusion_op=*) qdq_fusion_op="${arg#*=}";;
99102
*)
100103
;;
101104
esac
@@ -275,7 +278,7 @@ for i in "${!test_model[@]}"; do
275278
model_compiler_flags="${model_compiler_flags} --model_input=${model_input}"
276279
fi
277280

278-
ARM_AOT_CMD="python3 -m examples.arm.aot_arm_compiler --model_name=${model} --target=${target} ${model_compiler_flags} --intermediate=${output_folder} --output=${pte_file} --system_config=${system_config} --memory_mode=${memory_mode} $bundleio_flag ${etrecord_flag} --config=${config}"
281+
ARM_AOT_CMD="python3 -m examples.arm.aot_arm_compiler --model_name=${model} --target=${target} ${model_compiler_flags} --intermediate=${output_folder} --output=${pte_file} --system_config=${system_config} --memory_mode=${memory_mode} $bundleio_flag ${etrecord_flag} --config=${config} --enable_qdq_fusion_pass=${qdq_fusion_op}"
279282
echo "CALL ${ARM_AOT_CMD}" >&2
280283
${ARM_AOT_CMD} 1>&2
281284

0 commit comments

Comments
 (0)