#NEWLINE# def test2( shape = ( 3 , 4 , 5 ) ) : #NEWLINE# #INDENT# '\n    Make sure that the gnumpy conversion is exact from CudaNdarray to\n    garray back to CudaNdarray.\n    ' #NEWLINE# gpu = theano . sandbox . cuda . basic_ops . gpu_from_host #NEWLINE# U = gpu ( theano . tensor . ftensor3 ( 'U' ) ) #NEWLINE# ii = theano . function ( [ U ] , gpu ( ( U + 1 ) ) ) #NEWLINE# A = numpy . random . rand ( * shape ) . astype ( 'float32' ) #NEWLINE# A_cnd = theano . sandbox . cuda . CudaNdarray ( A ) #NEWLINE# A_gar = cudandarray_to_garray ( A_cnd ) #NEWLINE# assert ( A_cnd . shape == A_gar . shape ) #NEWLINE# B = garray_to_cudandarray ( A_gar ) #NEWLINE# assert ( A_cnd . shape == B . shape ) #NEWLINE# assert ( A_cnd . _strides == A . _strides ) #NEWLINE# assert ( A_cnd . gpudata == B . gpudata ) #NEWLINE# v = numpy . asarray ( B ) #NEWLINE# assert ( v == A ) . all ( )