def test_elemwise_collapse4():
 shape = (4, 5)
 a = cuda_ndarray.CudaNdarray(theano._asarray(numpy.random.rand(*shape), dtype='float32'))
 a = theano._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], mode=mode_with_gpu)
 v = theano._asarray(numpy.random.rand(5, shape[0], shape[1], 4), dtype='float32')
 v = cuda_ndarray.CudaNdarray(v)
 out = f(v)[0]
 assert numpy.allclose(out, ((a.reshape(1, shape[0], shape[1], 1) + v) + 2))

def test_elemwise_collapse4 ( ) : shape = ( 4 , 5 ) a = cuda_ndarray . CudaNdarray ( theano . _asarray ( numpy . random . rand ( * shape ) , dtype = 'float32' ) ) a = theano . _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 ] , mode = mode_with_gpu ) v = theano . _asarray ( numpy . random . rand ( 5 , shape [ 0 ] , shape [ 1 ] , 4 ) , dtype = 'float32' ) v = cuda_ndarray . CudaNdarray ( v ) out = f ( v ) [ 0 ] assert numpy . allclose ( out , ( ( a . reshape ( 1 , shape [ 0 ] , shape [ 1 ] , 1 ) + v ) + 2 ) )
test when only one inputs have two broadcastable dimension at each ends and we add a scalar .