Skip to content

Commit eedbcc9

Browse files
Tests update. Autogen hwcomponents expected
1 parent a5a0c13 commit eedbcc9

2 files changed

Lines changed: 51 additions & 5 deletions

File tree

tests/hwcomponents_expected.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
}
248248
},
249249
"LocalBuffer": {
250-
"area": 5e-05,
250+
"area": 5.1e-05,
251251
"leak_power": 0.0,
252252
"actions": {
253253
"read": {
@@ -261,7 +261,7 @@
261261
}
262262
},
263263
"ScalarUnit": {
264-
"area": 1e-05,
264+
"area": 8.7e-06,
265265
"leak_power": 0.0,
266266
"actions": {
267267
"compute": {
@@ -271,7 +271,7 @@
271271
}
272272
},
273273
"Register": {
274-
"area": 1e-11,
274+
"area": 8.5e-11,
275275
"leak_power": 0.0,
276276
"actions": {
277277
"read": {
@@ -285,7 +285,7 @@
285285
}
286286
},
287287
"MAC": {
288-
"area": 9e-11,
288+
"area": 8.5e-10,
289289
"leak_power": 0.0,
290290
"actions": {
291291
"compute": {

tests/test_regression.py

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
Regression tests for the FFM mapper.
33
4-
python tests/test_regression.py # (re)generate reference json
4+
python tests/test_regression.py # (re)generate both reference jsons
55
pytest tests/test_regression.py -v # compare against reference
66
"""
77

@@ -311,5 +311,51 @@ def t(self):
311311
setattr(TestHWComponentsConsistency, _test_name, _make_test())
312312

313313

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+
314359
if __name__ == "__main__":
360+
generate_hwcomponents()
315361
generate(fusion_choices=(True, False))

0 commit comments

Comments
 (0)