提交 e684f824 authored 作者: Frederic Bastien's avatar Frederic Bastien

bugfix in Alloc.perform(). This bug happen if their was inplace modification to…

bugfix in Alloc.perform(). This bug happen if their was inplace modification to the output of Alloc. It was not reset. Check how and when to use destroy_map to don't copy to it too often.
上级 c2b33a27
...@@ -1787,8 +1787,9 @@ class Alloc(gof.Op): ...@@ -1787,8 +1787,9 @@ class Alloc(gof.Op):
v = inputs[0] v = inputs[0]
sh = tuple([int(i) for i in inputs[1:]]) sh = tuple([int(i) for i in inputs[1:]])
if out[0] is None or out[0].shape != sh: if out[0] is None or out[0].shape != sh:
# out[0] = numpy.empty(sh, dtype=v.dtype)
out[0] = numpy.zeros(sh, dtype=v.dtype) out[0] = numpy.zeros(sh, dtype=v.dtype)
out[0][...] += v # broadcast v to fill us up out[0][...] = v # broadcast v to fill us up
def grad(self, inputs, (gout,)): def grad(self, inputs, (gout,)):
return [None for i in inputs] return [None for i in inputs]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论