Source and Conversion Formats#

Use the convert() method of the Core ML Tools Unified Conversion API (available from Core ML Tools version 4.0 and newer versions) to convert deep learning models to the Core ML model format in order to deploy them in the Core ML framework.

Supported Source Formats#

Source model formats supported by the Unified Conversion API include the following:

TensorFlow versions 1.x Formats#

TensorFlow versions 2.x Formats#

PyTorch Formats#

  • TorchScript object

  • TorchScript object saved as a .pt file

Target Conversion Formats#

You can choose which format to use during conversion using the convert_to or the minimum_deployment_target arguments in the convert() method.

Default Format#

While neuralnetwork was the format originally used by Core ML to represent neural networks, it is now in maintenance mode and no longer receiving new features. The mlprogram model format, deployable to iOS15, macOS12, watchOS8, tvOS15, and newer versions, is the recommended format.

Since the neuralnetwork format is widely available, it is still the default format produced by versions of the Unified Conversion API older than 7.0. Calling convert() without providing the convert_to or the minimum_deployment_target parameters, in versions older than 7.0, defaults to the iOS11/macOS10.13 deployment target and the neuralnetwork backend.

However, in 7.0 and newer versions of Core ML Tools, the convert() method produces an mlprogram by default with the iOS15/macOS12 deployment target. You can override this behavior by providing a minimum_deployment_target value.

Format Differences#

The following table summarizes the format differences:

Neural Network

ML Program

Minimum deployment target

macOS 10.13, iOS 11, watchOS 4, tvOS 11

macOS 12, iOS 15, watchOS 8, tvOS 15

Supported file formats

.mlmodel or .mlpackage

.mlpackage

Note

To learn more about the differences between the two formats, see Comparing ML Programs and Neural Networks.

Minimum Deployment Target#

  • Neural network: macOS 10.13, iOS 11, watchOS 4, tvOS 11

  • ML Program: macOS 12, iOS 15, watchOS 8, tvOS 15

Supported Core ML File Formats#

How to Produce#

  • Core ML Tools versions older than 7.0:

    • Neural network: Generated by default by the convert() method.

    • ML Program: Use either convert_to="mlprogram", or minimum_deployment_target=target.iOS15 or newer.

  • Core ML Tools 7.0 and newer:

    • Neural network: Use minimum_deployment_target=target.iOS14 or older.

    • ML Program: Generated by default by the convert() method.

Format Specification#

Supported Operations#

  • Neural network: Set of supported ops frozen. For the current list of ops (also known as layers), see the NeuralNetwork spec description.

  • ML Program: New ops are added continually. For the current list of ops, see MIL Ops.

Feature Development#

  • Neural network: Frozen, under maintenance only.

  • ML Program: All new features target the ML Program format.

Performance Improvements#

  • Neural network: Limited.

  • ML Program: All major performance enhancements target ML Program.