|
10 | 10 | from datetime import datetime
|
11 | 11 |
|
12 | 12 | from pathlib import Path
|
13 |
| -from typing import Any |
| 13 | +from typing import Any, Optional |
14 | 14 |
|
15 | 15 | import pytest
|
16 | 16 | from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder
|
@@ -91,63 +91,96 @@ def get_tosa_compile_spec_unbuilt(
|
91 | 91 |
|
92 | 92 |
|
93 | 93 | def get_u55_compile_spec(
|
94 |
| - custom_path=None, |
| 94 | + macs: int = 128, |
| 95 | + system_config: str = "Ethos_U55_High_End_Embedded", |
| 96 | + memory_mode: str = "Shared_Sram", |
| 97 | + extra_flags: str = "--debug-force-regor --output-format=raw", |
| 98 | + custom_path: Optional[str] = None, |
95 | 99 | ) -> list[CompileSpec]:
|
96 | 100 | """
|
97 |
| - Default compile spec for Ethos-U55 tests. |
| 101 | + Compile spec for Ethos-U55. |
98 | 102 | """
|
99 | 103 | return get_u55_compile_spec_unbuilt(
|
| 104 | + macs=macs, |
| 105 | + system_config=system_config, |
| 106 | + memory_mode=memory_mode, |
| 107 | + extra_flags=extra_flags, |
100 | 108 | custom_path=custom_path,
|
101 | 109 | ).build()
|
102 | 110 |
|
103 | 111 |
|
104 | 112 | def get_u85_compile_spec(
|
| 113 | + macs: int = 128, |
| 114 | + system_config="Ethos_U85_SYS_DRAM_Mid", |
| 115 | + memory_mode="Shared_Sram", |
| 116 | + extra_flags="--output-format=raw", |
105 | 117 | custom_path=None,
|
106 | 118 | ) -> list[CompileSpec]:
|
107 | 119 | """
|
108 |
| - Default compile spec for Ethos-U85 tests. |
| 120 | + Compile spec for Ethos-U85. |
109 | 121 | """
|
110 | 122 | return get_u85_compile_spec_unbuilt( # type: ignore[attr-defined]
|
| 123 | + macs=macs, |
| 124 | + system_config=system_config, |
| 125 | + memory_mode=memory_mode, |
| 126 | + extra_flags=extra_flags, |
111 | 127 | custom_path=custom_path,
|
112 | 128 | ).build()
|
113 | 129 |
|
114 | 130 |
|
115 | 131 | def get_u55_compile_spec_unbuilt(
|
116 |
| - custom_path=None, |
| 132 | + macs: int, |
| 133 | + system_config: str, |
| 134 | + memory_mode: str, |
| 135 | + extra_flags: str, |
| 136 | + custom_path: Optional[str], |
117 | 137 | ) -> ArmCompileSpecBuilder:
|
118 | 138 | """Get the ArmCompileSpecBuilder for the Ethos-U55 tests, to modify
|
119 | 139 | the compile spec before calling .build() to finalize it.
|
120 | 140 | """
|
121 | 141 | artifact_path = custom_path or tempfile.mkdtemp(prefix="arm_u55_")
|
122 | 142 | if not os.path.exists(artifact_path):
|
123 | 143 | os.makedirs(artifact_path, exist_ok=True)
|
| 144 | + |
| 145 | + # https://gitlab.arm.com/artificial-intelligence/ethos-u/ethos-u-vela/-/blob/main/OPTIONS.md |
| 146 | + assert macs in [32, 64, 128, 256], "Unsupported MACs value" |
| 147 | + |
124 | 148 | compile_spec = (
|
125 | 149 | ArmCompileSpecBuilder()
|
126 | 150 | .ethosu_compile_spec(
|
127 |
| - "ethos-u55-128", |
128 |
| - system_config="Ethos_U55_High_End_Embedded", |
129 |
| - memory_mode="Shared_Sram", |
130 |
| - extra_flags="--debug-force-regor --output-format=raw", |
| 151 | + f"ethos-u55-{macs}", |
| 152 | + system_config=system_config, |
| 153 | + memory_mode=memory_mode, |
| 154 | + extra_flags=extra_flags, |
131 | 155 | )
|
132 | 156 | .dump_intermediate_artifacts_to(artifact_path)
|
133 | 157 | )
|
134 | 158 | return compile_spec
|
135 | 159 |
|
136 | 160 |
|
137 | 161 | def get_u85_compile_spec_unbuilt(
|
138 |
| - custom_path=None, |
| 162 | + macs: int, |
| 163 | + system_config: str, |
| 164 | + memory_mode: str, |
| 165 | + extra_flags: str, |
| 166 | + custom_path: Optional[str], |
139 | 167 | ) -> list[CompileSpec]:
|
140 | 168 | """Get the ArmCompileSpecBuilder for the Ethos-U85 tests, to modify
|
141 | 169 | the compile spec before calling .build() to finalize it.
|
142 | 170 | """
|
143 | 171 | artifact_path = custom_path or tempfile.mkdtemp(prefix="arm_u85_")
|
| 172 | + if not os.path.exists(artifact_path): |
| 173 | + os.makedirs(artifact_path, exist_ok=True) |
| 174 | + |
| 175 | + assert macs in [128, 256, 512, 1024, 2048], "Unsupported MACs value" |
| 176 | + |
144 | 177 | compile_spec = (
|
145 | 178 | ArmCompileSpecBuilder()
|
146 | 179 | .ethosu_compile_spec(
|
147 |
| - "ethos-u85-128", |
148 |
| - system_config="Ethos_U85_SYS_DRAM_Mid", |
149 |
| - memory_mode="Shared_Sram", |
150 |
| - extra_flags="--output-format=raw", |
| 180 | + f"ethos-u85-{macs}", |
| 181 | + system_config=system_config, |
| 182 | + memory_mode=memory_mode, |
| 183 | + extra_flags=extra_flags, |
151 | 184 | )
|
152 | 185 | .dump_intermediate_artifacts_to(artifact_path)
|
153 | 186 | )
|
|
0 commit comments