提交 9a1e8ce4 authored 作者: Frederic Bastien's avatar Frederic Bastien

added test for the futur version of elemwise with the collapsing of dimensions.

上级 966cda36
...@@ -143,3 +143,43 @@ def speed_elemwise_collapse(): ...@@ -143,3 +143,43 @@ def speed_elemwise_collapse():
#let debugmode catch errors #let debugmode catch errors
f(v) f(v)
t2=time.time() t2=time.time()
def test_elemwise_collapse():
""" used to test if the case where all inputs are broadcast """
shape = (4,5,60)
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(0,'x',1,2)
b = tcn.CudaNdarrayType((False, True, False, False))()
c = a3+b * tensor.exp(1 + b**a3)
f = pfunc([b], [c])
v = numpy.asarray(numpy.random.rand(shape[0],1,*shape[1:]),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)
def test_elemwise_collapse2():
""" used to test if the case where some inputs are broadcast """
shape = (4,5,60)
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(0,'x',1,2)
b = tcn.CudaNdarrayType((False, False, False, False))()
c = a3+b * tensor.exp(1 + b**a3)
f = pfunc([b], [c])
v = numpy.asarray(numpy.random.rand(shape[0],5,*shape[1:]),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)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论