| 
11 | 11 | from datetime import datetime  | 
12 | 12 | 
 
  | 
13 | 13 | from pathlib import Path  | 
14 |  | -from typing import Any  | 
 | 14 | +from typing import Any, Optional  | 
15 | 15 | 
 
  | 
16 | 16 | import pytest  | 
17 | 17 | from executorch.backends.arm.arm_backend import ArmCompileSpecBuilder  | 
@@ -92,63 +92,96 @@ def get_tosa_compile_spec_unbuilt(  | 
92 | 92 | 
 
  | 
93 | 93 | 
 
  | 
94 | 94 | 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,  | 
96 | 100 | ) -> list[CompileSpec]:  | 
97 | 101 |     """  | 
98 |  | -    Default compile spec for Ethos-U55 tests.  | 
 | 102 | +    Compile spec for Ethos-U55.  | 
99 | 103 |     """  | 
100 | 104 |     return get_u55_compile_spec_unbuilt(  | 
 | 105 | +        macs=macs,  | 
 | 106 | +        system_config=system_config,  | 
 | 107 | +        memory_mode=memory_mode,  | 
 | 108 | +        extra_flags=extra_flags,  | 
101 | 109 |         custom_path=custom_path,  | 
102 | 110 |     ).build()  | 
103 | 111 | 
 
  | 
104 | 112 | 
 
  | 
105 | 113 | 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",  | 
106 | 118 |     custom_path=None,  | 
107 | 119 | ) -> list[CompileSpec]:  | 
108 | 120 |     """  | 
109 |  | -    Default compile spec for Ethos-U85 tests.  | 
 | 121 | +    Compile spec for Ethos-U85.  | 
110 | 122 |     """  | 
111 | 123 |     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,  | 
112 | 128 |         custom_path=custom_path,  | 
113 | 129 |     ).build()  | 
114 | 130 | 
 
  | 
115 | 131 | 
 
  | 
116 | 132 | 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],  | 
118 | 138 | ) -> ArmCompileSpecBuilder:  | 
119 | 139 |     """Get the ArmCompileSpecBuilder for the Ethos-U55 tests, to modify  | 
120 | 140 |     the compile spec before calling .build() to finalize it.  | 
121 | 141 |     """  | 
122 | 142 |     artifact_path = custom_path or tempfile.mkdtemp(prefix="arm_u55_")  | 
123 | 143 |     if not os.path.exists(artifact_path):  | 
124 | 144 |         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 | + | 
125 | 149 |     compile_spec = (  | 
126 | 150 |         ArmCompileSpecBuilder()  | 
127 | 151 |         .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,  | 
132 | 156 |         )  | 
133 | 157 |         .dump_intermediate_artifacts_to(artifact_path)  | 
134 | 158 |     )  | 
135 | 159 |     return compile_spec  | 
136 | 160 | 
 
  | 
137 | 161 | 
 
  | 
138 | 162 | 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],  | 
140 | 168 | ) -> list[CompileSpec]:  | 
141 | 169 |     """Get the ArmCompileSpecBuilder for the Ethos-U85 tests, to modify  | 
142 | 170 |     the compile spec before calling .build() to finalize it.  | 
143 | 171 |     """  | 
144 | 172 |     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 | + | 
145 | 178 |     compile_spec = (  | 
146 | 179 |         ArmCompileSpecBuilder()  | 
147 | 180 |         .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,  | 
152 | 185 |         )  | 
153 | 186 |         .dump_intermediate_artifacts_to(artifact_path)  | 
154 | 187 |     )  | 
 | 
0 commit comments