提交 586eccbb authored 作者: Frederic Bastien's avatar Frederic Bastien

added test for collapse of dims and scalar.

上级 67ff432e
......@@ -202,6 +202,27 @@ def test_elemwise_collapse3():
f = pfunc([b], [c])
v = numpy.asarray(numpy.random.rand(5,shape[0],shape[1],4),dtype='float32')
v=cuda_ndarray.CudaNdarray(v)
for id,n in enumerate(f.maker.env.toposort()):
print id, n
#let debugmode catch errors
f(v)
print "Expected collapse to 3 dimensions"
def test_elemwise_collapse4():
""" used to test if the case where one inputs have 2 broadcast dimensions at each ends and a scalar"""
shape = (4,5)
a = cuda_ndarray.CudaNdarray(numpy.asarray(numpy.random.rand(*shape),dtype='float32'))
a = numpy.asarray(numpy.random.rand(*shape),dtype='float32')
a2 = tcn.shared_constructor(a, 'a')
a3 = a2.dimshuffle('x',0,1,'x')
b = tcn.CudaNdarrayType((False, False, False, False))()
c = (a3+b+2)
f = pfunc([b], [c])
v = numpy.asarray(numpy.random.rand(5,shape[0],shape[1],4),dtype='float32')
v=cuda_ndarray.CudaNdarray(v)
for id,n in enumerate(f.maker.env.toposort()):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论