提交 823818fc authored 作者: Frederic Bastien's avatar Frederic Bastien

fix bug that disabled fonctionnality in Reshape that broke the buildbot. Add…

fix bug that disabled fonctionnality in Reshape that broke the buildbot. Add specifig test about it.
上级 350f5b6b
......@@ -3451,7 +3451,7 @@ class Reshape(Op):
else:
bcasts = [False] * self.ndim
shp_list = shp_orig
if not isinstance(shp_orig,(list,tuple)):
if shp_orig.ndim==0:
shp_list = [shp_orig]
for index in xrange(self.ndim):
y = shp_list[index]
......
......@@ -2530,14 +2530,20 @@ def test_reshape():
a = dvector()
b = dmatrix()
d = dmatrix()
#basic to 1 dim
#basic to 1 dim(without 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
c = reshape(b,d.shape)
f = inplace_func([b,d], c)
assert numpy.all(f(numpy.asarray([[0,1,2],[3,4,5]]),[[0,1],[2,3],[4,5]]) == numpy.asarray([[0,1],[2,3],[4,5]]))
#basic to 2 dims
c = reshape(a, [2,3])
f = inplace_func([a], c)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论