提交 3f63bfa0 authored 作者: Frederic's avatar Frederic

Put color on pydotprint edge

上级 4c76812b
......@@ -623,6 +623,10 @@ def pydotprint(fct, outfile=None,
red ellipses are transfers from/to the gpu (ops with names GpuFromHost,
HostFromGpu).
For edge's, they black by default. If a node return a view
of an input, we put the corresponding input edge in blue. If we
return a destroyed inputs, we put the corresponding edge in red.
.. note::
Since October 20th, 2014, this print the inner function of all
......@@ -838,6 +842,13 @@ def pydotprint(fct, outfile=None,
label = str(id) + ' ' + label
if len(label) > max_label_size:
label = label[:max_label_size - 3] + '...'
param = {}
if hasattr(node.op, 'view_map') and id in reduce(
list.__add__, node.op.view_map.values()):
param['color'] = 'blue'
elif hasattr(node.op, 'destroy_map') and id in reduce(
list.__add__, node.op.destroy_map.values()):
param['color'] = 'red'
if var.owner is None:
if high_contrast:
g.add_node(pd.Node(varstr,
......@@ -846,12 +857,12 @@ def pydotprint(fct, outfile=None,
shape=var_shape))
else:
g.add_node(pd.Node(varstr, color='green', shape=var_shape))
g.add_edge(pd.Edge(varstr, astr, label=label))
g.add_edge(pd.Edge(varstr, astr, label=label, **param))
elif var.name or not compact:
g.add_edge(pd.Edge(varstr, astr, label=label))
g.add_edge(pd.Edge(varstr, astr, label=label, **param))
else:
# no name, so we don't make a var ellipse
g.add_edge(pd.Edge(apply_name(var.owner), astr, label=label))
g.add_edge(pd.Edge(apply_name(var.owner), astr, label=label, **param))
for id, var in enumerate(node.outputs):
varstr = var_name(var)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论