提交 6d0936fc authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Do not copy non-destroyed inputs.

上级 10535543
...@@ -1199,8 +1199,11 @@ def _check_preallocated_output(node, thunk, prealloc_modes, def_val, ...@@ -1199,8 +1199,11 @@ def _check_preallocated_output(node, thunk, prealloc_modes, def_val,
node, thunk, prealloc_modes, def_val, storage_map, r_vals, node, thunk, prealloc_modes, def_val, storage_map, r_vals,
dr_vals, perform, active_order_set): dr_vals, perform, active_order_set):
_logger.debug(' name = %s', name) _logger.debug(' name = %s', name)
# Copy the inputs over again
for r in node.inputs: # Copy the inputs over, if they were marked as destroyed
dmap = getattr(node.op, 'destroy_map', {})
for i, r in enumerate(node.inputs):
if any(i in v for v in dmap.values()):
storage_map[r][0] = _lessbroken_deepcopy(r_vals[r]) storage_map[r][0] = _lessbroken_deepcopy(r_vals[r])
# Get the appropriate output storages # Get the appropriate output storages
...@@ -1742,7 +1745,8 @@ class _Linker(gof.link.LocalLinker): ...@@ -1742,7 +1745,8 @@ class _Linker(gof.link.LocalLinker):
clobber = True clobber = True
if thunk_py: if thunk_py:
for r in node.inputs: dmap = getattr(node.op, 'destroy_map', {})
for i, r in enumerate(node.inputs):
# if thunk_py ran, and we still got this far, # if thunk_py ran, and we still got this far,
# it means that the destroy_map of the Op (and view_map) are # it means that the destroy_map of the Op (and view_map) are
# accurate # accurate
...@@ -1750,14 +1754,7 @@ class _Linker(gof.link.LocalLinker): ...@@ -1750,14 +1754,7 @@ class _Linker(gof.link.LocalLinker):
# fact not been destroyed. # fact not been destroyed.
# Therefore... we only need to overwrite inputs that *have* # Therefore... we only need to overwrite inputs that *have*
# been marked as destroyed. # been marked as destroyed.
if any(i in v for v in dmap.values()):
#TODO: The following was tried on revision 6c613932a63c,
# and made lots of tests fail, some complaining about
# AttributeError: 'Env' object has no attribute 'destroyers'
# some giving plain wrong numerical results.
#if env.destroyers(r):
# storage_map[r][0] = _lessbroken_deepcopy(r_vals[r])
storage_map[r][0] = _lessbroken_deepcopy(r_vals[r]) storage_map[r][0] = _lessbroken_deepcopy(r_vals[r])
clobber = False clobber = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论