hotfix: viz recenter and unlimited zoom (#9760)

* hotfix: viz recenter and unlimited zoom

* add shapes to the ast graph

* not for COPY
This commit is contained in:
qazal
2025-04-07 14:38:03 +08:00
committed by GitHub
parent d0dace4306
commit 4cd27aa0e6
2 changed files with 3 additions and 1 deletions

View File

@@ -190,7 +190,7 @@ function renderMemoryGraph(graph) {
// ** zoom and recentering
const zoom = d3.zoom().scaleExtent([0.05, 2]).on("zoom", (e) => d3.select("#render").attr("transform", e.transform));
const zoom = d3.zoom().on("zoom", (e) => d3.select("#render").attr("transform", e.transform));
d3.select("#graph-svg").call(zoom);
// zoom to fit into view
document.getElementById("zoom-to-fit-btn").addEventListener("click", () => {
@@ -426,6 +426,7 @@ document.addEventListener("keydown", async function(event) {
return setState({ currentRewrite:Math.min(totalRewrites, currentRewrite+1) });
}
if (event.key == " ") {
event.preventDefault()
document.getElementById("zoom-to-fit-btn").click();
}
});

View File

@@ -71,6 +71,7 @@ def uop_to_json(x:UOp) -> dict[int, dict]:
if x in excluded:
if x.op is Ops.CONST and dtypes.is_float(u.dtype): label += f"\nCONST{idx} {x.arg:g}"
else: label += f"\n{x.op.name}{idx} {x.arg}"
if u.op not in {Ops.VIEW, Ops.BUFFER, Ops.KERNEL, Ops.ASSIGN, Ops.COPY, *GroupOp.Buffer} and u.st is not None: label += f"\n{repr(u.shape)}"
graph[id(u)] = {"label":label, "src":[id(x) for x in u.src if x not in excluded], "color":uops_colors.get(u.op, "#ffffff")}
return graph