Skip to content

Instantly share code, notes, and snippets.

@bayerj
Last active December 30, 2015 21:59
Show Gist options
  • Save bayerj/7890721 to your computer and use it in GitHub Desktop.
Save bayerj/7890721 to your computer and use it in GitHub Desktop.
import theano
import theano.tensor as T
import theano.sandbox.cuda as cuda
from theano.printing import pydotprint
from theano.misc import pycuda_utils
from pycuda.gpuarray import zeros
import pycuda.driver as drv
import pycuda.autoinit
from pycuda.compiler import SourceModule
X = cuda.fmatrix()
A = cuda.vector()
indexed = X[T.cast(A, 'int32')]
f = theano.function([X, A], indexed)
x = pycuda_utils.to_cudandarray(zeros((2, 2), dtype='float32'))
a = pycuda_utils.to_cudandarray(zeros((4,), dtype='float32'))
pydotprint(f, 'simple.png')
print f(x, a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment