2

I am really new to Coreml and Metal.

Now I am working on a project testing performance of Core Ml model. I implemented a CNN model based on tensorflow and convert this model to .mlmodel using tf-coreml tool.

But in my CNN model, it has an op named 'equal', which Coreml does not support. It converted into a custom layer of .mlmodel my .mlmodel file screen shot

Then I followed Hollemans amazing blog http://machinethink.net/blog/coreml-custom-layers/ to implement this custom layer on both CPU and GPU. My Cpu version works good, but when I implemented this op on GPU it cannot activate "encode function". I followed all steps in Hollemans's Blog creating the Metal compute kernels and the rest. But when I run my project, it always run on CPU. It seemed never get into Encode function.only run on evaluate function

I searched a lot on google but did not find an ideal answer, that really made me frustrated. If anyone has any hints, I will really appreciate. Thanks in advance.

1 Answer 1

1

When you ask your model for prediction, you can specify options like running on CPU only. One possible reason why your model isn't running on GPU might be that you have something like

let options = MLPredictionOptions() options.usesCPUOnly = true

in your code and you pass options to the prediction method. Put the usesCPUOnly property to false to allow the model to run on GPU. As it isn't mentioned in the Hollemans' blog (which is really great) that you can choose to run the model on CPU or GPU, I guess it could be one reason why your model keeps running on CPU.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.