Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsMay 31, 2026·3 min de lecture

CoreML Tools — Convert ML Models to Apple CoreML Format

A Python package for converting trained models from TensorFlow, PyTorch, and other frameworks into Apple's CoreML format for on-device inference on iPhone, iPad, and Mac.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
CoreML Tools
Commande d'installation directe
npx -y tokrepo@latest install de281956-5cea-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

CoreML Tools is Apple's open-source Python library for converting machine learning models into the CoreML format (.mlpackage or .mlmodel). Once converted, models run natively on Apple Neural Engine, GPU, and CPU across iOS, iPadOS, macOS, watchOS, and tvOS with no additional dependencies.

What CoreML Tools Does

  • Converts models from PyTorch, TensorFlow, TensorFlow Lite, scikit-learn, and ONNX to CoreML
  • Applies post-training quantization (INT8, FP16, palettization) to reduce model size
  • Supports neural network, pipeline, and ML program model representations
  • Validates converted models by comparing outputs against the original framework
  • Generates Xcode-ready .mlpackage files for drag-and-drop integration into apps

Architecture Overview

The conversion pipeline starts by importing a model from its source framework into CoreML Tools' intermediate representation (MIL — Model Intermediate Language). MIL normalizes operations across frameworks into a common graph. Optimization passes then apply quantization, graph pruning, and operation fusion. Finally, a backend serializer writes the optimized graph into the CoreML protobuf format, bundled as an .mlpackage with weights and metadata.

Self-Hosting & Configuration

  • Install via pip on macOS or Linux (conversion works on both; inference requires Apple hardware)
  • Use ct.convert() with framework-specific inputs for one-line conversion
  • Specify compute units (CPU, GPU, Neural Engine, or all) in the conversion call
  • Apply quantization with ct.optimize utilities to shrink model size for mobile deployment
  • Test converted models locally using the predict() method before deploying to devices

Key Features

  • Unified converter handles PyTorch (traced and exported), TensorFlow, and ONNX models
  • Post-training compression includes weight quantization, pruning, and palettization
  • Models leverage Apple Neural Engine for hardware-accelerated inference on A-series and M-series chips
  • MIL intermediate representation enables custom optimization passes
  • Supports vision, NLP, audio, and tabular model types

Comparison with Similar Tools

  • ONNX Runtime — cross-platform inference engine; CoreML Tools targets Apple-specific hardware acceleration
  • TensorFlow Lite — mobile inference for Android and iOS; CoreML Tools produces Apple-optimized models
  • OpenVINO — Intel hardware optimization; CoreML Tools targets Apple Neural Engine and GPU
  • TorchScript — PyTorch serialization format; CoreML Tools converts to a format native to Apple platforms
  • NVIDIA TensorRT — GPU inference optimization for NVIDIA hardware; CoreML Tools targets Apple silicon

FAQ

Q: Can I convert models on Linux? A: Yes. Model conversion runs on Linux and macOS. Running inference on the converted model requires Apple hardware.

Q: Which PyTorch export methods are supported? A: Both torch.jit.trace and torch.export (ExecuTorch path) are supported for conversion.

Q: How much smaller are quantized models? A: INT8 quantization typically reduces model size by 4x compared to FP32 with minimal accuracy loss.

Q: Does it support transformer models? A: Yes. CoreML Tools can convert transformer-based models including vision transformers and language models.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires