#NEWLINE# def test_pycuda_theano( ) : #NEWLINE# #INDENT# 'Simple example with pycuda function and Theano CudaNdarray object.' #NEWLINE# from pycuda.compiler import SourceModule #NEWLINE# mod = SourceModule ( '\n__global__ void multiply_them(float *dest, float *a, float *b)\n{\n  const int i = threadIdx.x;\n  dest[i] = a[i] * b[i];\n}\n' ) #NEWLINE# multiply_them = mod . get_function ( 'multiply_them' ) #NEWLINE# a = numpy . random . randn ( 100 ) . astype ( numpy . float32 ) #NEWLINE# b = numpy . random . randn ( 100 ) . astype ( numpy . float32 ) #NEWLINE# ga = cuda_ndarray . CudaNdarray ( a ) #NEWLINE# gb = cuda_ndarray . CudaNdarray ( b ) #NEWLINE# dest = cuda_ndarray . CudaNdarray . zeros ( gb . shape ) #NEWLINE# multiply_them ( dest , ga , gb , block = ( 400 , 1 , 1 ) , grid = ( 1 , 1 ) ) #NEWLINE# assert ( numpy . asarray ( dest ) == ( a * b ) ) . all ( )