viz: show contents of vconst (#16636)

* failing test

* render vconst

* simpler test

* reorder
This commit is contained in:
qazal 2026-06-17 01:31:03 +08:00 committed by GitHub
commit 1cb6b88d37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -258,6 +258,9 @@ class TestViz(unittest.TestCase):
const_reshaped = const_stack.reshape((1, 2))
const_graph = uop_to_json(VizData(), const_reshaped)
self.assertTrue(const_graph[id(const_stack)]["exclude"])
reshape_node = const_graph[id(const_reshaped)]
self.assertFalse(reshape_node["exclude"])
self.assertIn("STACK0 {1,2} Ops.CONST", reshape_node["label"].split("\n"))
# VIZ displays nested graph_rewrites in a tree view

View file

@ -138,7 +138,7 @@ def uop_to_json(data:VizData, x:UOp) -> dict[int, dict]:
# walk through excluded movement ops to find the underlying CONST
cx = x
while cx.op in GroupOp.Movement and len(cx.src) >= 1 and cx.src[0] in excluded: cx = cx.src[0]
arg = f"{cx.arg:g}" if cx.op is Ops.CONST and dtypes.is_float(cx.dtype) else f"{cx.arg}"
arg = f"{cx.arg:g}" if cx.op is Ops.CONST and dtypes.is_float(cx.dtype) else cx.render() if cx.op is Ops.STACK else f"{cx.arg}"
label += f"\n{cx.op.name}{idx} {arg}" + (f" {cx.src[0].op}" if len(cx.src) else "")
try:
if len(rngs:=u.ranges):