提交 36f94424 authored 作者: Frederic Bastien's avatar Frederic Bastien

Add the offset information in the memory profile

上级 df16dbcc
......@@ -89,6 +89,7 @@ def _atexit_print_fn():
# merge dictonary
for attr in ["apply_time", "apply_callcount",
"apply_cimpl", "variable_shape", "variable_strides",
"variable_offset",
"linker_make_thunk_time"]:
cum_attr = getattr(cum, attr)
for key, val in iteritems(getattr(ps, attr)):
......@@ -229,6 +230,10 @@ class ProfileStats(object):
# Variable -> strides
#
variable_offset = {}
# Variable -> offset
#
optimizer_time = 0.0
# time spent optimizing graph (FunctionMaker.__init__)
......@@ -295,6 +300,7 @@ class ProfileStats(object):
self.apply_cimpl = {}
self.variable_shape = {}
self.variable_strides = {}
self.variable_offset = {}
if flag_time_thunks is None:
self.flag_time_thunks = config.profiling.time_thunks
else:
......@@ -697,15 +703,21 @@ class ProfileStats(object):
for idx, var in enumerate(a.inputs):
sh = self.variable_shape.get(var, 'no shape')
st = self.variable_strides.get(var, 'no strides')
off = self.variable_offset.get(var, '')
if off != '':
off = ", offset=%s" % off
dtype = getattr(var, 'dtype', 'no dtype')
print(" input %d: dtype=%s, shape=%s, strides=%s " % (
idx, dtype, sh, st), file=file)
print(" input %d: dtype=%s, shape=%s, strides=%s%s" % (
idx, dtype, sh, st, off), file=file)
for idx, var in enumerate(a.outputs):
sh = self.variable_shape.get(var, 'no shape')
st = self.variable_strides.get(var, 'no strides')
off = self.variable_offset.get(var, '')
if off != '':
off = ", offset=%s" % off
dtype = getattr(var, 'dtype', 'no dtype')
print(" output %d: dtype=%s, shape=%s, strides=%s " % (
idx, dtype, sh, st), file=file)
print(" output %d: dtype=%s, shape=%s, strides=%s%s" % (
idx, dtype, sh, st, off), file=file)
# Same as before, this I've sacrificied some information making
# the output more readable
print(' ... (remaining %i Apply instances account for '
......
......@@ -207,6 +207,7 @@ class VM(object):
if hasattr(self, 'variable_shape'):
profile.variable_shape = self.variable_shape.copy()
profile.variable_strides = self.variable_strides.copy()
profile.variable_offset = self.variable_offset.copy()
if hasattr(self, 'node_executed_order'):
profile.node_executed_order = self.node_executed_order[:]
......@@ -342,6 +343,7 @@ class Stack(VM):
self.storage_map = storage_map
self.variable_shape = {} # Variable -> shape
self.variable_strides = {} # Variable -> strides
self.variable_offset = {} # Variable -> offset
self.compute_map = compute_map
self.node_idx = node_idx = {}
self.callback = callback
......@@ -445,6 +447,8 @@ class Stack(VM):
data[0].is_c_contiguous()):
st = "c"
self.variable_strides[var] = st
off = getattr(data[0], 'offset', '')
self.variable_offset[var] = off
while apply_stack:
# Make sure something happened last time round. This is
......@@ -506,6 +510,8 @@ class Stack(VM):
data[0].is_c_contiguous()):
st = "c"
self.variable_strides[var] = st
off = getattr(o[0], 'offset', '')
self.variable_offset[var] = off
except Exception:
link.raise_with_op(
current_apply,
......@@ -614,6 +620,8 @@ class Stack(VM):
data[0].is_c_contiguous()):
st = "c"
self.variable_strides[var] = st
off = getattr(o[0], 'offset', '')
self.variable_offset[var] = off
input_index = []
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论