hughperkins / DeepCL

OpenCL library to train deep convolutional neural networks
Mozilla Public License 2.0
865 stars 199 forks source link

PyOpenCL interoperability #126

Open EyeOfPython opened 6 years ago

EyeOfPython commented 6 years ago

It seems like I can only create an OpenCL context using the DeepCL constructor like this cl = PyDeepCL.DeepCL().

However, it's impossible to use an external context source, such as from PyOpenCL. If I want to share buffers between the neural network and other, non-DNN, OpenCL kernels, is there a way to do this?

Something like this would be optimal:

import pyopencl
import PyDeepCL
ctx = pyopencl.create_some_context()
deep_cl = PyDeepCL.DeepCL(context=ctx)

# use both ctx and deep_cl over the same buffers
0StackOverflow0 commented 6 years ago

You would probably be copying an np.array from one context to the other.

The weights and the inputs/outputs are all np arrays and all accessible. I believe you could even take a partially forwarded input from a middle layer if you really wanted to.

Otherwise, create a wrapper for one to work with the other, but that seems like more work with little additional payoff; unless I misunderstand the point.