Skip to content

Commit 3b0f7c8

Browse files
authored
Arm backend: Add support for custom vela.ini (#11958)
The vela compiler supports the option to specify a custom vela.ini file. But none of the scripts in the arm backend handles this option and forwards it to vela. Previous to this commit this was always hardcoded to "Arm/vela.ini" Now this can be specified with --config that is being forwarded to vela for the following scripts: * examples/arm/run.sh * examples/arm/aot_arm_compiler.py While keeping the default of "Arm/vela.ini" in test/common to not break CI. Signed-off-by: [email protected]
1 parent 3666680 commit 3b0f7c8

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

backends/arm/test/common.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def get_u55_compile_spec(
9595
memory_mode: str = "Shared_Sram",
9696
extra_flags: str = "--debug-force-regor --output-format=raw",
9797
custom_path: Optional[str] = None,
98+
config: Optional[str] = "Arm/vela.ini",
9899
) -> list[CompileSpec]:
99100
"""
100101
Compile spec for Ethos-U55.
@@ -105,6 +106,7 @@ def get_u55_compile_spec(
105106
memory_mode=memory_mode,
106107
extra_flags=extra_flags,
107108
custom_path=custom_path,
109+
config=config,
108110
).build()
109111

110112

@@ -114,6 +116,7 @@ def get_u85_compile_spec(
114116
memory_mode="Shared_Sram",
115117
extra_flags="--output-format=raw",
116118
custom_path=None,
119+
config: Optional[str] = "Arm/vela.ini",
117120
) -> list[CompileSpec]:
118121
"""
119122
Compile spec for Ethos-U85.
@@ -124,6 +127,7 @@ def get_u85_compile_spec(
124127
memory_mode=memory_mode,
125128
extra_flags=extra_flags,
126129
custom_path=custom_path,
130+
config=config,
127131
).build()
128132

129133

@@ -133,6 +137,7 @@ def get_u55_compile_spec_unbuilt(
133137
memory_mode: str,
134138
extra_flags: str,
135139
custom_path: Optional[str],
140+
config: Optional[str],
136141
) -> ArmCompileSpecBuilder:
137142
"""Get the ArmCompileSpecBuilder for the Ethos-U55 tests, to modify
138143
the compile spec before calling .build() to finalize it.
@@ -151,6 +156,7 @@ def get_u55_compile_spec_unbuilt(
151156
system_config=system_config,
152157
memory_mode=memory_mode,
153158
extra_flags=extra_flags,
159+
config_ini=config,
154160
)
155161
.dump_intermediate_artifacts_to(artifact_path)
156162
)
@@ -163,6 +169,7 @@ def get_u85_compile_spec_unbuilt(
163169
memory_mode: str,
164170
extra_flags: str,
165171
custom_path: Optional[str],
172+
config: Optional[str],
166173
) -> list[CompileSpec]:
167174
"""Get the ArmCompileSpecBuilder for the Ethos-U85 tests, to modify
168175
the compile spec before calling .build() to finalize it.
@@ -180,6 +187,7 @@ def get_u85_compile_spec_unbuilt(
180187
system_config=system_config,
181188
memory_mode=memory_mode,
182189
extra_flags=extra_flags,
190+
config_ini=config,
183191
)
184192
.dump_intermediate_artifacts_to(artifact_path)
185193
)

examples/arm/aot_arm_compiler.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ def get_compile_spec(
386386
system_config: Optional[str] = None,
387387
memory_mode: Optional[str] = None,
388388
quantize: bool = False,
389+
config: Optional[str] = None,
389390
) -> list[CompileSpec]:
390391
spec_builder = None
391392
if target.startswith("TOSA"):
@@ -400,6 +401,7 @@ def get_compile_spec(
400401
system_config=system_config,
401402
memory_mode=memory_mode,
402403
extra_flags="--verbose-operators --verbose-cycle-estimate",
404+
config_ini=config,
403405
)
404406
elif "vgf" in target:
405407
if quantize:
@@ -573,6 +575,12 @@ def get_args():
573575
default=None,
574576
help="Memory mode to select from the Vela configuration file (see vela.ini). Default is 'Shared_Sram' for Ethos-U55 targets and 'Sram_Only' for Ethos-U85 targets",
575577
)
578+
parser.add_argument(
579+
"--config",
580+
required=False,
581+
default="Arm/vela.ini",
582+
help="Specify custom vela configuration file (vela.ini)",
583+
)
576584
args = parser.parse_args()
577585

578586
if args.evaluate and (
@@ -706,6 +714,7 @@ def to_edge_TOSA_delegate(
706714
args.system_config,
707715
args.memory_mode,
708716
args.quantize,
717+
args.config,
709718
)
710719

711720
model_int8 = None
@@ -746,6 +755,7 @@ def to_edge_no_delegate(exported_program, args, model: torch.nn.Module, example_
746755
args.system_config,
747756
args.memory_mode,
748757
args.quantize,
758+
args.config,
749759
)
750760
model, exported_program = quantize_model(
751761
args, model, example_inputs, compile_spec

examples/arm/run.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ build_type="Release"
3333
extra_build_flags=""
3434
build_only=false
3535
system_config=""
36+
config=""
3637
memory_mode=""
3738
et_build_root="${et_root_dir}/arm_test"
3839
ethos_u_scratch_dir=${script_dir}/ethos-u-scratch
@@ -57,6 +58,7 @@ function help() {
5758
echo " --build_only Only build, don't run FVP"
5859
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."
5960
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."
61+
echo " --config=<FILEPATH> System configuration file that specifies system configurations (vela.ini)"
6062
echo " --memory_mode=<MODE> Memory mode to select from the Vela configuration file (see vela.ini), e.g. Shared_Sram/Sram_Only. Default: 'Shared_Sram' for Ethos-U55 targets, 'Sram_Only' for Ethos-U85 targets"
6163
echo " --et_build_root=<FOLDER> Executorch build output root folder to use, defaults to ${et_build_root}"
6264
echo " --scratch-dir=<FOLDER> Path to your Ethos-U scrach dir if you not using default ${ethos_u_scratch_dir}"
@@ -80,6 +82,7 @@ for arg in "$@"; do
8082
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
8183
--build_only) build_only=true ;;
8284
--system_config=*) system_config="${arg#*=}";;
85+
--config=*) config="${arg#*=}";;
8386
--memory_mode=*) memory_mode="${arg#*=}";;
8487
--et_build_root=*) et_build_root="${arg#*=}";;
8588
--scratch-dir=*) ethos_u_scratch_dir="${arg#*=}" ; scratch_dir_set=true ;;
@@ -114,6 +117,11 @@ then
114117
fi
115118
fi
116119

120+
if [[ ${config} == "" ]]
121+
then
122+
config="Arm/vela.ini"
123+
fi
124+
117125
function check_setup () {
118126
# basic checks that setup.sh did everything needed before we get started
119127

@@ -242,7 +250,7 @@ for i in "${!test_model[@]}"; do
242250
model_compiler_flags="${model_compiler_flags} --model_input=${model_input}"
243251
fi
244252

245-
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"
253+
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 --config=${config}"
246254
echo "CALL ${ARM_AOT_CMD}" >&2
247255
${ARM_AOT_CMD} 1>&2
248256

0 commit comments

Comments
 (0)