提交 cb22e69d authored 作者: Frederic's avatar Frederic

Remove the old hack for flops computation now as it collide with the new one.…

Remove the old hack for flops computation now as it collide with the new one. They reuse the flops attribute.
上级 5b1bb8a7
......@@ -292,32 +292,6 @@ class ProfileStats(object):
rval[node.op] = 'Py'
return rval
def op_flops(self):
"""dict op -> total number of flops"""
# timing is stored by node, we compute timing by Op on demand
rval = {}
return rval # TODO: continue here
for node, count in self.apply_callcount.items():
rval.setdefault(node.op, 0)
rval[node.op] += 1
return rval
for a, t in self.op_time.items():
if hasattr(a, 'flops'):
op_flops[a] = a.flops * op_call[a] / t / 1e6
flops_msg = ''
if op_flops:
flops_msg = ' <MFlops/s>'
print ('\nHACK WARNING: we print the flops for some OP, but the'
' logic does not always work. You need to know the internal'
' of Theano to make it work correctly.'
' Otherwise don\'t use!')
print ('\nOp-wise summary:'
' <%% 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))
def summary_class(self, file=sys.stderr, N=None):
if self.apply_time:
local_time = sum(self.apply_time.values())
......@@ -330,7 +304,6 @@ class ProfileStats(object):
class_time = self.class_time()
class_call = self.class_callcount()
class_apply = self.class_nodes()
# class_flops = self.class_flops()
class_impl = self.class_impl()
if N is None:
N = len(self.class_time)
......@@ -395,12 +368,6 @@ class ProfileStats(object):
# While this carries over less information, it is arranged such
# that it way more readeable that the previous output of the
# profiler
#if op_flops:
# print >>file, ' %4.1f%% %5.1f%% %5.3fs %5.3fs %.2es %s %7.1f %5d %2d %s' % (
# f, ftot, t, tot, t/nb_call, impl, op_flops.get(a,-1), nb_call, nb_apply, a)
#else:
# print >>file, ' %4.1f%% %5.1f%% %5.3fs %5.3fs %.2es %s %5d %2d %s' % (
# f, ftot, t, tot, t/nb_call, impl, nb_call, nb_apply, a)
print >>file, ' ... (remaining %i Classes account for %6.2f%%(%.2fs) of the runtime)'\
% (max(0, len(otimes) - N),
sum(f for f, t, a, ci, nb_call, nb_op in otimes[N:]),
......@@ -419,10 +386,7 @@ class ProfileStats(object):
op_time = self.op_time()
op_call = self.op_callcount()
op_apply = self.op_nodes()
op_flops = self.op_flops()
op_impl = self.op_impl()
if N is None:
N = len(self.op_flops)
otimes = [(t * 100 / local_time,
t,
op,
......@@ -484,12 +448,6 @@ class ProfileStats(object):
# While this carries over less information, it is arranged such
# that it way more readeable that the previous output of the
# profiler
#if op_flops:
# print >>file, ' %4.1f%% %5.1f%% %5.3fs %5.3fs %.2es %s %7.1f %5d %2d %s' % (
# f, ftot, t, tot, t/nb_call, impl, op_flops.get(a,-1), nb_call, nb_apply, a)
#else:
# print >>file, ' %4.1f%% %5.1f%% %5.3fs %5.3fs %.2es %s %5d %2d %s' % (
# f, ftot, t, tot, t/nb_call, impl, nb_call, nb_apply, a)
print >>file, ' ... (remaining %i Ops account for %6.2f%%(%.2fs) of the runtime)'\
% (max(0, len(otimes) - N),
sum(f for f, t, a, ci, nb_call, nb_op in otimes[N:]),
......
......@@ -537,8 +537,6 @@ class ConvOp(OpenMPOp):
time_unroll_batch_kern)
self._rehash()
if config.op.set_flops:
self.set_flops()
def __eq__(self, other):
if type(self) != type(other):
......@@ -567,44 +565,6 @@ class ConvOp(OpenMPOp):
return "ConvOp{" + ",".join(str((a, getattr(self, a)))
for a in self.__attrnames) + "}"
def set_flops(self):
""" Useful with the hack in profilemode to print the MFlops"""
if self.out_mode == "valid":
# nb mul and add by output pixed
self.flops = self.kshp[0] * self.kshp[1] * 2
#nb flops by output image
self.flops *= self.outshp[0] * self.outshp[1]
# for all outputs images#n_stack==self.imshp[0]
self.flops *= self.imshp[0] * self.nkern * self.bsize
else: # full mode not implemented
self.flops = 0
for out_row in xrange(self.outshp[0]): # loop over output row
for out_col in xrange(self.outshp[0]): # loop over output col
for row in xrange(self.kshp[0]): # loop over kern row
if (row + out_row - self.kshp[0] + 1 < 0 or
row + out_row - self.kshp[0] + 1 >= self.imshp[1]):
continue
col = 0
max_col = self.kshp[1]
img_col = out_col - self.kshp[1] + 1
max_col = min(max_col, self.imshp[2] - img_col)
if img_col < 0:
col = -img_col
img_col += col
while col < max_col: # loop over kern col
self.flops += 2
col += 1
# for all outputs images#n_stack==self.imshp[0]
self.flops *= self.imshp[0] * self.nkern * self.bsize
assert self.flops == self.bsize * self.nkern * self.imshp[0] * \
self.kshp[0] * self.kshp[1] * \
self.imshp[1] * self.imshp[2] * 2
def flops(self, inputs, outputs):
""" Useful with the hack in profilemode to print the MFlops"""
images, kerns = inputs
......@@ -936,9 +896,6 @@ class ConvOp(OpenMPOp):
version=self.version,
verbose=self.verbose)
if hasattr(self, 'flops'):
dw.set_flops()
dw = dw(img, filters)
if all_shape:
......@@ -985,9 +942,6 @@ class ConvOp(OpenMPOp):
version=-1, # we we change the mode, we don't forward the version.
verbose=self.verbose)
if hasattr(self, 'flops'):
din.set_flops()
din = din(gz, filters)
assert (din.owner.op.outshp is None and self.imshp is None) or \
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论