Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert OpenCL/CUDA to Metal

I'm about to convert some GPU kernels of my project from OpenCL/Cuda to Metal in order to run my application on Apple devices. Currently, my project was written completely in C/C++. After doing some research, I think I need to get my hand dirty with Swift or Objective-C. But to be honest, I'm not sure about this stuff because Metal language for computation and deep learning is quite new.

I know there's a library called "CoreML", but my app requires some custom kernels. My question: what is the best way to deal with low-level API of Apple devices in my situation?

like image 256
dk1111 Avatar asked Mar 06 '23 11:03

dk1111


1 Answers

The Metal Shading Language is a version of C++. I haven't had too much trouble with porting OpenCL or CUDA kernels to Metal.

Core ML only supports a limited set of layers. You can write your own custom layers, which involves writing a CPU version and optionally a GPU version (in the Metal language).

I wrote a blog post about this: http://machinethink.net/blog/coreml-custom-layers/

like image 192
Matthijs Hollemans Avatar answered Mar 16 '23 12:03

Matthijs Hollemans