提交 d5c089f5 authored 作者: Christof Angermueller's avatar Christof Angermueller

Fix lost edge highlight feature

上级 39adc822
...@@ -301,10 +301,7 @@ function setupGraph() { ...@@ -301,10 +301,7 @@ function setupGraph() {
}); });
nodes.on('mouseover', function(node) { nodes.on('mouseover', function(node) {
if (!isProfiled || isEditNode || typeof(node.value.profile) == 'undefined') { // Highlight incoming edges
return;
}
edges.each(function (d, i) { edges.each(function (d, i) {
var edge = d3.select(this); var edge = d3.select(this);
if (d.source == node || d.target == node) { if (d.source == node || d.target == node) {
...@@ -313,13 +310,17 @@ function setupGraph() { ...@@ -313,13 +310,17 @@ function setupGraph() {
.style('opacity', 1.0); .style('opacity', 1.0);
} }
}); });
nodeDiv.transition()
.duration(200) // Show node details if node is not edited as has profiling information
.style('opacity', .9); if (!isEditNode && node.value.profile.length) {
nodeDiv nodeDiv.transition()
.html(nodeDetails(node)) .duration(200)
.style('left', (d3.event.pageX) + 30 + 'px') .style('opacity', .9);
.style('top', (d3.event.pageY - 28) + 'px'); nodeDiv
.html(nodeDetails(node))
.style('left', (d3.event.pageX) + 30 + 'px')
.style('top', (d3.event.pageY - 28) + 'px');
}
}); });
nodes.on('mouseout', function(node) { nodes.on('mouseout', function(node) {
......
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import numpy as np\n",
"from IPython.display import SVG"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Couldn't import dot_parser, loading of dot files will not be possible.\n"
]
}
],
"source": [
"import theano as th\n",
"import theano.tensor as tht\n",
"import theano.printing as thp\n",
"import theano.d3printing as d3p"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example 1"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"x, y, z = tht.scalars('xyz')\n",
"e = x + y * z\n",
"o = th.OpFromGraph([x, y, z], [e])\n",
"e2 = o(x, y, z) + o(z, y, y)\n",
"f = th.function([x, y, z], [e2])"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"topo = f.maker.fgraph.toposort()"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"of = topo[0]"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"fo = of.op.fn"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"gf = d3p.GraphFormatter()\n",
"g = gf.to_pydot(fo)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"220pt\" viewBox=\"0.00 0.00 722.00 220.00\" width=\"722pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 216)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" points=\"-4,4 -4,-216 718,-216 718,4 -4,4\" stroke=\"none\"/>\n",
"<!-- _1 -->\n",
"<g class=\"node\" id=\"node1\"><title>_1</title>\n",
"<ellipse cx=\"349\" cy=\"-106\" fill=\"#ffaabb\" rx=\"155.005\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-102.3\">Elemwise{Composite{(i0 + (i1 * i2))}}</text>\n",
"</g>\n",
"<!-- _5 -->\n",
"<g class=\"node\" id=\"node5\"><title>_5</title>\n",
"<polygon fill=\"dodgerblue\" points=\"435,-36 263,-36 263,-0 435,-0 435,-36\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-14.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _1&#45;&gt;_5 -->\n",
"<g class=\"edge\" id=\"edge4\"><title>_1-&gt;_5</title>\n",
"<path d=\"M349,-87.5966C349,-75.7459 349,-59.8169 349,-46.2917\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"352.5,-46.084 349,-36.084 345.5,-46.084 352.5,-46.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"427\" y=\"-58.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _2 -->\n",
"<g class=\"node\" id=\"node2\"><title>_2</title>\n",
"<polygon fill=\"limegreen\" points=\"220.25,-212 -0.25,-212 -0.25,-176 220.25,-176 220.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"110\" y=\"-190.3\">name=x TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _2&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge1\"><title>_2-&gt;_1</title>\n",
"<path d=\"M128.186,-175.807C141.119,-164.521 159.428,-150.354 178,-142 197.086,-133.415 218.319,-126.915 239.152,-121.999\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"240.022,-125.391 249.01,-119.781 238.486,-118.562 240.022,-125.391\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"261.5\" y=\"-146.3\">0 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3 -->\n",
"<g class=\"node\" id=\"node3\"><title>_3</title>\n",
"<polygon fill=\"limegreen\" points=\"459.25,-212 238.75,-212 238.75,-176 459.25,-176 459.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-190.3\">name=y TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge2\"><title>_3-&gt;_1</title>\n",
"<path d=\"M349,-175.597C349,-163.746 349,-147.817 349,-134.292\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"352.5,-134.084 349,-124.084 345.5,-134.084 352.5,-134.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"432.5\" y=\"-146.3\">1 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _4 -->\n",
"<g class=\"node\" id=\"node4\"><title>_4</title>\n",
"<polygon fill=\"limegreen\" points=\"698,-212 478,-212 478,-176 698,-176 698,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"588\" y=\"-190.3\">name=z TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _4&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge3\"><title>_4-&gt;_1</title>\n",
"<path d=\"M569.814,-175.807C556.881,-164.521 538.572,-150.354 520,-142 500.914,-133.415 479.681,-126.915 458.848,-121.999\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"459.514,-118.562 448.99,-119.781 457.978,-125.391 459.514,-118.562\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"630.5\" y=\"-146.3\">2 TensorType(float64, scalar)</text>\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"SVG(g.create_svg())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example 2 "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"x, y, z = tht.scalars('xyz')\n",
"e = x * y\n",
"o = th.OpFromGraph([x, y], [e])\n",
"e2 = o(x, y) + z\n",
"o2 = th.OpFromGraph([x, y, z], [e2])\n",
"e3 = o2(x, y, z) + z\n",
"f = th.function([x, y, z], [e3])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"topo = f.maker.fgraph.toposort()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"of = topo[0]"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"ofo = of.op"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"gf = d3p.GraphFormatter()"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"g = gf.to_pydot(ofo.fn.maker.fgraph)"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"259pt\" viewBox=\"0.00 0.00 1212.00 259.00\" width=\"1212pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 255)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" points=\"-4,4 -4,-255 1208,-255 1208,4 -4,4\" stroke=\"none\"/>\n",
"<g class=\"cluster\" id=\"clust1\"><title>cluster__1</title>\n",
"<polygon fill=\"none\" points=\"8,-168 8,-243 485,-243 485,-168 8,-168\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"246.5\" y=\"-227.8\">theano.compile.builders.OpFromGraph object at 0x10eff0410</text>\n",
"</g>\n",
"<!-- _2 -->\n",
"<g class=\"node\" id=\"node1\"><title>_2</title>\n",
"<polygon fill=\"limegreen\" points=\"476.25,-212 255.75,-212 255.75,-176 476.25,-176 476.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"366\" y=\"-190.3\">name=x TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3 -->\n",
"<g class=\"node\" id=\"node2\"><title>_3</title>\n",
"<polygon fill=\"limegreen\" points=\"237.25,-212 16.75,-212 16.75,-176 237.25,-176 237.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"127\" y=\"-190.3\">name=y TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _1 -->\n",
"<g class=\"node\" id=\"node3\"><title>_1</title>\n",
"<ellipse cx=\"730\" cy=\"-194\" fill=\"none\" rx=\"235.394\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"730\" y=\"-190.3\">theano.compile.builders.OpFromGraph object at 0x10eff0410</text>\n",
"</g>\n",
"<!-- _4 -->\n",
"<g class=\"node\" id=\"node4\"><title>_4</title>\n",
"<ellipse cx=\"912\" cy=\"-106\" fill=\"#ffaabb\" rx=\"96.2631\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"912\" y=\"-102.3\">Elemwise{Add}[(0, 0)]</text>\n",
"</g>\n",
"<!-- _1&#45;&gt;_4 -->\n",
"<g class=\"edge\" id=\"edge1\"><title>_1-&gt;_4</title>\n",
"<path d=\"M765.957,-176.009C795.53,-162.035 837.526,-142.191 868.899,-127.367\" fill=\"none\" stroke=\"red\"/>\n",
"<polygon fill=\"red\" points=\"870.722,-130.376 878.269,-122.939 867.732,-124.047 870.722,-130.376\" stroke=\"red\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"921.5\" y=\"-146.3\">0 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _6 -->\n",
"<g class=\"node\" id=\"node6\"><title>_6</title>\n",
"<polygon fill=\"dodgerblue\" points=\"1012.25,-36 811.75,-36 811.75,-0 1012.25,-0 1012.25,-36\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"912\" y=\"-14.3\">TensorType(float64, scalar) id=4</text>\n",
"</g>\n",
"<!-- _4&#45;&gt;_6 -->\n",
"<g class=\"edge\" id=\"edge3\"><title>_4-&gt;_6</title>\n",
"<path d=\"M912,-87.5966C912,-75.7459 912,-59.8169 912,-46.2917\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"915.5,-46.084 912,-36.084 908.5,-46.084 915.5,-46.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"990\" y=\"-58.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _5 -->\n",
"<g class=\"node\" id=\"node5\"><title>_5</title>\n",
"<polygon fill=\"limegreen\" points=\"1204,-212 984,-212 984,-176 1204,-176 1204,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"1094\" y=\"-190.3\">name=z TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _5&#45;&gt;_4 -->\n",
"<g class=\"edge\" id=\"edge2\"><title>_5-&gt;_4</title>\n",
"<path d=\"M1068.31,-175.793C1051.81,-165.201 1029.68,-151.818 1009,-142 996.117,-135.882 981.858,-130.182 968.328,-125.233\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"969.23,-121.838 958.635,-121.767 966.873,-128.43 969.23,-121.838\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"1120.5\" y=\"-146.3\">1 TensorType(float64, scalar)</text>\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"SVG(g.create_svg())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
digraph G { digraph G {
graph [bb="0,0,2482,251"]; graph [bb="0,0,2478,251"];
node [label="\N"]; node [label="\N"];
subgraph cluster__1 { subgraph cluster__1 {
graph [bb="8,168,723,243", graph [bb="8,168,723,243",
label="theano.compile.builders.OpFromGraph object at 0x1076d9190", label="theano.compile.builders.OpFromGraph object at 0x1141d3a50",
lheight=0.21, lheight=0.21,
lp="365.5,231.5", lp="365.5,231.5",
lwidth=4.90 lwidth=4.89
]; ];
_2 [fillcolor=limegreen, _2 [fillcolor=limegreen,
height=0.5, height=0.5,
...@@ -31,67 +31,67 @@ digraph G { ...@@ -31,67 +31,67 @@ digraph G {
width=3.0625]; width=3.0625];
} }
subgraph cluster__5 { subgraph cluster__5 {
graph [bb="1759,168,2474,243", graph [bb="1755,168,2470,243",
label="theano.compile.builders.OpFromGraph object at 0x1076d9190 id=1", label="theano.compile.builders.OpFromGraph object at 0x1141d3a50 id=1",
lheight=0.21, lheight=0.21,
lp="2116.5,231.5", lp="2112.5,231.5",
lwidth=5.31 lwidth=5.29
]; ];
_6 [fillcolor=limegreen, _6 [fillcolor=limegreen,
height=0.5, height=0.5,
label="name=x TensorType(float64, scalar)", label="name=x TensorType(float64, scalar)",
pos="2355,194", pos="2351,194",
shape=box, shape=box,
style=filled, style=filled,
width=3.0625]; width=3.0625];
_7 [fillcolor=limegreen, _7 [fillcolor=limegreen,
height=0.5, height=0.5,
label="name=y TensorType(float64, scalar)", label="name=y TensorType(float64, scalar)",
pos="2116,194", pos="2112,194",
shape=box, shape=box,
style=filled, style=filled,
width=3.0625]; width=3.0625];
_8 [fillcolor=limegreen, _8 [fillcolor=limegreen,
height=0.5, height=0.5,
label="name=z TensorType(float64, scalar)", label="name=z TensorType(float64, scalar)",
pos="1877,194", pos="1873,194",
shape=box, shape=box,
style=filled, style=filled,
width=3.0556]; width=3.0556];
} }
_1 [height=0.5, _1 [height=0.5,
label="theano.compile.builders.OpFromGraph object at 0x1076d9190", label="theano.compile.builders.OpFromGraph object at 0x1141d3a50",
pos="973,194", pos="972,194",
shape=ellipse, shape=ellipse,
width=6.6504]; width=6.6414];
_9 [fillcolor="#FFAABB", _9 [fillcolor="#FFAABB",
height=0.5, height=0.5,
label="Elemwise{Add}[(0, 0)]", label="Elemwise{Add}[(0, 0)]",
pos="1231,106", pos="1229,106",
shape=ellipse, shape=ellipse,
style=filled, style=filled,
type=colored, type=colored,
width=2.6784]; width=2.6784];
_1 -> _9 [label="TensorType(float64, scalar)", _1 -> _9 [label="1 TensorType(float64, scalar)",
lp="1204,150", lp="1207.5,150",
pos="e,1185.8,122.05 1023.1,176.32 1067,161.66 1130.8,140.38 1176.2,125.28"]; pos="e,1184,122.05 1021.9,176.32 1065.6,161.66 1129.2,140.38 1174.4,125.28"];
_5 [height=0.5, _5 [height=0.5,
label="theano.compile.builders.OpFromGraph object at 0x1076d9190 id=1", label="theano.compile.builders.OpFromGraph object at 0x1141d3a50 id=1",
pos="1490,194", pos="1487,194",
shape=ellipse, shape=ellipse,
width=7.1761]; width=7.167];
_5 -> _9 [color=red, _5 -> _9 [color=red,
label="TensorType(float64, scalar)", label="0 TensorType(float64, scalar)",
lp="1461,150", lp="1464.5,150",
pos="e,1276.3,122.05 1439.8,176.32 1395.6,161.66 1331.5,140.38 1286,125.28"]; pos="e,1274.2,122.05 1436.9,176.32 1393,161.66 1329.2,140.38 1283.8,125.28"];
_10 [fillcolor=dodgerblue, _10 [fillcolor=dodgerblue,
height=0.5, height=0.5,
label="TensorType(float64, scalar) id=5", label="TensorType(float64, scalar) id=5",
pos="1231,18", pos="1229,18",
shape=box, shape=box,
style=filled, style=filled,
width=2.7847]; width=2.7847];
_9 -> _10 [label="TensorType(float64, scalar)", _9 -> _10 [label="TensorType(float64, scalar)",
lp="1309,62", lp="1307,62",
pos="e,1231,36.084 1231,87.597 1231,75.746 1231,59.817 1231,46.292"]; pos="e,1229,36.084 1229,87.597 1229,75.746 1229,59.817 1229,46.292"];
} }
...@@ -301,10 +301,7 @@ function setupGraph() { ...@@ -301,10 +301,7 @@ function setupGraph() {
}); });
nodes.on('mouseover', function(node) { nodes.on('mouseover', function(node) {
if (!isProfiled || isEditNode || typeof(node.value.profile) == 'undefined') { // Highlight incoming edges
return;
}
edges.each(function (d, i) { edges.each(function (d, i) {
var edge = d3.select(this); var edge = d3.select(this);
if (d.source == node || d.target == node) { if (d.source == node || d.target == node) {
...@@ -313,13 +310,17 @@ function setupGraph() { ...@@ -313,13 +310,17 @@ function setupGraph() {
.style('opacity', 1.0); .style('opacity', 1.0);
} }
}); });
nodeDiv.transition()
.duration(200) // Show node details if node is not edited as has profiling information
.style('opacity', .9); if (!isEditNode && node.value.profile.length) {
nodeDiv nodeDiv.transition()
.html(nodeDetails(node)) .duration(200)
.style('left', (d3.event.pageX) + 30 + 'px') .style('opacity', .9);
.style('top', (d3.event.pageY - 28) + 'px'); nodeDiv
.html(nodeDetails(node))
.style('left', (d3.event.pageX) + 30 + 'px')
.style('top', (d3.event.pageY - 28) + 'px');
}
}); });
nodes.on('mouseout', function(node) { nodes.on('mouseout', function(node) {
......
...@@ -3,7 +3,7 @@ digraph G { ...@@ -3,7 +3,7 @@ digraph G {
node [label="\N"]; node [label="\N"];
subgraph cluster__1 { subgraph cluster__1 {
graph [bb="8,168,723,243", graph [bb="8,168,723,243",
label="theano.compile.builders.OpFromGraph object at 0x1076d9190", label="theano.compile.builders.OpFromGraph object at 0x114552bd0",
lheight=0.21, lheight=0.21,
lp="365.5,231.5", lp="365.5,231.5",
lwidth=4.90 lwidth=4.90
...@@ -32,7 +32,7 @@ digraph G { ...@@ -32,7 +32,7 @@ digraph G {
} }
subgraph cluster__5 { subgraph cluster__5 {
graph [bb="1759,168,2474,243", graph [bb="1759,168,2474,243",
label="theano.compile.builders.OpFromGraph object at 0x1076d9190 id=1", label="theano.compile.builders.OpFromGraph object at 0x114552bd0 id=1",
lheight=0.21, lheight=0.21,
lp="2116.5,231.5", lp="2116.5,231.5",
lwidth=5.31 lwidth=5.31
...@@ -60,7 +60,7 @@ digraph G { ...@@ -60,7 +60,7 @@ digraph G {
width=3.0556]; width=3.0556];
} }
_1 [height=0.5, _1 [height=0.5,
label="theano.compile.builders.OpFromGraph object at 0x1076d9190", label="theano.compile.builders.OpFromGraph object at 0x114552bd0",
pos="973,194", pos="973,194",
shape=ellipse, shape=ellipse,
width=6.6504]; width=6.6504];
...@@ -72,17 +72,17 @@ digraph G { ...@@ -72,17 +72,17 @@ digraph G {
style=filled, style=filled,
type=colored, type=colored,
width=2.6784]; width=2.6784];
_1 -> _9 [label="TensorType(float64, scalar)", _1 -> _9 [label="1 TensorType(float64, scalar)",
lp="1204,150", lp="1209.5,150",
pos="e,1185.8,122.05 1023.1,176.32 1067,161.66 1130.8,140.38 1176.2,125.28"]; pos="e,1185.8,122.05 1023.1,176.32 1067,161.66 1130.8,140.38 1176.2,125.28"];
_5 [height=0.5, _5 [height=0.5,
label="theano.compile.builders.OpFromGraph object at 0x1076d9190 id=1", label="theano.compile.builders.OpFromGraph object at 0x114552bd0 id=1",
pos="1490,194", pos="1490,194",
shape=ellipse, shape=ellipse,
width=7.1761]; width=7.1761];
_5 -> _9 [color=red, _5 -> _9 [color=red,
label="TensorType(float64, scalar)", label="0 TensorType(float64, scalar)",
lp="1461,150", lp="1466.5,150",
pos="e,1276.3,122.05 1439.8,176.32 1395.6,161.66 1331.5,140.38 1286,125.28"]; pos="e,1276.3,122.05 1439.8,176.32 1395.6,161.66 1331.5,140.38 1286,125.28"];
_10 [fillcolor=dodgerblue, _10 [fillcolor=dodgerblue,
height=0.5, height=0.5,
......
...@@ -301,10 +301,7 @@ function setupGraph() { ...@@ -301,10 +301,7 @@ function setupGraph() {
}); });
nodes.on('mouseover', function(node) { nodes.on('mouseover', function(node) {
if (!isProfiled || isEditNode || typeof(node.value.profile) == 'undefined') { // Highlight incoming edges
return;
}
edges.each(function (d, i) { edges.each(function (d, i) {
var edge = d3.select(this); var edge = d3.select(this);
if (d.source == node || d.target == node) { if (d.source == node || d.target == node) {
...@@ -313,13 +310,17 @@ function setupGraph() { ...@@ -313,13 +310,17 @@ function setupGraph() {
.style('opacity', 1.0); .style('opacity', 1.0);
} }
}); });
nodeDiv.transition()
.duration(200) // Show node details if node is not edited as has profiling information
.style('opacity', .9); if (!isEditNode && node.value.profile.length) {
nodeDiv nodeDiv.transition()
.html(nodeDetails(node)) .duration(200)
.style('left', (d3.event.pageX) + 30 + 'px') .style('opacity', .9);
.style('top', (d3.event.pageY - 28) + 'px'); nodeDiv
.html(nodeDetails(node))
.style('left', (d3.event.pageX) + 30 + 'px')
.style('top', (d3.event.pageY - 28) + 'px');
}
}); });
nodes.on('mouseout', function(node) { nodes.on('mouseout', function(node) {
......
digraph G { digraph G {
graph [bb="0,0,1448,251"]; graph [bb="0,0,1450,251"];
node [label="\N"]; node [label="\N"];
subgraph cluster__1 { subgraph cluster__1 {
graph [bb="8,168,723,243", graph [bb="8,168,723,243",
label="theano.compile.builders.OpFromGraph object at 0x107b5ca10", label="theano.compile.builders.OpFromGraph object at 0x114648450",
lheight=0.21, lheight=0.21,
lp="365.5,231.5", lp="365.5,231.5",
lwidth=4.88 lwidth=4.90
]; ];
_2 [fillcolor=limegreen, _2 [fillcolor=limegreen,
height=0.5, height=0.5,
...@@ -31,40 +31,40 @@ digraph G { ...@@ -31,40 +31,40 @@ digraph G {
width=3.0556]; width=3.0556];
} }
_1 [height=0.5, _1 [height=0.5,
label="theano.compile.builders.OpFromGraph object at 0x107b5ca10", label="theano.compile.builders.OpFromGraph object at 0x114648450",
pos="971,194", pos="972,194",
shape=ellipse, shape=ellipse,
width=6.6185]; width=6.6504];
_5 [fillcolor="#FFAABB", _5 [fillcolor="#FFAABB",
height=0.5, height=0.5,
label="Elemwise{Add}[(0, 0)]", label="Elemwise{Add}[(0, 0)]",
pos="1154,106", pos="1156,106",
shape=ellipse, shape=ellipse,
style=filled, style=filled,
type=colored, type=colored,
width=2.6784]; width=2.6784];
_1 -> _5 [color=red, _1 -> _5 [color=red,
label="TensorType(float64, scalar)", label="0 TensorType(float64, scalar)",
lp="1157,150", lp="1164.5,150",
pos="e,1120.1,122.94 1007.2,176.01 1036.9,162.04 1079.1,142.19 1110.7,127.37"]; pos="e,1121.9,122.94 1008.4,176.01 1038.4,161.97 1081.1,142.02 1112.8,127.18"];
_7 [fillcolor=dodgerblue, _7 [fillcolor=dodgerblue,
height=0.5, height=0.5,
label="TensorType(float64, scalar) id=4", label="TensorType(float64, scalar) id=4",
pos="1154,18", pos="1156,18",
shape=box, shape=box,
style=filled, style=filled,
width=2.7847]; width=2.7847];
_5 -> _7 [label="TensorType(float64, scalar)", _5 -> _7 [label="TensorType(float64, scalar)",
lp="1232,62", lp="1234,62",
pos="e,1154,36.084 1154,87.597 1154,75.746 1154,59.817 1154,46.292"]; pos="e,1156,36.084 1156,87.597 1156,75.746 1156,59.817 1156,46.292"];
_6 [fillcolor=limegreen, _6 [fillcolor=limegreen,
height=0.5, height=0.5,
label="name=z TensorType(float64, scalar)", label="name=z TensorType(float64, scalar)",
pos="1338,194", pos="1340,194",
shape=box, shape=box,
style=filled, style=filled,
width=3.0556]; width=3.0556];
_6 -> _5 [label="TensorType(float64, scalar)", _6 -> _5 [label="1 TensorType(float64, scalar)",
lp="1347,150", lp="1364.5,150",
pos="e,1193.7,122.51 1306.2,175.76 1287,165.54 1261.8,152.55 1239,142 1227.5,136.66 1214.9,131.25 1203,126.34"]; pos="e,1202.1,121.95 1313.3,175.88 1296.2,165.33 1273.3,151.95 1252,142 1239.2,136.01 1225.1,130.36 1211.7,125.42"];
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"cells": [ "cells": [
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 8,
"metadata": { "metadata": {
"collapsed": true "collapsed": true
}, },
...@@ -14,11 +14,20 @@ ...@@ -14,11 +14,20 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 9,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [ "source": [
"%load_ext autoreload\n", "%load_ext autoreload\n",
"%autoreload 2" "%autoreload 2"
...@@ -26,19 +35,11 @@ ...@@ -26,19 +35,11 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 10,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"Couldn't import dot_parser, loading of dot files will not be possible.\n"
]
}
],
"source": [ "source": [
"import theano as th\n", "import theano as th\n",
"import theano.tensor as tht\n", "import theano.tensor as tht\n",
...@@ -46,6 +47,21 @@ ...@@ -46,6 +47,21 @@
"import theano.d3printing as d3p" "import theano.d3printing as d3p"
] ]
}, },
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def viz_ofg(ofg):\n",
" fo = ofg.op.fn\n",
" gf = d3p.GraphFormatter()\n",
" g = gf.to_pydot(fo)\n",
" return g.create_svg()"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
...@@ -55,7 +71,7 @@ ...@@ -55,7 +71,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 31,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -70,43 +86,106 @@ ...@@ -70,43 +86,106 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 12,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"gf = d3p.GraphFormatter()\n", "d3p.d3print(f, 'example1/index.html')"
"g = gf.to_pydot(f)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "markdown",
"execution_count": 6, "metadata": {},
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [ "source": [
"g.write_dot('dev/opfrom.dot');" "[Open](./example1/index.html)"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "markdown",
"execution_count": 7, "metadata": {},
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [ "source": [
"d3p.d3print(f, 'example1/index.html')" "## OFG node"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "code",
"metadata": {}, "execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"220pt\" viewBox=\"0.00 0.00 722.00 220.00\" width=\"722pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 216)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" points=\"-4,4 -4,-216 718,-216 718,4 -4,4\" stroke=\"none\"/>\n",
"<!-- _1 -->\n",
"<g class=\"node\" id=\"node1\"><title>_1</title>\n",
"<ellipse cx=\"349\" cy=\"-106\" fill=\"#ffaabb\" rx=\"155.005\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-102.3\">Elemwise{Composite{(i0 + (i1 * i2))}}</text>\n",
"</g>\n",
"<!-- _5 -->\n",
"<g class=\"node\" id=\"node5\"><title>_5</title>\n",
"<polygon fill=\"dodgerblue\" points=\"435,-36 263,-36 263,-0 435,-0 435,-36\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-14.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _1&#45;&gt;_5 -->\n",
"<g class=\"edge\" id=\"edge4\"><title>_1-&gt;_5</title>\n",
"<path d=\"M349,-87.5966C349,-75.7459 349,-59.8169 349,-46.2917\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"352.5,-46.084 349,-36.084 345.5,-46.084 352.5,-46.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"427\" y=\"-58.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _2 -->\n",
"<g class=\"node\" id=\"node2\"><title>_2</title>\n",
"<polygon fill=\"limegreen\" points=\"220.25,-212 -0.25,-212 -0.25,-176 220.25,-176 220.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"110\" y=\"-190.3\">name=x TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _2&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge1\"><title>_2-&gt;_1</title>\n",
"<path d=\"M128.186,-175.807C141.119,-164.521 159.428,-150.354 178,-142 197.086,-133.415 218.319,-126.915 239.152,-121.999\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"240.022,-125.391 249.01,-119.781 238.486,-118.562 240.022,-125.391\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"261.5\" y=\"-146.3\">0 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3 -->\n",
"<g class=\"node\" id=\"node3\"><title>_3</title>\n",
"<polygon fill=\"limegreen\" points=\"459.25,-212 238.75,-212 238.75,-176 459.25,-176 459.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-190.3\">name=y TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge2\"><title>_3-&gt;_1</title>\n",
"<path d=\"M349,-175.597C349,-163.746 349,-147.817 349,-134.292\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"352.5,-134.084 349,-124.084 345.5,-134.084 352.5,-134.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"432.5\" y=\"-146.3\">1 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _4 -->\n",
"<g class=\"node\" id=\"node4\"><title>_4</title>\n",
"<polygon fill=\"limegreen\" points=\"698,-212 478,-212 478,-176 698,-176 698,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"588\" y=\"-190.3\">name=z TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _4&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge3\"><title>_4-&gt;_1</title>\n",
"<path d=\"M569.814,-175.807C556.881,-164.521 538.572,-150.354 520,-142 500.914,-133.415 479.681,-126.915 458.848,-121.999\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"459.514,-118.562 448.99,-119.781 457.978,-125.391 459.514,-118.562\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"630.5\" y=\"-146.3\">2 TensorType(float64, scalar)</text>\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"[Open](./example1/index.html)" "SVG(viz_ofg(f.maker.fgraph.toposort()[0]))"
] ]
}, },
{ {
...@@ -118,7 +197,7 @@ ...@@ -118,7 +197,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 42,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -135,7 +214,7 @@ ...@@ -135,7 +214,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 21,
"metadata": { "metadata": {
"collapsed": false "collapsed": false
}, },
...@@ -150,6 +229,172 @@ ...@@ -150,6 +229,172 @@
"source": [ "source": [
"[Open](./example2/index.html)" "[Open](./example2/index.html)"
] ]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## OFG node 1 "
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"259pt\" viewBox=\"0.00 0.00 1219.00 259.00\" width=\"1219pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 255)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" points=\"-4,4 -4,-255 1215,-255 1215,4 -4,4\" stroke=\"none\"/>\n",
"<g class=\"cluster\" id=\"clust1\"><title>cluster__1</title>\n",
"<polygon fill=\"none\" points=\"8,-168 8,-243 485,-243 485,-168 8,-168\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"246.5\" y=\"-227.8\">theano.compile.builders.OpFromGraph object at 0x1148a8110</text>\n",
"</g>\n",
"<!-- _2 -->\n",
"<g class=\"node\" id=\"node1\"><title>_2</title>\n",
"<polygon fill=\"limegreen\" points=\"476.25,-212 255.75,-212 255.75,-176 476.25,-176 476.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"366\" y=\"-190.3\">name=x TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3 -->\n",
"<g class=\"node\" id=\"node2\"><title>_3</title>\n",
"<polygon fill=\"limegreen\" points=\"237.25,-212 16.75,-212 16.75,-176 237.25,-176 237.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"127\" y=\"-190.3\">name=y TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _1 -->\n",
"<g class=\"node\" id=\"node3\"><title>_1</title>\n",
"<ellipse cx=\"734\" cy=\"-194\" fill=\"none\" rx=\"239.268\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"734\" y=\"-190.3\">theano.compile.builders.OpFromGraph object at 0x1148a8110</text>\n",
"</g>\n",
"<!-- _4 -->\n",
"<g class=\"node\" id=\"node4\"><title>_4</title>\n",
"<ellipse cx=\"917\" cy=\"-106\" fill=\"#ffaabb\" rx=\"96.2631\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"917\" y=\"-102.3\">Elemwise{Add}[(0, 0)]</text>\n",
"</g>\n",
"<!-- _1&#45;&gt;_4 -->\n",
"<g class=\"edge\" id=\"edge1\"><title>_1-&gt;_4</title>\n",
"<path d=\"M770.155,-176.009C799.89,-162.035 842.117,-142.191 873.662,-127.367\" fill=\"none\" stroke=\"red\"/>\n",
"<polygon fill=\"red\" points=\"875.521,-130.36 883.083,-122.939 872.544,-124.025 875.521,-130.36\" stroke=\"red\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"925.5\" y=\"-146.3\">0 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _6 -->\n",
"<g class=\"node\" id=\"node6\"><title>_6</title>\n",
"<polygon fill=\"dodgerblue\" points=\"1017.25,-36 816.75,-36 816.75,-0 1017.25,-0 1017.25,-36\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"917\" y=\"-14.3\">TensorType(float64, scalar) id=4</text>\n",
"</g>\n",
"<!-- _4&#45;&gt;_6 -->\n",
"<g class=\"edge\" id=\"edge3\"><title>_4-&gt;_6</title>\n",
"<path d=\"M917,-87.5966C917,-75.7459 917,-59.8169 917,-46.2917\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"920.5,-46.084 917,-36.084 913.5,-46.084 920.5,-46.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"995\" y=\"-58.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _5 -->\n",
"<g class=\"node\" id=\"node5\"><title>_5</title>\n",
"<polygon fill=\"limegreen\" points=\"1211,-212 991,-212 991,-176 1211,-176 1211,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"1101\" y=\"-190.3\">name=z TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _5&#45;&gt;_4 -->\n",
"<g class=\"edge\" id=\"edge2\"><title>_5-&gt;_4</title>\n",
"<path d=\"M1074.31,-175.883C1057.2,-165.325 1034.27,-151.949 1013,-142 1000.2,-136.013 986.068,-130.363 972.675,-125.42\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"973.677,-122.061 963.083,-121.951 971.296,-128.644 973.677,-122.061\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"1125.5\" y=\"-146.3\">1 TensorType(float64, scalar)</text>\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ofg1 = f.maker.fgraph.toposort()[0]\n",
"SVG(viz_ofg(ofg1))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## OFG node 2"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"220pt\" viewBox=\"0.00 0.00 513.00 220.00\" width=\"513pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"<g class=\"graph\" id=\"graph0\" transform=\"scale(1 1) rotate(0) translate(4 216)\">\n",
"<title>G</title>\n",
"<polygon fill=\"white\" points=\"-4,4 -4,-216 509,-216 509,4 -4,4\" stroke=\"none\"/>\n",
"<!-- _1 -->\n",
"<g class=\"node\" id=\"node1\"><title>_1</title>\n",
"<ellipse cx=\"229\" cy=\"-106\" fill=\"#ffaabb\" rx=\"111.186\" ry=\"18\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"229\" y=\"-102.3\">Elemwise{mul,no_inplace}</text>\n",
"</g>\n",
"<!-- _4 -->\n",
"<g class=\"node\" id=\"node4\"><title>_4</title>\n",
"<polygon fill=\"dodgerblue\" points=\"315,-36 143,-36 143,-0 315,-0 315,-36\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"229\" y=\"-14.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _1&#45;&gt;_4 -->\n",
"<g class=\"edge\" id=\"edge3\"><title>_1-&gt;_4</title>\n",
"<path d=\"M229,-87.5966C229,-75.7459 229,-59.8169 229,-46.2917\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"232.5,-46.084 229,-36.084 225.5,-46.084 232.5,-46.084\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"307\" y=\"-58.3\">TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _2 -->\n",
"<g class=\"node\" id=\"node2\"><title>_2</title>\n",
"<polygon fill=\"limegreen\" points=\"220.25,-212 -0.25,-212 -0.25,-176 220.25,-176 220.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"110\" y=\"-190.3\">name=x TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _2&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge1\"><title>_2-&gt;_1</title>\n",
"<path d=\"M124.112,-175.983C133.526,-165.334 146.597,-151.821 160,-142 167.085,-136.809 175.052,-131.986 182.989,-127.682\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"184.633,-130.772 191.889,-123.051 181.402,-124.562 184.633,-130.772\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"243.5\" y=\"-146.3\">0 TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3 -->\n",
"<g class=\"node\" id=\"node3\"><title>_3</title>\n",
"<polygon fill=\"limegreen\" points=\"459.25,-212 238.75,-212 238.75,-176 459.25,-176 459.25,-212\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"349\" y=\"-190.3\">name=y TensorType(float64, scalar)</text>\n",
"</g>\n",
"<!-- _3&#45;&gt;_1 -->\n",
"<g class=\"edge\" id=\"edge2\"><title>_3-&gt;_1</title>\n",
"<path d=\"M345.336,-175.801C342.177,-164.804 336.566,-150.971 327,-142 319.637,-135.095 310.819,-129.537 301.533,-125.066\" fill=\"none\" stroke=\"black\"/>\n",
"<polygon fill=\"black\" points=\"302.691,-121.753 292.126,-120.949 299.884,-128.165 302.691,-121.753\" stroke=\"black\"/>\n",
"<text font-family=\"Times,serif\" font-size=\"14.00\" text-anchor=\"middle\" x=\"421.5\" y=\"-146.3\">1 TensorType(float64, scalar)</text>\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ofg2 = ofg1.op.fn.maker.fgraph.toposort()[0]\n",
"SVG(viz_ofg(ofg2))"
]
} }
], ],
"metadata": { "metadata": {
......
...@@ -155,12 +155,13 @@ class GraphFormatter(object): ...@@ -155,12 +155,13 @@ class GraphFormatter(object):
param['color'] = 'red' param['color'] = 'red'
edge_label = str(var.type) edge_label = str(var.type)
if len(node.inputs) > 1:
edge_label = str(id) + ' ' + edge_label
if var.owner is None: if var.owner is None:
id_ = self.var_name(var) id_ = self.var_name(var)
n = make_node(id_, n = make_node(id_, style='filled',
style='filled', fillcolor=self.node_colors['input'],
fillcolor=self.node_colors['input'], shape=var_shape, profile=aprof)
shape=var_shape, profile=aprof)
parent.add_node(n) parent.add_node(n)
if not is_opfrom: if not is_opfrom:
g.add_edge(pd.Edge(n.get_name(), aid, label=edge_label, **param)) g.add_edge(pd.Edge(n.get_name(), aid, label=edge_label, **param))
......
...@@ -301,10 +301,7 @@ function setupGraph() { ...@@ -301,10 +301,7 @@ function setupGraph() {
}); });
nodes.on('mouseover', function(node) { nodes.on('mouseover', function(node) {
if (!isProfiled || isEditNode || typeof(node.value.profile) == 'undefined') { // Highlight incoming edges
return;
}
edges.each(function (d, i) { edges.each(function (d, i) {
var edge = d3.select(this); var edge = d3.select(this);
if (d.source == node || d.target == node) { if (d.source == node || d.target == node) {
...@@ -313,13 +310,17 @@ function setupGraph() { ...@@ -313,13 +310,17 @@ function setupGraph() {
.style('opacity', 1.0); .style('opacity', 1.0);
} }
}); });
nodeDiv.transition()
.duration(200) // Show node details if node is not edited as has profiling information
.style('opacity', .9); if (!isEditNode && node.value.profile.length) {
nodeDiv nodeDiv.transition()
.html(nodeDetails(node)) .duration(200)
.style('left', (d3.event.pageX) + 30 + 'px') .style('opacity', .9);
.style('top', (d3.event.pageY - 28) + 'px'); nodeDiv
.html(nodeDetails(node))
.style('left', (d3.event.pageX) + 30 + 'px')
.style('top', (d3.event.pageY - 28) + 'px');
}
}); });
nodes.on('mouseout', function(node) { nodes.on('mouseout', function(node) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论