That does not seem to work. So I have this:

a = T.fmatrix()
ctx = pygpu.init(theano.config.device)
theano.gpuarray.reg_context("mine", ctx)
a_gpu = theano.gpuarray.GpuArrayType(a.dtype, a.broadcastable, "mine")
f2 = theano.function([a_gpu], a + T.constant(2), givens={a: a_gpu})
return f1, f2


However, Theano complains about:

TypeError: Unknown parameter type: <class 
'theano.gpuarray.type.GpuArrayType'>

If instead of the [a_gpu] I have [a] it complains that the givens is 
overwriting an input:

RuntimeError: You are trying to replace variable '<TensorType(float32, 
matrix)>' through the `givens` parameter, but this variable is an input to 
your function. Replacing inputs is currently forbidden because it has no 
effect. One way to modify an input `x` to a function evaluating f(x) is to 
define a new input `y` and use `theano.function([y], f(x), givens={x: 
g(y)})`. Another solution consists in using `theano.clone`, e.g. like this: 
`theano.function([x], theano.clone(f(x), replace={x: g(x)}))`.


On Tuesday, 9 May 2017 15:19:10 UTC+1, Adam Becker wrote:
>
> In the main graph, replace the input variables with type: 
> theano.gpuarray.GpuArrayType (Can be done using givens parameter of 
> theano.function). Then, feed pygpu.gpuarray.GpuArray object directly to 
> the compiled function. pygpu.gpuarray.asarray can be used to move numpy 
> array to GPU.
>
> On Tuesday, May 9, 2017 at 5:01:42 PM UTC+8, Alexander Botev wrote:
>>
>> Actually one thing I've just realized is that to do this consistently I 
>> need to have access to the underlying Theano pygpu Context. Is there anyway 
>> to get that?
>>
>> On Tuesday, 9 May 2017 09:53:02 UTC+1, Alexander Botev wrote:
>>>
>>> So recently I was wondering if there is any way that after compiling a 
>>> theano function, rather than taking numpy arrays / native lists / native 
>>> numbers it can accept as an input something like a libgpuarray or anything 
>>> else that lives on the GPU. However, I know that in the computation graph 
>>> usually when you compile it there is a Transfer Op if it is on the GPU. Is 
>>> there a way to avoid that transfer?
>>>
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to theano-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to