提交 8d57251e authored 作者: Iban Harlouchet's avatar Iban Harlouchet

numpydoc for theano/compile/profilemode.py

上级 8129b741
......@@ -122,7 +122,10 @@ class ProfileMode(Mode):
profile_stats))
def function_maker(self, i, o, m, *args, **kwargs):
"""Return an instance of `Profiler_Maker` which init the count"""
"""
Return an instance of `Profiler_Maker` which init the count.
"""
assert m is self
return Profile_Maker(i, o, self, *args, **kwargs)
......@@ -147,7 +150,9 @@ class ProfileMode(Mode):
self.profile_stats = profile_stats
def profile_thunk(i, node, th):
""" Profile only the execution time
"""
Profile only the execution time.
"""
global run_cthunk
if hasattr(th, 'cthunk'):
......@@ -169,7 +174,9 @@ class ProfileMode(Mode):
self.apply_time[node] += max(dt, 1e-14)
def profile_thunk2(i, node, th):
""" Profile the execution time and the memory size.
"""
Profile the execution time and the memory size.
"""
global run_cthunk
if hasattr(th, 'cthunk'):
......@@ -211,7 +218,8 @@ class ProfileMode(Mode):
self.fn_time = 0
def print_summary(self, **kwargs):
""" Print 3 summaries that show where time is spent. The first shows
"""
Print 3 summaries that show where time is spent. The first shows
an Apply-wise summary, the second an Op-wise summary and the
third a type-Op-wise summary.
......@@ -235,10 +243,13 @@ class ProfileMode(Mode):
There is an hack with the Op-wise summary. Go see it if you
want to know more.
:param kwargs: They are passed to print_summary_ expanded.
Currently there is n_apply_to_print,
n_ops_to_print and min_memory_size that are
accepted.
Parameters
----------
kwargs
They are passed to print_summary_ expanded. Currently there is
n_apply_to_print, n_ops_to_print and min_memory_size that are
accepted.
"""
compile_time = sum([ps.compile_time for ps
in self.profile_stats.values()])
......@@ -280,18 +291,23 @@ class ProfileMode(Mode):
**kwargs)
def print_diff_summary(self, other, **kwargs):
""" As print_summary, but print the difference on two different
"""
As print_summary, but print the difference on two different
profile mode.
TODO: Also we don't print the Apply-wise summary as it don't
work for now.
TODO: make comparaison with gpu code.
:param other: the other instance of ProfileMode that we want
to be compared to.
:param kwargs: They are passed to print_summary_ expanded.
Parameters
----------
other
The other instance of ProfileMode that we want to be compared to.
kwargs
They are passed to print_summary_ expanded.
Currently there is n_apply_to_print, n_ops_to_print and
min_memory_size that are accepted.
"""
def diff_dict(a_time, b_time_):
......@@ -343,13 +359,18 @@ class ProfileMode(Mode):
min_memory_size=config.ProfileMode.min_memory_size,
):
"""
do the actual printing of print_summary and print_diff_summary.
:param n_apply_to_print: the number of apply to print. Default 15.
Do the actual printing of print_summary and print_diff_summary.
Parameters
----------
n_apply_to_print
The number of apply to print. Default 15.
n_ops_to_print
The number of ops to print. Default 20.
min_memory_size
Don't print memory profile of apply whose outputs memory size is
lower than that.
:param n_ops_to_print: the number of ops to print. Default 20.
:param min_memory_size: Don't print memory profile of apply
whose outputs memory size is lower then that.
"""
print("ProfileMode is deprecated! Use the new profiler.")
......@@ -700,9 +721,9 @@ Test them first, as they are not guaranteed to always provide a speedup.""")
"""
Create a new instance of this Mode.
Keyword arguments can be provided for the linker,
in which case its `clone` method will be called with these
arguments.
Keyword arguments can be provided for the linker, in which case its
`clone` method will be called with these arguments.
"""
new_linker = self.linker.clone(**link_kwargs)
new_optimizer = self.provided_optimizer
......@@ -727,10 +748,11 @@ prof_mode_instance_to_print = [predefined_modes["PROFILE_MODE"]]
def atexit_print_default_profile_mode():
"""Print the summary of the predefined mode ProfileMode if used.
"""
Print the summary of the predefined mode ProfileMode if used.
This all to have the summary printed at exit when config.mode=ProfileMode.
This all to have the summary printed at exit when
config.mode=ProfileMode
"""
for prof_mode in prof_mode_instance_to_print:
if prof_mode.local_time > 0:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论