# Lazy import to avoid compilation when importing theano.
# Lazy import to avoid compilation when importing theano.
fromtheano.gof.cutilsimportrun_cthunk
fromtheano.gof.cutilsimportrun_cthunk# noqa
warnings.warn(
warnings.warn(
"DEPRECATION WARNING: The ProfileMode is deprecated. Use the Theano"
"DEPRECATION WARNING: The ProfileMode is deprecated. "
" flags/parameter to theano.function 'profile=True' instead"
"Use the Theano flags/parameter to theano.function "
" of 'mode=ProfileMode'")
"'profile=True' instead of 'mode=ProfileMode'")
returnret
returnret
...
@@ -115,9 +116,9 @@ class ProfileMode(Mode):
...
@@ -115,9 +116,9 @@ class ProfileMode(Mode):
message=""
message=""
profile_stats={}
profile_stats={}
self.__setstate__((linker,
self.__setstate__((linker,
optimizer,
optimizer,
message,
message,
profile_stats))
profile_stats))
deffunction_maker(self,i,o,m,*args,**kwargs):
deffunction_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"""
...
@@ -156,7 +157,7 @@ class ProfileMode(Mode):
...
@@ -156,7 +157,7 @@ class ProfileMode(Mode):
raiseRuntimeError(
raiseRuntimeError(
('A C Op raised an exception. ProfileMode cannot'
('A C Op raised an exception. ProfileMode cannot'
' tell you what it was though. Use a standard mode'
' tell you what it was though. Use a standard mode'
' such as FAST_RUN to correct the problem.'))
' such as FAST_RUN to correct the problem.'))
else:
else:
t0=time.time()
t0=time.time()
th()
th()
...
@@ -209,26 +210,43 @@ class ProfileMode(Mode):
...
@@ -209,26 +210,43 @@ class ProfileMode(Mode):
self.fn_time=0
self.fn_time=0
defprint_summary(self,**kwargs):
defprint_summary(self,**kwargs):
""" Print 3 summary that show where the time is spend. The first show an Apply-wise summary, the second show an Op-wise summary, the third show an type-Op-wise summary.
""" Print 3 summaries that show where time is spent. The first shows
an Apply-wise summary, the second an Op-wise summary and the
The Apply-wise summary print the timing information for the worst offending Apply nodes. This corresponds to individual Op applications within your graph which take the longest to execute (so if you use dot twice, you will see two entries there).
third a type-Op-wise summary.
The Op-wise summary print the execution time of all Apply nodes executing the same Op are grouped together and the total execution time per Op is shown (so if you use dot twice, you will see only one entry there corresponding to the sum of the time spent in each of them). If two Op have different hash value, they will be separate.
The type-Op-wise summary group the result by type of op. So event if two Op have different hash value, they will be merged.
The Apply-wise summary prints the timing information for the
worst offending Apply nodes. This corresponds to individual Op
Their is an hack with the Op-wise summary. Go see it if you want to know more.
applications within your graph which take the longest to
execute (so if you use dot twice, you will see two entries
there).
The Op-wise summary prints the execution time of all Apply
nodes executing the same Op grouped together and the total
execution time per Op is shown (so if you use dot twice, you
will see only one entry there corresponding to the sum of the
time spent in each of them). If two Ops have different hash
value, they will be separate.
The type-Op-wise summary group the result by type of op. So
event if two Op have different hash value, they will be
merged.
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.
:param kwargs: They are passed to print_summary_ expanded.
Currently there is n_apply_to_print, n_ops_to_print and min_memory_size
sop_cimpl={}# map each op class to Bool. True iff all applies were done in c.
# map each op class to Bool. True iff all applies were done in c.
sop_cimpl={}
fora,tinop_time.items():
fora,tinop_time.items():
typ=type(a)
typ=type(a)
sop_time.setdefault(typ,0)
sop_time.setdefault(typ,0)
...
@@ -415,8 +452,11 @@ class ProfileMode(Mode):
...
@@ -415,8 +452,11 @@ class ProfileMode(Mode):
# Print the summary per op class.
# Print the summary per op class.
print()
print()
print('Single Op-wise summary:')
print('Single Op-wise summary:')
print('<% of local_time spent on this kind of Op> <cumulative %> <self seconds> <cumulative seconds> <time per call> [*] <nb_call> <nb_op> <nb_apply> <Op name>')
print('<% of local_time spent on this kind of Op> <cumulative %> '
print('\nHACK WARNING: we print the flops for some OP, but the logic don\'t always work. You need to know the internal of Theano to make it work correctly. Otherwise don\'t use!')
print("\nHACK WARNING: we print the flops for some OP, but the "
"logic doesn't always work. You need to know the "
"internals of Theano to make it work correctly. "
"Otherwise don't use it!")
print()
print()
print('Op-wise summary:')
print('Op-wise summary:')
print('<%% of local_time spent on this kind of Op> <cumulative %%> <self seconds> <cumulative seconds> <time per call> [*] %s <nb_call> <nb apply> <Op name>'%(flops_msg))
print('<%% of local_time spent on this kind of Op> <cumulative %%> '
'<self seconds> <cumulative seconds> <time per call> [*] %s '
print('<% of local_time spent at this position> <cumulative %%> <apply time> <cumulative seconds> <time per call> [*] <nb_call> <Apply position> <Apply Op name>')
print('<% of local_time spent at this position> <cumulative %%> '