You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tvm.apache.org by Morita Kazutaka via TVM Discuss <no...@discuss.tvm.ai> on 2020/04/17 16:58:25 UTC

[TVM Discuss] [Development/RFC] [RFC] CoreML Codegen


Adding CoreML codegen with the BYOC feature enables us to offload subgraphs to Apple’s Neural Engine on iOS devices. There are some approaches how to build a CoreML model in TVM.

- A0: Build with coremltools

  I think this is the most intuitive way to construct CoreML models.  coremltools provides good [APIs](https://apple.github.io/coremltools/generated/coremltools.models.neural_network.builder.html) and they are well documented. My concern is that we need to implement codegen with Python to use coremltools.  I wonder if there is any limitation to implement external codegen with Python.

- A1: Generate protobuf from Core ML specification

  Core ML model format is protobuf and its specification is available [here](https://github.com/apple/coremltools/tree/master/mlmodel/format), so we can create Core ML model with generated .pb.h and .pb.cc files. TFLite also takes this approach to implement Core ML Delegate. We can implement CoreML codegen flexibly, but it looks a harder way to go than A0.

- A2: Convert ONNX models

  We can use [onnx-coreml](https://github.com/onnx/onnx-coreml) to convert generated ONNX models by [this feature](https://discuss.tvm.ai/t/rfc-relay-to-onnx/6101).  We don't need to maintenance codes to build CoreML models, but I'm not sure how the implementation would be.  The flexibility of the output CoreML model might be limited by the intermediate ONNX model.

I've implemented [a prototype of A0](https://github.com/kazum/tvm/tree/coreml_codegen), which supports only add and multiply, on top of [CoreML runtime](https://github.com/apache/incubator-tvm/pull/5283). It looks working well at this point.

Any comments are welcome :)

@tqchen @ziheng @FrozenGene @thierry





---
[Visit Topic](https://discuss.tvm.ai/t/rfc-coreml-codegen/6415/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/2b410852728a40c0875cffb4eee2f8c9901e12dcb1b5171c3e0440001fdca33a).

[TVM Discuss] [Development/RFC] [RFC] CoreML Codegen

Posted by Morita Kazutaka via TVM Discuss <no...@discuss.tvm.ai>.

[quote="kazum, post:1, topic:6415"]
I’ve implemented [a prototype of A0](https://github.com/kazum/tvm/tree/coreml_codegen)
[/quote]

The PR was sent and it's ready to review.
https://github.com/apache/incubator-tvm/pull/5634





---
[Visit Topic](https://discuss.tvm.ai/t/rfc-coreml-codegen/6415/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubscribe/eede535c6b42bd1b83801203cbe4b25114436856d96a8d7577d659e19439cd82).