Spaces:
Running
Running
Edward J. Schwartz commited on
Commit ·
dd17a03
1
Parent(s): bd11be5
Size CFGs naturally, capped at 600px (vh feeds back through HF's auto-resizing iframe)
Browse files
app.py
CHANGED
|
@@ -28,8 +28,11 @@ GRAPHVIZ_HEAD = "".join(f'<script src="https://cdn.jsdelivr.net/npm/{lib}"></scr
|
|
| 28 |
"d3@7.9.0/dist/d3.min.js", "@hpcc-js/wasm@2.20.0/dist/graphviz.umd.js", "d3-graphviz@5.6.0/build/d3-graphviz.min.js"))
|
| 29 |
GRAPHVIZ_JS = """
|
| 30 |
const graph = element.querySelector('.graph');
|
| 31 |
-
d3.select(graph).graphviz({useWorker: false, zoom: true,
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
"""
|
| 34 |
EXAMPLES = sorted(str(p) for p in Path(__file__).with_name("examples").glob("*.cubin"))
|
| 35 |
|
|
@@ -83,7 +86,7 @@ with gr.Blocks(title="cuobjdump / nvdisasm") as demo:
|
|
| 83 |
if output.startswith("digraph"):
|
| 84 |
gr.Markdown(f"`{label}` (scroll to zoom, drag to pan)")
|
| 85 |
gr.HTML(output.replace("\t", " "), head=GRAPHVIZ_HEAD, js_on_load=GRAPHVIZ_JS,
|
| 86 |
-
html_template='<div class="graph" style="
|
| 87 |
'border:1px solid var(--border-color-primary)"></div>')
|
| 88 |
with gr.Accordion(f"{label} (DOT source)", open=False):
|
| 89 |
gr.Code(output, max_lines=60)
|
|
|
|
| 28 |
"d3@7.9.0/dist/d3.min.js", "@hpcc-js/wasm@2.20.0/dist/graphviz.umd.js", "d3-graphviz@5.6.0/build/d3-graphviz.min.js"))
|
| 29 |
GRAPHVIZ_JS = """
|
| 30 |
const graph = element.querySelector('.graph');
|
| 31 |
+
d3.select(graph).graphviz({useWorker: false, zoom: true}).renderDot(props.value, () => {
|
| 32 |
+
const svg = graph.querySelector('svg');
|
| 33 |
+
svg.setAttribute('width', '100%');
|
| 34 |
+
svg.setAttribute('height', Math.min(svg.viewBox.baseVal.height * 4 / 3, 600));
|
| 35 |
+
});
|
| 36 |
"""
|
| 37 |
EXAMPLES = sorted(str(p) for p in Path(__file__).with_name("examples").glob("*.cubin"))
|
| 38 |
|
|
|
|
| 86 |
if output.startswith("digraph"):
|
| 87 |
gr.Markdown(f"`{label}` (scroll to zoom, drag to pan)")
|
| 88 |
gr.HTML(output.replace("\t", " "), head=GRAPHVIZ_HEAD, js_on_load=GRAPHVIZ_JS,
|
| 89 |
+
html_template='<div class="graph" style="background:white;'
|
| 90 |
'border:1px solid var(--border-color-primary)"></div>')
|
| 91 |
with gr.Accordion(f"{label} (DOT source)", open=False):
|
| 92 |
gr.Code(output, max_lines=60)
|