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

fix another case of reshape and add specific test for it.

上级 823818fc
...@@ -3451,7 +3451,7 @@ class Reshape(Op): ...@@ -3451,7 +3451,7 @@ class Reshape(Op):
else: else:
bcasts = [False] * self.ndim bcasts = [False] * self.ndim
shp_list = shp_orig shp_list = shp_orig
if shp_orig.ndim==0: if hasattr(shp_orig,"ndim") and shp_orig.ndim==0:
shp_list = [shp_orig] shp_list = [shp_orig]
for index in xrange(self.ndim): for index in xrange(self.ndim):
y = shp_list[index] y = shp_list[index]
......
...@@ -2539,6 +2539,13 @@ def test_reshape(): ...@@ -2539,6 +2539,13 @@ def test_reshape():
print f.maker.env.toposort() print f.maker.env.toposort()
#check that we remove the useless reshape #check that we remove the useless reshape
#basic to 1 dim(with list)
c = reshape(b, (as_tensor_variable(6),), ndim=1)
f = inplace_func([b], c)
assert numpy.all(f(numpy.asarray([[0,1,2],[3,4,5]])) == numpy.asarray([0,1,2,3,4,5]))
print f.maker.env.toposort()
#check that we remove the useless reshape
#basic to shape object of same ndim #basic to shape object of same ndim
c = reshape(b,d.shape) c = reshape(b,d.shape)
f = inplace_func([b,d], c) f = inplace_func([b,d], c)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论