Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed gpu function exprs bug #42

Open
wants to merge 1 commit into
base: revamp
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions breze/arch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def cpu_expr_to_gpu(expr, unsafe=False):
If unsafe is set to True, subsequent function calls evaluating the
expression might return arrays pointing at the same memory region.
"""
if isinstance(expr, theano.sandbox.cuda.var.CudaNdarrayVariable):
return expr

expr_ = T.cast(expr, 'float32')
expr_ = theano.Out(theano.sandbox.cuda.basic_ops.gpu_from_host(expr),
borrow=unsafe)
Expand Down Expand Up @@ -421,14 +424,13 @@ def _unify_exprs(self, exprs):
if isinstance(exprs, (str, unicode)):
# We are only being given a single string expression.
exprs = self.exprs[exprs]
elif isinstance(exprs, theano.tensor.basic.TensorVariable):
# TODO: does this work in case of the GPU?
exprs = exprs
else:
elif isinstance(exprs, list):
# We have several, either string or variable, thus make it a list
# and substitute the strings.
exprs = list(exprs)
exprs = [self.exprs[i] if isinstance(i, str) else i for i in exprs]
else:
exprs = exprs

return exprs

Expand Down