|
1 | 1 | """ |
2 | 2 | Regression tests for the FFM mapper. |
3 | 3 |
|
4 | | - python tests/test_regression.py # (re)generate reference json |
| 4 | + python tests/test_regression.py # (re)generate both reference jsons |
5 | 5 | pytest tests/test_regression.py -v # compare against reference |
6 | 6 | """ |
7 | 7 |
|
@@ -311,5 +311,51 @@ def t(self): |
311 | 311 | setattr(TestHWComponentsConsistency, _test_name, _make_test()) |
312 | 312 |
|
313 | 313 |
|
| 314 | +def generate_hwcomponents(): |
| 315 | + arches = { |
| 316 | + "eyeriss": af.examples.arches.eyeriss, |
| 317 | + "simba": af.examples.arches.simba, |
| 318 | + "simple": af.examples.arches.simple, |
| 319 | + "tpu_v4i": af.examples.arches.tpu_v4i, |
| 320 | + } |
| 321 | + results = {} |
| 322 | + for name, arch_path in arches.items(): |
| 323 | + spec = Spec.from_yaml( |
| 324 | + arch_path, |
| 325 | + af.examples.workloads.matmuls, |
| 326 | + jinja_parse_data={"N_EINSUMS": 2, "M": 64, "KN": 64}, |
| 327 | + ) |
| 328 | + spec = spec.calculate_component_area_energy_latency_leak( |
| 329 | + einsum_name="Matmul0" |
| 330 | + ) |
| 331 | + components = {} |
| 332 | + for node in spec.arch.nodes: |
| 333 | + if not isinstance(node, (af.arch.Memory, af.arch.Compute)): |
| 334 | + continue |
| 335 | + comp = {} |
| 336 | + if node.area is not None: |
| 337 | + comp["area"] = float(node.area) |
| 338 | + if node.leak_power is not None: |
| 339 | + comp["leak_power"] = float(node.leak_power) |
| 340 | + actions = {} |
| 341 | + for a in node.actions: |
| 342 | + act = {} |
| 343 | + if a.energy is not None: |
| 344 | + act["energy"] = float(a.energy) |
| 345 | + if a.latency is not None: |
| 346 | + act["latency"] = float(a.latency) |
| 347 | + if act: |
| 348 | + actions[a.name] = act |
| 349 | + if actions: |
| 350 | + comp["actions"] = actions |
| 351 | + if comp: |
| 352 | + components[node.name] = comp |
| 353 | + results[name] = components |
| 354 | + with open(HWCOMPONENTS_JSON_PATH, "w") as f: |
| 355 | + json.dump(results, f, indent=2) |
| 356 | + print(f"Wrote {len(results)} arch results to {HWCOMPONENTS_JSON_PATH}") |
| 357 | + |
| 358 | + |
314 | 359 | if __name__ == "__main__": |
| 360 | + generate_hwcomponents() |
315 | 361 | generate(fusion_choices=(True, False)) |
0 commit comments