#NEWLINE# def test_elemwise_collapse2( ) : #NEWLINE# #INDENT# ' Test when only one inputs have one broadcastable dimension ' #NEWLINE# shape = ( 4 , 5 , 9 ) #NEWLINE# a = cuda_ndarray . CudaNdarray ( theano . _asarray ( numpy . random . rand ( * shape ) , dtype = 'float32' ) ) #NEWLINE# a = theano . _asarray ( numpy . random . rand ( * shape ) , dtype = 'float32' ) #NEWLINE# a2 = tcn . shared_constructor ( a , 'a' ) #NEWLINE# a3 = a2 . dimshuffle ( 0 , 'x' , 1 , 2 ) #NEWLINE# b = tcn . CudaNdarrayType ( ( False , False , False , False ) ) ( ) #NEWLINE# c = ( a3 + b ) #NEWLINE# f = pfunc ( [ b ] , [ c ] , mode = mode_with_gpu ) #NEWLINE# v = theano . _asarray ( numpy . random . rand ( shape [ 0 ] , 5 , * shape [ 1 : ] ) , dtype = 'float32' ) #NEWLINE# v = cuda_ndarray . CudaNdarray ( shape ) #NEWLINE# out = f ( v ) [ 0 ] #NEWLINE# assert numpy . allclose ( out , ( a . reshape ( shape [ 0 ] , 1 , * shape [ 1 : ] ) + v ) )