<s> import parakeet <EOL> import numpy as np <EOL> def matmult_high_level ( X , Y ) : <EOL> return np . array ( [ [ np . dot ( x , y ) for y in Y . T ] for x in X ] ) <EOL> n , d , m = <NUM_LIT> , <NUM_LIT> , <NUM_LIT> <EOL> dtype = '<STR_LIT>' <EOL> X = np . random . randn ( m , d ) . astype ( dtype ) <EOL> Y = np . random . randn ( d , n ) . astype ( dtype ) <EOL> from compare_perf import compare_perf <EOL> extra = { '<STR_LIT>' : np . dot } <EOL> try : <EOL> import pycuda <EOL> import pycuda . gpuarray <EOL> import pycuda . autoinit <EOL> import scikits . cuda . linalg <EOL> import scikits . cuda . cublas <EOL> cublas_context = scikits . cuda . cublas . cublasCreate ( ) <EOL> def gpu_dot ( X , Y ) : <EOL> X_gpu = pycuda . gpuarray . to_gpu ( X ) <EOL> Y_gpu = pycuda . gpuarray . to_gpu ( Y ) <EOL> Z_gpu = scikits . cuda . linalg . dot ( X_gpu , Y_gpu , '<STR_LIT:N>' , '<STR_LIT:N>' , handle = cublas_context ) <EOL> return Z_gpu . get ( ) <EOL> extra [ '<STR_LIT>' ] = gpu_dot <EOL> except : <EOL> print "<STR_LIT>" <EOL> try : <EOL> import numba <EOL> @ numba . autojit <EOL> def matmult_loops ( X , Y , Z ) : <EOL> m , d = X . shape <EOL> n = Y . shape [ <NUM_LIT:1> ] <EOL> for i in xrange ( m ) : <EOL> for j in xrange ( n ) : <EOL> total = X [ i , <NUM_LIT:0> ] * Y [ <NUM_LIT:0> , j ] <EOL> for k in xrange ( <NUM_LIT:1> , d ) : <EOL> total += X [ i , k ] * Y [ k , j ] <EOL> Z [ i , j ] = total <EOL> def call_numba ( X , Y ) : <EOL> Z = np . zeros ( ( X . shape [ <NUM_LIT:0> ] , Y . shape [ <NUM_LIT:1> ] ) ) . astype ( dtype ) <EOL> matmult_loops ( X , Y , Z ) <EOL> return Z <EOL> extra [ '<STR_LIT>' ] = call_numba <EOL> except : <EOL> print "<STR_LIT>" <EOL> pass <EOL> compare_perf ( matmult_high_level , [ X , Y ] , <EOL> cpython = True , <EOL> numba = False , <EOL> extra = extra , <EOL> suppress_output = False , <EOL> propagate_exceptions = False ) </s>
