提交 c8f8a276 authored 作者: abergeron's avatar abergeron

Merge pull request #2485 from nouiz/profile

Profile fix.
...@@ -1559,6 +1559,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False, ...@@ -1559,6 +1559,7 @@ def orig_function(inputs, outputs, mode=None, accept_inplace=False,
t2 = time.time() t2 = time.time()
if profile: if profile:
profile.compile_time += t2 - t1 profile.compile_time += t2 - t1
profile.nb_nodes = len(fn.maker.fgraph.apply_nodes)
fn.name = name fn.name = name
fn.maker.fgraph.name = name fn.maker.fgraph.name = name
......
...@@ -199,6 +199,11 @@ class ProfileStats(object): ...@@ -199,6 +199,11 @@ class ProfileStats(object):
line_width = config.profiling.output_line_width line_width = config.profiling.output_line_width
nb_nodes = -1
# The number of nodes in the graph. We need the infomartion
# separatly in case we print the profile when the function wasn't
# executed or if there is lazy operation in the graph.
optimizer_profile = None optimizer_profile = None
# None or tuple (the optimizer, the profile it returned) # None or tuple (the optimizer, the profile it returned)
...@@ -637,7 +642,7 @@ class ProfileStats(object): ...@@ -637,7 +642,7 @@ class ProfileStats(object):
print >> file, ' Time in thunks: %es (%.3f%%)' % ( print >> file, ' Time in thunks: %es (%.3f%%)' % (
local_time, 100 * local_time / self.fct_call_time) local_time, 100 * local_time / self.fct_call_time)
print >> file, ' Total compile time: %es' % self.compile_time print >> file, ' Total compile time: %es' % self.compile_time
print >> file, ' Number of Apply nodes: %s' % len(self.apply_time) print >> file, ' Number of Apply nodes: %d' % self.nb_nodes
print >> file, ' Theano Optimizer time: %es' % self.optimizer_time print >> file, ' Theano Optimizer time: %es' % self.optimizer_time
print >> file, ' Theano validate time: %es' % self.validate_time print >> file, ' Theano validate time: %es' % self.validate_time
print >> file, (' Theano Linker time (includes C,' print >> file, (' Theano Linker time (includes C,'
...@@ -649,6 +654,9 @@ class ProfileStats(object): ...@@ -649,6 +654,9 @@ class ProfileStats(object):
# The validation time is a subset of optimizer_time # The validation time is a subset of optimizer_time
assert self.validate_time < self.optimizer_time assert self.validate_time < self.optimizer_time
def summary_globals(self, file):
print >> file, 'Time in all call to theano.grad() %es' % theano.gradient.grad_time
def summary_memory(self, file, N=None): def summary_memory(self, file, N=None):
fct_memory = {} # fgraph->dict(node->[outputs size]) fct_memory = {} # fgraph->dict(node->[outputs size])
fct_shapes = {} # fgraph->dict(node->[outputs shapes])) fct_shapes = {} # fgraph->dict(node->[outputs shapes]))
...@@ -1204,6 +1212,7 @@ class ProfileStats(object): ...@@ -1204,6 +1212,7 @@ class ProfileStats(object):
def summary(self, file=sys.stderr, n_ops_to_print=20, def summary(self, file=sys.stderr, n_ops_to_print=20,
n_apply_to_print=20): n_apply_to_print=20):
self.summary_function(file) self.summary_function(file)
self.summary_globals(file)
local_time = sum(self.apply_time.values()) local_time = sum(self.apply_time.values())
if local_time > 0: if local_time > 0:
self.summary_class(file, n_ops_to_print) self.summary_class(file, n_ops_to_print)
......
...@@ -804,7 +804,7 @@ def io_toposort(inputs, outputs, orderings=None): ...@@ -804,7 +804,7 @@ def io_toposort(inputs, outputs, orderings=None):
"""WRITEME """WRITEME
inputs: a list or tuple of Variable instances inputs: a list or tuple of Variable instances
outputs: a list or tuple of Variable instances outputs: a list or tuple of Apply instances
orderings: a dictionary orderings: a dictionary
key: Apply instance key: Apply instance
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论