提交 ce53f5e8 authored 作者: abergeron's avatar abergeron 提交者: GitHub

Merge pull request #6273 from nouiz/gh-6268_scan_profile

[CRASH] Crash fix when we don't do scan(..., profile=True)
...@@ -2895,7 +2895,15 @@ def profile_printer(message, compile_time, fct_call_time, ...@@ -2895,7 +2895,15 @@ def profile_printer(message, compile_time, fct_call_time,
total_scan_fct_time = 0 total_scan_fct_time = 0
total_scan_op_time = 0 total_scan_op_time = 0
for node, v in iteritems(apply_time): for node, v in iteritems(apply_time):
if isinstance(node.op, Scan) and node.op.fn.profile: if isinstance(node.op, Scan) and not node.op.fn.profile:
print(
" One scan node do not have its inner profile enabled. "
"If you enable Theano profiler with "
"'theano.function(..., profile=True)', you must manually"
" enable the profiling for each scan too: "
"'theano.scan_module.scan(...,profile=True)'."
" Or use Theano flag 'profile=True'.", file=file)
elif isinstance(node.op, Scan) and node.op.fn.profile:
if v > 0: if v > 0:
scan_fct_time = node.op.fn.profile.call_time scan_fct_time = node.op.fn.profile.call_time
scan_op_time = sum(node.op.fn.profile.apply_time.values()) scan_op_time = sum(node.op.fn.profile.apply_time.values())
...@@ -2911,9 +2919,12 @@ def profile_printer(message, compile_time, fct_call_time, ...@@ -2911,9 +2919,12 @@ def profile_printer(message, compile_time, fct_call_time,
else: else:
print((' The node took 0s, so we can not ' print((' The node took 0s, so we can not '
'compute the overhead'), node, file=file) 'compute the overhead'), node, file=file)
print('total %5.1fs %5.1fs %5.1fs %5.1f%% %5.1f%%' % ( if total_super_scan_time == 0:
total_super_scan_time, print(' No scan have its inner profile enabled.', file=file)
total_scan_fct_time, else:
total_scan_op_time, print('total %5.1fs %5.1fs %5.1fs %5.1f%% %5.1f%%' % (
total_scan_fct_time / total_super_scan_time * 100, total_super_scan_time,
total_scan_op_time / total_super_scan_time * 100), file=file) total_scan_fct_time,
total_scan_op_time,
total_scan_fct_time / total_super_scan_time * 100,
total_scan_op_time / total_super_scan_time * 100), file=file)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论