提交 a2666307 authored 作者: Frederic's avatar Frederic

make pydotprint add the timming in the plot with the new profiler.

上级 33c4b2cc
...@@ -544,12 +544,14 @@ def pydotprint(fct, outfile=None, ...@@ -544,12 +544,14 @@ def pydotprint(fct, outfile=None,
if isinstance(fct, Function): if isinstance(fct, Function):
mode = fct.maker.mode mode = fct.maker.mode
fct_fgraph = fct.maker.fgraph profile = getattr(fct, "profile", None)
if (not isinstance(mode, ProfileMode) if (not isinstance(mode, ProfileMode)
or not fct in mode.profile_stats): or not fct in mode.profile_stats):
mode = None mode = None
fct_fgraph = fct.maker.fgraph
elif isinstance(fct, gof.FunctionGraph): elif isinstance(fct, gof.FunctionGraph):
mode = None mode = None
profile = None
fct_fgraph = fct fct_fgraph = fct
else: else:
raise ValueError(('pydotprint expects as input a theano.function or ' raise ValueError(('pydotprint expects as input a theano.function or '
...@@ -660,6 +662,14 @@ def pydotprint(fct, outfile=None, ...@@ -660,6 +662,14 @@ def pydotprint(fct, outfile=None,
else: else:
pf = time * 100 / mode.profile_stats[fct].fct_call_time pf = time * 100 / mode.profile_stats[fct].fct_call_time
prof_str = ' (%.3fs,%.3f%%,%.3f%%)' % (time, pt, pf) prof_str = ' (%.3fs,%.3f%%,%.3f%%)' % (time, pt, pf)
elif profile:
time = profile.apply_time.get(node, 0)
#second, %fct time in profiler
if profile.fct_callcount == 0:
pf = 0
else:
pf = time * 100 / profile.fct_call_time
prof_str = ' (%.3fs,%.3f%%)' % (time, pf)
applystr = str(node.op).replace(':', '_') applystr = str(node.op).replace(':', '_')
applystr += prof_str applystr += prof_str
if (applystr in all_strings) or with_ids: if (applystr in all_strings) or with_ids:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论