Taking advantage of the GPU 

You may recall that when we introduced the MLCustomLayer protocol, there was an optional method, encode(commandBuffer, inputs, outputs), reserved for performing the evaluation on the GPU if the hosting device supported it. This flexibility is one of the advantages Core ML has over other machine learning frameworks; it allows mixing layers, which run on the CPU and GPU, and allows them to work coherently together. 

To use the GPU, we will be using Apple's Metal framework, a graphics framework equivalent to OpenGL and DirectX (and now Vulkan), for those who are familiar with 3D graphics. Unlike our previous solutions, which included all code in a single method, we need to write the code that performs the computation ...

Get Machine Learning with Core ML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.