From d79bf356c27ee659f8bca52aa026baa70e65e84d Mon Sep 17 00:00:00 2001 From: qazal <77887910+Qazalin@users.noreply.github.com> Date: Tue, 5 May 2026 17:34:44 +0300 Subject: [PATCH] viz: add CALL -> codegen link (#16044) * work * cleaner * details * rm --- tinygrad/viz/index.html | 13 +++++++++++++ tinygrad/viz/js/index.js | 11 +++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tinygrad/viz/index.html b/tinygrad/viz/index.html index 2d8503b121..35804472bc 100644 --- a/tinygrad/viz/index.html +++ b/tinygrad/viz/index.html @@ -122,6 +122,19 @@ font-size: 6px; fill: #08090e; } + g.tag.ref * { + cursor: pointer; + } + g.tag.ref circle { + fill: #9FDDE6; + stroke: #4a4b57; + } + g.tag.ref path { + fill: none; + stroke: #08090e; + stroke-width: 0.7; + stroke-linejoin: miter; + } .label :is(text, p) { font-weight: 350; } diff --git a/tinygrad/viz/js/index.js b/tinygrad/viz/js/index.js index 9465341d37..5df0f87d52 100644 --- a/tinygrad/viz/js/index.js +++ b/tinygrad/viz/js/index.js @@ -56,9 +56,10 @@ function intersectRect(r1, r2) { return {x:r1.x+dx*scale, y:r1.y+dy*scale}; } -function addTags(root) { +function addTags(root, path) { root.selectAll("circle").data(d => [d]).join("circle").attr("r", 5); - root.selectAll("text").data(d => [d]).join("text").text(d => d).attr("dy", "0.35em"); + if (path != null) root.selectAll("path").data(d => [d]).join("path").attr("d", path); + else root.selectAll("text").data(d => [d]).join("text").text(d => d).attr("dy", "0.35em"); } const drawGraph = (data) => { @@ -116,9 +117,11 @@ const drawGraph = (data) => { }); addTags(nodes.selectAll("g.tag").data(d => d.tag != null ? [d] : []).join("g").attr("class", "tag") .attr("transform", d => `translate(${-d.width/2+8}, ${-d.height/2+8})`).datum(e => e.tag)); - addTags(nodes.selectAll("g.type").data(d => d.callNode ? [d] : []).join("g") - .attr("class", d => `tag ${d.collapsed ? 'collapsed' : 'expanded'}`) + addTags(nodes.selectAll("g.type").data(d => d.callNode ? [d] : []).join("g").attr("class", d => `tag ${d.collapsed ? 'collapsed' : 'expanded'}`) .attr("transform", d => `translate(${-d.width/2}, ${0})`).datum(d => d.collapsed ? "+" : "−")); + addTags(nodes.selectAll("g.ref").data(d => d.ref != null ? [d] : []).join("g").attr("class", "tag ref") + .attr("transform", d => `translate(${d.width/2-2}, ${-d.height/2+2})`).on("click", (e,d) => { e.stopPropagation(); switchCtx(d.ref); }), + "M-1.7 1.7 L1.7 -1.7 M-0.55 -1.7 H1.7 V0.55"); // draw edges const line = d3.line().x(d => d.x).y(d => d.y).curve(d3.curveBasis), edges = g.edges(); d3.select("#edges").selectAll("path.edgePath").data(edges).join("path").attr("class", "edgePath").attr("d", (e) => {