Skip to content

Commit be4d81b

Browse files
Workload viz improvements
1 parent 8eaea9d commit be4d81b

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

accelforge/frontend/workload.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,14 @@ def _to_formatted_string(self) -> str:
135135
if isinstance(self.projection, ImpliedProjection):
136136
return f"{self.name}<sub>{subscript}</sub>"
137137

138-
string = [self.name]
138+
string = []
139139
for k, v in self.projection.items():
140-
if len(string) < len(self.projection):
141-
string.append(f"<sup>{k},</sup><sub>{v},</sub>")
140+
if v == k.lower():
141+
string.append(v)
142142
else:
143-
string.append(f"<sup>{k}</sup><sub>{v}</sub>")
143+
string.append(f"{k}:{v}")
144+
return f"{self.name}<sub>{','.join(string)}</sub>"
145+
144146
return "".join(string)
145147

146148
@property
@@ -533,7 +535,7 @@ def _to_formatted_string(self, compress: bool = False) -> str:
533535
A string representation of this Einsum for use in a Pydot graph.
534536
"""
535537
lhs_join = ",\n" if compress else " , "
536-
rhs_join = " \n " if compress else " "
538+
rhs_join = " \n " if compress else " × "
537539
lhs = lhs_join.join(
538540
[t._to_formatted_string() for t in self.tensor_accesses if t.output]
539541
)
@@ -974,14 +976,19 @@ def render(self) -> str:
974976
"""Renders the workload as a Pydot graph. Returns an SVG string."""
975977
graph = _pydot_graph()
976978

979+
# Set ranksep to 0.3
980+
graph.set_ranksep(0.2)
981+
977982
# Add all tensors as nodes (circles)
978983
tensors = []
979984
seen_tensor_names = set()
980985
for einsum in self.einsums:
981986
node = pydot.Node(
982987
f"Einsum_{einsum.name}",
983988
shape="box",
984-
label=f"<{einsum._to_formatted_string(compress=True)}>",
989+
label=f"<{einsum._to_formatted_string(compress=False)}>",
990+
style="filled",
991+
fillcolor="#E0EEFF", # Same color as Compute nodes
985992
)
986993
graph.add_node(node)
987994
for tensor_access in einsum.tensor_accesses:
@@ -992,6 +999,8 @@ def render(self) -> str:
992999
f"Tensor_{tensor_access.name}",
9931000
shape="oval",
9941001
label=f"<{tensor_access._to_formatted_string()}>",
1002+
style="filled",
1003+
fillcolor="#D7FCD7", # Same color as Storage nodes
9951004
)
9961005
graph.add_node(node)
9971006

@@ -1002,13 +1011,17 @@ def render(self) -> str:
10021011
if tensor_access.output:
10031012
# Output tensor: einsum -> tensor
10041013
edge = pydot.Edge(
1005-
f"Einsum_{einsum.name}", f"Tensor_{tensor_access.name}"
1014+
f"Einsum_{einsum.name}",
1015+
f"Tensor_{tensor_access.name}",
1016+
dir="forward",
10061017
)
10071018
graph.add_edge(edge)
10081019
else:
10091020
# Input tensor: tensor -> einsum
10101021
edge = pydot.Edge(
1011-
f"Tensor_{tensor_access.name}", f"Einsum_{einsum.name}"
1022+
f"Tensor_{tensor_access.name}",
1023+
f"Einsum_{einsum.name}",
1024+
dir="forward",
10121025
)
10131026
graph.add_edge(edge)
10141027
return _SVGJupyterRender(graph.create_svg(prog="dot").decode("utf-8"))

0 commit comments

Comments
 (0)