Using OpenCL and DLPrimitives from Swift #17
Replies: 4 comments 7 replies
-
I compiled SwiftOpenCL on Google Colab (which has an Nvidia GPU) and I just ran |
Beta Was this translation helpful? Give feedback.
-
I strongly discourage you from rewriting c++ code in Swift.
Most of API you need is here http://dlprimitives.org/docs/namespacedlprim_1_1core.html + several classes like Tensor Context etc. Once you wrap them in Swift you are going to simply maintenance and can work on your own developments Now you have two approaches:
But implementing it all from the scratch is waste if time. BTW Swift opencl binding can indeed be very useful |
Beta Was this translation helpful? Give feedback.
-
Yes, of course. In fact in pytorch dlprimitivies/opencl backend the memory management is separate from dlprimitives Edit: this is an example of creating dlprimitives tensort from pytorch opencl tensor: https://github.com/artyom-beilis/pytorch_dlprim/blob/master/src/utils.cpp#L43
1st of all there are pointwise operations with broadcasting/reduction for generic operations. I use them extensively in pytorch. For example: https://github.com/artyom-beilis/pytorch_dlprim/blob/master/src/pointwise_ops.cpp#L477 this is how I use it from pytorch. However there is no direct support of running your own full kernel (it is related to caching) but shouldn't be a big problem to add such stuff. It maybe useful mostly because dlprimitives can cache compiled kernels on disk/memory |
Beta Was this translation helpful? Give feedback.
-
I've decided to go with translating DLPrimitives from C++ to Swift, and I have some questions:
|
Beta Was this translation helpful? Give feedback.
-
@artyom-beilis - citing #13 (reply in thread), this is the thread where we can discuss stuff besides debugging or optimizing DLPrimitives for the Apple architecture.
I plan to take this path:
opencl.hpp
. This is a work in progress: SwiftOpenCLQuestions:
Beta Was this translation helpful? Give feedback.
All reactions