提交 37bf28f6 authored 作者: Frederic's avatar Frederic

Allow to do a debugprint of the profiled function

上级 79ce0fba
...@@ -360,6 +360,14 @@ import theano and print the config variable, as in: ...@@ -360,6 +360,14 @@ import theano and print the config variable, as in:
The profiling output can be either directed to stderr The profiling output can be either directed to stderr
(default), or stdout or an arbitrary file. (default), or stdout or an arbitrary file.
.. attribute:: config.profiling.debugprint
Bool value: either True or False
Default False
Do a debugprint of the profiled functions
.. attribute:: config.lib.amdlibm .. attribute:: config.lib.amdlibm
Bool value: either True or False Bool value: either True or False
......
...@@ -76,6 +76,13 @@ AddConfigVar('profiling.destination', ...@@ -76,6 +76,13 @@ AddConfigVar('profiling.destination',
StrParam('stderr'), StrParam('stderr'),
in_c_key=False) in_c_key=False)
AddConfigVar('profiling.debugprint',
"""
Do a debugprint of the profiled functions
""",
BoolParam(False),
in_c_key=False)
def _atexit_print_fn(): def _atexit_print_fn():
""" """
...@@ -1285,6 +1292,9 @@ class ProfileStats(object): ...@@ -1285,6 +1292,9 @@ class ProfileStats(object):
elif self.fct_callcount > 0: elif self.fct_callcount > 0:
print(" No execution time accumulated " print(" No execution time accumulated "
"(hint: try config profiling.time_thunks=1)", file=file) "(hint: try config profiling.time_thunks=1)", file=file)
if config.profiling.debugprint:
fcts = set([n.fgraph for n in self.apply_time.keys()])
theano.printing.debugprint(fcts, print_type=True)
if self.variable_shape or self.variable_strides: if self.variable_shape or self.variable_strides:
self.summary_memory(file, n_apply_to_print) self.summary_memory(file, n_apply_to_print)
if self.optimizer_profile: if self.optimizer_profile:
......
...@@ -102,7 +102,7 @@ def debugprint(obj, depth=-1, print_type=False, ...@@ -102,7 +102,7 @@ def debugprint(obj, depth=-1, print_type=False,
results_to_print = [] results_to_print = []
profile_list = [] profile_list = []
order = [] order = []
if isinstance(obj, (list, tuple)): if isinstance(obj, (list, tuple, set)):
lobj = obj lobj = obj
else: else:
lobj = [obj] lobj = [obj]
...@@ -120,7 +120,8 @@ def debugprint(obj, depth=-1, print_type=False, ...@@ -120,7 +120,8 @@ def debugprint(obj, depth=-1, print_type=False,
order = obj.maker.fgraph.toposort() order = obj.maker.fgraph.toposort()
elif isinstance(obj, gof.FunctionGraph): elif isinstance(obj, gof.FunctionGraph):
results_to_print.extend(obj.outputs) results_to_print.extend(obj.outputs)
profile_list.extend([None for item in obj.outputs]) profile_list.extend([getattr(obj, 'profile', None)
for item in obj.outputs])
order = obj.toposort() order = obj.toposort()
elif isinstance(obj, (integer_types, float, np.ndarray)): elif isinstance(obj, (integer_types, float, np.ndarray)):
print(obj) print(obj)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论