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

Add in the cvm profile the printing of the sum of all theano function.

上级 9707cf67
...@@ -15,11 +15,15 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>" ...@@ -15,11 +15,15 @@ __contact__ = "theano-dev <theano-dev@googlegroups.com>"
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
import atexit import atexit
import copy
import sys import sys
import theano
from theano.configparser import AddConfigVar, StrParam, BoolParam
import time import time
import numpy import numpy
import theano
from theano.configparser import AddConfigVar, StrParam, BoolParam
import_time = time.time() import_time = time.time()
config = theano.config config = theano.config
...@@ -39,6 +43,23 @@ def _atexit_print_fn(): ...@@ -39,6 +43,23 @@ def _atexit_print_fn():
ps.summary(file=_atexit_print_file) ps.summary(file=_atexit_print_file)
else: else:
print 'Skipping empty Profile' print 'Skipping empty Profile'
if len(_atexit_print_list) > 1:
# Make a global profile
cum = copy.copy(_atexit_print_list[0])
cum.message = "Sum of all Theano function"
for ps in _atexit_print_list[1:]:
for attr in ["compile_time", "fct_call_time", "fct_callcount",
"vm_call_time", "optimizer_time", "linker_time"]:
setattr(cum, attr, getattr(cum, attr) + getattr(ps, attr))
for attr in ["apply_time", "apply_callcount",
"apply_cimpl", "outputs_size"]:
cum_attr = getattr(cum, attr)
for key, val in getattr(ps, attr).iteritems():
assert key not in cum_attr
cum_attr[key] = val
cum.summary(file=_atexit_print_file)
atexit.register(_atexit_print_fn) atexit.register(_atexit_print_fn)
class ProfileStats(object): class ProfileStats(object):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论