提交 235b6d99 authored 作者: Frederic Bastien's avatar Frederic Bastien

merge

...@@ -2213,8 +2213,13 @@ class Alloc(gof.Op): ...@@ -2213,8 +2213,13 @@ 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) if v.size == 1 and v.item() == 0:
out[0] = numpy.zeros(sh, dtype=v.dtype) out[0] = numpy.zeros(sh, dtype=v.dtype)
else:
out[0] = numpy.empty(sh, dtype=v.dtype)
out[0][...] = v # broadcast v to fill us up
else:
#reuse the allocated memory.
out[0][...] = v # broadcast v to fill us up out[0][...] = v # broadcast v to fill us up
def infer_shape(self, node, input_shapes): def infer_shape(self, node, input_shapes):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论