提交 76d02f64 authored 作者: Frederic's avatar Frederic

Print the optimized scan graph

上级 499f5728
...@@ -99,6 +99,8 @@ def debugprint(obj, depth=-1, print_type=False, ...@@ -99,6 +99,8 @@ def debugprint(obj, depth=-1, print_type=False,
order = obj.toposort() order = obj.toposort()
elif isinstance(obj, (int, long, float, numpy.ndarray)): elif isinstance(obj, (int, long, float, numpy.ndarray)):
print obj print obj
elif isinstance(obj, (theano.In, theano.Out)):
results_to_print.append(obj.variable)
else: else:
raise TypeError("debugprint cannot print an object of this type", raise TypeError("debugprint cannot print an object of this type",
obj) obj)
...@@ -123,8 +125,12 @@ def debugprint(obj, depth=-1, print_type=False, ...@@ -123,8 +125,12 @@ def debugprint(obj, depth=-1, print_type=False,
debugmode.debugprint(s, depth=depth, done=done, print_type=print_type, debugmode.debugprint(s, depth=depth, done=done, print_type=print_type,
file=_file, ids=ids, file=_file, ids=ids,
scan_ops=scan_ops, stop_on_name=stop_on_name) scan_ops=scan_ops, stop_on_name=stop_on_name)
if hasattr(s.owner.op, 'fn'):
for idx, i in enumerate(s.owner.op.outputs): # If the op was compiled, print the optimized version.
outputs = s.owner.op.fn.maker.fgraph.outputs
else:
outputs = s.owner.op.output
for idx, i in enumerate(outputs):
if hasattr(i, 'owner') and hasattr(i.owner, 'op'): if hasattr(i, 'owner') and hasattr(i.owner, 'op'):
if isinstance(i.owner.op, theano.scan_module.scan_op.Scan): if isinstance(i.owner.op, theano.scan_module.scan_op.Scan):
scan_ops.append(i) scan_ops.append(i)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论