Skip to content

Commit f22acdd

Browse files
committed
[ExecuTorch] Arm Ethos:Make get_compile_spec() configurable
Allow users to generate different compile specs based on the Args. Preserve the behavior. No change in the default spec returned. Differential Revision: [D70351486](https://our.internmc.facebook.com/intern/diff/D70351486/) ghstack-source-id: 269412249 Pull Request resolved: #8899
1 parent c7a20e2 commit f22acdd

File tree

1 file changed

+47
-14
lines changed

1 file changed

+47
-14
lines changed

backends/arm/test/common.py

+47-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from datetime import datetime
1212

1313
from pathlib import Path
14-
from typing import Any
14+
from typing import Any, Optional
1515

1616
import pytest
1717
from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder
@@ -92,63 +92,96 @@ def get_tosa_compile_spec_unbuilt(
9292

9393

9494
def get_u55_compile_spec(
95-
custom_path=None,
95+
macs: int = 128,
96+
system_config: str = "Ethos_U55_High_End_Embedded",
97+
memory_mode: str = "Shared_Sram",
98+
extra_flags: str = "--debug-force-regor --output-format=raw",
99+
custom_path: Optional[str] = None,
96100
) -> list[CompileSpec]:
97101
"""
98-
Default compile spec for Ethos-U55 tests.
102+
Compile spec for Ethos-U55.
99103
"""
100104
return get_u55_compile_spec_unbuilt(
105+
macs=macs,
106+
system_config=system_config,
107+
memory_mode=memory_mode,
108+
extra_flags=extra_flags,
101109
custom_path=custom_path,
102110
).build()
103111

104112

105113
def get_u85_compile_spec(
114+
macs: int = 128,
115+
system_config="Ethos_U85_SYS_DRAM_Mid",
116+
memory_mode="Shared_Sram",
117+
extra_flags="--output-format=raw",
106118
custom_path=None,
107119
) -> list[CompileSpec]:
108120
"""
109-
Default compile spec for Ethos-U85 tests.
121+
Compile spec for Ethos-U85.
110122
"""
111123
return get_u85_compile_spec_unbuilt( # type: ignore[attr-defined]
124+
macs=macs,
125+
system_config=system_config,
126+
memory_mode=memory_mode,
127+
extra_flags=extra_flags,
112128
custom_path=custom_path,
113129
).build()
114130

115131

116132
def get_u55_compile_spec_unbuilt(
117-
custom_path=None,
133+
macs: int,
134+
system_config: str,
135+
memory_mode: str,
136+
extra_flags: str,
137+
custom_path: Optional[str],
118138
) -> ArmCompileSpecBuilder:
119139
"""Get the ArmCompileSpecBuilder for the Ethos-U55 tests, to modify
120140
the compile spec before calling .build() to finalize it.
121141
"""
122142
artifact_path = custom_path or tempfile.mkdtemp(prefix="arm_u55_")
123143
if not os.path.exists(artifact_path):
124144
os.makedirs(artifact_path, exist_ok=True)
145+
146+
# https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/blob/main/OPTIONS.md
147+
assert macs in [32, 64, 128, 256], "Unsupported MACs value"
148+
125149
compile_spec = (
126150
ArmCompileSpecBuilder()
127151
.ethosu_compile_spec(
128-
"ethos-u55-128",
129-
system_config="Ethos_U55_High_End_Embedded",
130-
memory_mode="Shared_Sram",
131-
extra_flags="--debug-force-regor --output-format=raw",
152+
f"ethos-u55-{macs}",
153+
system_config=system_config,
154+
memory_mode=memory_mode,
155+
extra_flags=extra_flags,
132156
)
133157
.dump_intermediate_artifacts_to(artifact_path)
134158
)
135159
return compile_spec
136160

137161

138162
def get_u85_compile_spec_unbuilt(
139-
custom_path=None,
163+
macs: int,
164+
system_config: str,
165+
memory_mode: str,
166+
extra_flags: str,
167+
custom_path: Optional[str],
140168
) -> list[CompileSpec]:
141169
"""Get the ArmCompileSpecBuilder for the Ethos-U85 tests, to modify
142170
the compile spec before calling .build() to finalize it.
143171
"""
144172
artifact_path = custom_path or tempfile.mkdtemp(prefix="arm_u85_")
173+
if not os.path.exists(artifact_path):
174+
os.makedirs(artifact_path, exist_ok=True)
175+
176+
assert macs in [128, 256, 512, 1024, 2048], "Unsupported MACs value"
177+
145178
compile_spec = (
146179
ArmCompileSpecBuilder()
147180
.ethosu_compile_spec(
148-
"ethos-u85-128",
149-
system_config="Ethos_U85_SYS_DRAM_Mid",
150-
memory_mode="Shared_Sram",
151-
extra_flags="--output-format=raw",
181+
f"ethos-u85-{macs}",
182+
system_config=system_config,
183+
memory_mode=memory_mode,
184+
extra_flags=extra_flags,
152185
)
153186
.dump_intermediate_artifacts_to(artifact_path)
154187
)

0 commit comments

Comments
 (0)