diff --git a/tinygrad/viz/index.html b/tinygrad/viz/index.html index 82699c9041..779638d3e9 100644 --- a/tinygrad/viz/index.html +++ b/tinygrad/viz/index.html @@ -349,36 +349,34 @@ }); // ***** UOp graph if (currentKernel == -1) return; + const cacheKey = `${currentKernel}-${currentUOp}`; + if (cacheKey in cache) { + ret = cache[cacheKey]; + } else { - const cacheKey = `${currentKernel}-${currentUOp}`; - if (cacheKey in cache) { - ret = cache[cacheKey]; + const p = document.querySelector(".progress"); + p.style.display = "none"; + const limit = 100; + const pageCount = Math.ceil((kernels[currentKernel][1][currentUOp].match_count+1)/limit); + if (pageCount > 1) { + p.style.display = "flex"; + d3.select("#graph-svg g").selectAll("*").remove(); } - else { - const p = document.querySelector(".progress"); - p.style.display = "none"; - const limit = 100; - const pageCount = Math.ceil((kernels[currentKernel][1][currentUOp].match_count+1)/limit); - if (pageCount > 1) { - p.style.display = "flex"; - d3.select("#graph-svg g").selectAll("*").remove(); - } - for (let i=0; i < pageCount; i++) { - p.innerText = `fetching data ${i+1}/${pageCount}`; - const chunk = await (await fetch(`/kernels?kernel=${currentKernel}&idx=${currentUOp}&offset=${i*limit}&limit=${limit}`)).json(); - if (i === 0) ret = chunk - else { - // TODO: this shouldn't exist after the viz api refactor - for (const [k,v] of Object.entries(chunk)) { - if (Array.isArray(v) && k !== "loc") ret[k].push(...v); - } + for (let i=0; i < pageCount; i++) { + p.innerText = `fetching data ${i+1}/${pageCount}`; + const chunk = await (await fetch(`/kernels?kernel=${currentKernel}&idx=${currentUOp}&offset=${i*limit}&limit=${limit}`)).json(); + if (i === 0) ret = chunk + else { + // TODO: this shouldn't exist after the viz api refactor + for (const [k,v] of Object.entries(chunk)) { + if (Array.isArray(v) && k !== "loc") ret[k].push(...v); } } - p.style.display = "none"; - cache[cacheKey] = ret; } - renderGraph(ret.graphs[currentRewrite], ret.changed_nodes[currentRewrite]); + p.style.display = "none"; + cache[cacheKey] = ret; } + renderGraph(ret.graphs[currentRewrite], ret.changed_nodes[currentRewrite]); // ***** RHS metadata const metadata = document.querySelector(".container.metadata"); metadata.innerHTML = "";