提交 d1cef2d5 authored 作者: Amjad Almahairi's avatar Amjad Almahairi

adding profiling.destination in config to enable outputting the profiling results to a file

上级 34a45383
...@@ -338,6 +338,16 @@ import theano and print the config variable, as in: ...@@ -338,6 +338,16 @@ import theano and print the config variable, as in:
Do the memory profile print the min peak memory usage? Do the memory profile print the min peak memory usage?
It only works when profile=True, profile_memory=True It only works when profile=True, profile_memory=True
.. attribute:: profiling.destination
String value
Default ''
Name of the destination file for the profiling output.
If string is empty then profiling output is directed
to stderr.
.. attribute:: config.lib.amdlibm .. attribute:: config.lib.amdlibm
Bool value: either True or False Bool value: either True or False
......
...@@ -25,14 +25,13 @@ import numpy ...@@ -25,14 +25,13 @@ import numpy
import theano import theano
from theano.gof import graph from theano.gof import graph
from theano.configparser import AddConfigVar, BoolParam, IntParam from theano.configparser import AddConfigVar, BoolParam, IntParam, StrParam
import_time = time.time() import_time = time.time()
config = theano.config config = theano.config
_atexit_print_list = [] _atexit_print_list = []
_atexit_print_file = sys.stderr
_atexit_registered = False _atexit_registered = False
AddConfigVar('profiling.time_thunks', AddConfigVar('profiling.time_thunks',
...@@ -66,14 +65,27 @@ AddConfigVar('profiling.min_peak_memory', ...@@ -66,14 +65,27 @@ AddConfigVar('profiling.min_peak_memory',
BoolParam(False), BoolParam(False),
in_c_key=False) in_c_key=False)
AddConfigVar('profiling.destination',
"""
File destination of the profiling output
""",
StrParam(''),
in_c_key=False)
def _atexit_print_fn(): def _atexit_print_fn():
"""Print ProfileStat objects in _atexit_print_list to _atexit_print_file """Print ProfileStat objects in _atexit_print_list to _atexit_print_file
""" """
to_sum = [] to_sum = []
if config.profiling.destination == '':
destination_file = sys.stderr
else:
destination_file = open(config.profiling.destination, 'w')
for ps in _atexit_print_list: for ps in _atexit_print_list:
if ps.fct_callcount or ps.compile_time > 0: if ps.fct_callcount or ps.compile_time > 0:
ps.summary(file=_atexit_print_file, ps.summary(file=destination_file,
n_ops_to_print=config.profiling.n_ops, n_ops_to_print=config.profiling.n_ops,
n_apply_to_print=config.profiling.n_apply) n_apply_to_print=config.profiling.n_apply)
if not isinstance(ps, ScanProfileStats): if not isinstance(ps, ScanProfileStats):
...@@ -109,7 +121,7 @@ def _atexit_print_fn(): ...@@ -109,7 +121,7 @@ def _atexit_print_fn():
else: else:
cum.optimizer_profile = None cum.optimizer_profile = None
cum.summary(file=_atexit_print_file, cum.summary(file=destination_file,
n_ops_to_print=config.profiling.n_ops, n_ops_to_print=config.profiling.n_ops,
n_apply_to_print=config.profiling.n_apply) n_apply_to_print=config.profiling.n_apply)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论