def test_pycuda_theano():
 from pycuda.compiler import SourceModule
 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')
 multiply_them = mod.get_function('multiply_them')
 a = numpy.random.randn(100).astype(numpy.float32)
 b = numpy.random.randn(100).astype(numpy.float32)
 ga = cuda_ndarray.CudaNdarray(a)
 gb = cuda_ndarray.CudaNdarray(b)
 dest = cuda_ndarray.CudaNdarray.zeros(a.shape)
 multiply_them(dest, ga, gb, block=(400, 1, 1), grid=(1, 1))
 assert (numpy.asarray(dest) == (a * b)).all()

def test_pycuda_theano ( ) : from pycuda . compiler import SourceModule 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' ) multiply_them = mod . get_function ( 'multiply_them' ) a = numpy . random . randn ( 100 ) . astype ( numpy . float32 ) b = numpy . random . randn ( 100 ) . astype ( numpy . float32 ) ga = cuda_ndarray . CudaNdarray ( a ) gb = cuda_ndarray . CudaNdarray ( b ) dest = cuda_ndarray . CudaNdarray . zeros ( a . shape ) multiply_them ( dest , ga , gb , block = ( 400 , 1 , 1 ) , grid = ( 1 , 1 ) ) assert ( numpy . asarray ( dest ) == ( a * b ) ) . all ( )
simple example with pycuda function and theano cudandarray object .