提交 770f9d2c authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Add test for new behaviour of the .base attribute of CudaNdarray

上级 44d8dea1
...@@ -816,6 +816,24 @@ def test_zeros_basic_vector(): ...@@ -816,6 +816,24 @@ def test_zeros_basic_vector():
assert numpy.allclose(numpy.asarray(_a), numpy.zeros((300,))) assert numpy.allclose(numpy.asarray(_a), numpy.zeros((300,)))
def test_base():
# Test that the 'base' attribute of a CudaNdarray is the one
# built initially, not an intermediate one.
a = cuda_ndarray.CudaNdarray.zeros((3,4,5))
for i in xrange(5):
b = a[:]
assert b.base is a
c = a[0]
d = c[:,0]
print d.shape
assert c.base is a
assert d.base is a
e = b.reshape((5,2,2,3))
assert e.base is a
if __name__ == '__main__': if __name__ == '__main__':
test_zeros_basic_3d_tensor() test_zeros_basic_3d_tensor()
test_zeros_basic_vector() test_zeros_basic_vector()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论