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

Fix code revice comments and add a message.

上级 57a65772
...@@ -626,7 +626,7 @@ class ProfileStats(object): ...@@ -626,7 +626,7 @@ class ProfileStats(object):
v = out.type.get_size(sh) v = out.type.get_size(sh)
sum_dense += v sum_dense += v
else: else:
v = "Unknow" v = "Unknown"
var_mem[out] = v var_mem[out] = v
fct_memory[node.fgraph][node].append(v) fct_memory[node.fgraph][node].append(v)
...@@ -778,12 +778,16 @@ class ProfileStats(object): ...@@ -778,12 +778,16 @@ class ProfileStats(object):
else: else:
p = "(%.2f%%)" % (float(sum_remaining) / size_sum_dense * 100) p = "(%.2f%%)" % (float(sum_remaining) / size_sum_dense * 100)
print >> file, ( print >> file, (
' ... (remaining %i Apply account for %4dB/%dB (%s) of' ' ... (remaining %i Apply account for %4dB/%dB (%s) of the'
' the Apply with dense outputs sizes)') % (max(0, len(node_mem) - N), ' Apply with dense outputs sizes)') % (max(0, len(node_mem) - N),
sum_remaining, sum_remaining,
size_sum_dense, p size_sum_dense, p
) )
print >> file, '' print >> file, ''
if N == 0:
print >> file, (' All Apply node have outputs size that take'
' less then %dB.' %
config.profiling.min_memory_size)
print >> file, ( print >> file, (
" <created/inplace/view> is taked from the op declaration.") " <created/inplace/view> is taked from the op declaration.")
print >> file, (" Apply nodes marked 'inplace' or 'view' may" print >> file, (" Apply nodes marked 'inplace' or 'view' may"
......
...@@ -421,7 +421,10 @@ class CudaNdarrayType(Type): ...@@ -421,7 +421,10 @@ class CudaNdarrayType(Type):
return obj.shape return obj.shape
def get_size(self, shape_info): def get_size(self, shape_info):
return numpy.prod(shape_info, dtype=int) * numpy.dtype(self.dtype).itemsize if shape_info:
return numpy.prod(shape_info) * numpy.dtype(self.dtype).itemsize
else: # a scalar
return numpy.dtype(self.dtype).itemsize
theano.compile.ops.expandable_types += (CudaNdarrayType,) theano.compile.ops.expandable_types += (CudaNdarrayType,)
......
...@@ -1209,8 +1209,10 @@ class TensorType(Type): ...@@ -1209,8 +1209,10 @@ class TensorType(Type):
:return: the number of bytes taken by the object described in :return: the number of bytes taken by the object described in
shape_info. shape_info.
""" """
return numpy.prod(shape_info, if shape_info:
dtype=int) * numpy.dtype(self.dtype).itemsize return numpy.prod(shape_info) * numpy.dtype(self.dtype).itemsize
else: # a scalar
return numpy.dtype(self.dtype).itemsize
theano.compile.ops.expandable_types += (TensorType,) theano.compile.ops.expandable_types += (TensorType,)
# Register TensorType C code for ViewOp. # Register TensorType C code for ViewOp.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论