Core ML
ONNX
TensorFlow Lite
model conversion
machine learning

Can't convert Core ML model to Onnx then to Tensorflow Lite

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

Trying to convert a Core ML model to ONNX and then to TensorFlow Lite usually fails because that conversion chain goes against the direction most tooling is designed for. Core ML is primarily a deployment format for Apple platforms, not a universal interchange format, so the most reliable solution is usually to go back to the original training framework and convert from there.

Why This Pipeline Breaks Down

Each model format makes different assumptions:

  • Core ML targets Apple runtime execution
  • ONNX is an interchange format between training and inference ecosystems
  • TensorFlow Lite targets mobile and embedded TensorFlow runtimes

Moving from PyTorch or TensorFlow into ONNX is common. Moving from ONNX into Core ML is also supported in some workflows. But going from an already converted Core ML package back outward into ONNX and then into TFLite is much less standard and often unsupported for many operators.

The Better Strategy

If you still have the source model in PyTorch, TensorFlow, or another training framework, use that as the starting point.

Typical reliable routes are:

  • PyTorch to ONNX to TensorFlow to TensorFlow Lite
  • TensorFlow or Keras directly to TensorFlow Lite
  • PyTorch to Core ML separately for iOS deployment

In other words, treat Core ML and TensorFlow Lite as sibling deployment targets, not as stepping stones to each other.

Example: Convert From TensorFlow Directly

If the original model is in TensorFlow or Keras, the direct TFLite conversion path is simple.

python
1import tensorflow as tf
2
3model = tf.keras.Sequential([
4    tf.keras.layers.Input(shape=(8,)),
5    tf.keras.layers.Dense(16, activation="relu"),
6    tf.keras.layers.Dense(2, activation="softmax"),
7])
8
9converter = tf.lite.TFLiteConverter.from_keras_model(model)
10tflite_model = converter.convert()
11
12with open("model.tflite", "wb") as f:
13    f.write(tflite_model)

This avoids the entire Core ML and ONNX detour.

Example: Convert From PyTorch Via ONNX

If the original model is in PyTorch and you need a TensorFlow Lite output, export ONNX from PyTorch rather than from Core ML.

python
1import torch
2import torch.nn as nn
3
4class TinyModel(nn.Module):
5    def __init__(self):
6        super().__init__()
7        self.fc = nn.Linear(8, 2)
8
9    def forward(self, x):
10        return self.fc(x)
11
12model = TinyModel().eval()
13dummy = torch.randn(1, 8)
14
15torch.onnx.export(model, dummy, "model.onnx", input_names=["input"], output_names=["output"])

From there, you can use ONNX-to-TensorFlow tooling or another supported bridge. The critical point is that the export starts from the framework that still has the real graph semantics.

Why Reverse Conversion Is Hard

By the time a model becomes Core ML, some graph information may have been rewritten, fused, or represented in ways that do not map cleanly back to ONNX. Even when a converter exists, it may fail on:

  • custom operators
  • unsupported layer types
  • dynamic shapes
  • fused preprocessing or postprocessing blocks
  • quantization metadata specific to the target runtime

This is not just a tooling inconvenience. It is a mismatch in intended format direction.

Practical Decision Rule

If you need to deploy the same model to both Apple devices and TensorFlow Lite targets, keep the original training checkpoint or framework model as the source of truth. Then produce separate exports for each target platform.

That makes debugging much easier because each converter sees the model before target-specific transformations are baked in.

Common Pitfalls

The most common mistake is treating Core ML as a neutral exchange format. It is optimized for Apple inference, not as a universal bridge to every other ecosystem.

Another mistake is stacking multiple lossy conversions and expecting full operator compatibility at the end. Every conversion step introduces another place for semantic drift or unsupported ops.

A third issue is discarding the original training model too early. Once the source graph is gone, deployment flexibility drops sharply.

Summary

  • Core ML to ONNX to TensorFlow Lite is usually an unreliable conversion path.
  • The most dependable approach is to convert from the original training framework instead.
  • Treat Core ML and TensorFlow Lite as separate deployment targets, not as intermediate formats for each other.
  • Reverse conversion often fails because operators and graph semantics do not map cleanly backward.
  • Keep the original model checkpoint or framework export as the source of truth.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design