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

Work around a bug with ndarray.resize(shape) when the shape contain 0.

This fix a failing test.
上级 c4698740
......@@ -733,6 +733,11 @@ class Elemwise(Op):
# always return an ndarray with dtype object
variable = numpy.asarray(variable, dtype=nout.dtype)
if hasattr(variable,'shape') and storage[0].shape != variable.shape:
if numpy.prod(variable.shape) == 0:
# numpy don't resize from a shape (1,5) to (0,5)
# This bypass the inplace... But I it is important in this case.
storage[0] = variable
continue
storage[0].resize(variable.shape)
if storage[0].shape:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论