Core ML tools contain supporting tools for Core ML model conversion, editing, and validation.
torch.narrow
torch.adaptive_avg_pool1d
and torch.adaptive_max_pool1d
torch.numpy_t
(i.e. the numpy-style transpose operator .T
)torch.clamp_min
for integer data typetorch.add
for complex data typetf.math.top_k
when k
is variableThanks to our ExecuTorch partners and our open-source community: @KrassCodes @M-Quadra @teelrabbit @minimalic @alealv @ChinChangYang @pcuenca
New Features:
Includes experimental support for torch.export
API but limited to EDGE dialect.
Example usage:
import torch
from torch.export import export
from executorch.exir import to_edge
import coremltools as ct
example_args = (torch.randn(*size), )
aten_dialect = export(AnyNNModule(), example_args)
edge_dialect = to_edge(aten_dialect).exported_program()
edge_dialect._dialect = "EDGE"
mlmodel = ct.convert(edge_dialect)
Enhancements:
ct.utils.make_pipeline
- now allows specifying compute_unitsBug Fixes:
Various other bug fixes, enhancements, clean ups and optimizations.
coremltools.optimize
for model quantization and compression
coremltools.optimize.coreml
for compressing coreml models, in a data free manner. coremltools.compresstion_utils.*
APIs have been moved herecoremltools.optimize.torch
for compressing torch model with training data and fine-tuning. The fine tuned torch model can then be converted using coremltools.convert
mlprogram
for iOS15/macOS12. Previously calling coremltools.convert()
without providing the convert_to
or the minimum_deployment_target
arguments, used the lowest deployment target (iOS11/macOS10.13) and the neuralnetwork
backend. Now the conversion process will default to iOS15/macOS12 and the mlprogram
backend. You can change this behavior by providing a minimum_deployment_target
or convert_to
value.repeat_interleave
, unflatten
, col2im
, view_as_real
, rand
, logical_not
, fliplr
, quantized_matmul
, randn
, randn_like
, scaled_dot_product_attention
, stft
, tile
pass_pipeline
parameter has been added to coremltools.convert
to allow controls over which optimizations are performed..modelc
files). Get compiled model files from an MLModel
instance. Python API to explicitly compile a model.coremltools.optimize.coreml.get_weights_metadata
. This information can be used to customize optimization across ops when using coremltools.optimize.coreml
APIs.coremltools.compression_utils
is deprecated.mlprogram
backend is used.mlprogram
:
RangeDim
is used and no upper-bound is set (with a positive number), an exception will be raised.inputs
parameter but there are undetermined dim in input shape (for example, TF with "None" in input placeholder), it will be sanitized to a finite number (default_size + 1) and raise a warning.Special thanks to our external contributors for this release: @fukatani , @pcuenca , @KWiecko , @comeweber , @sercand , @mlaves, @cclauss, @smpanaro , @nikalra, @jszaday
mlprogram
for iOS15/macOS12. Previously calling coremltools.convert()
without providing the convert_to
or the minimum_deployment_target
arguments, used the lowest deployment target (iOS11/macOS10.13) and the neuralnetwork
backend. Now the conversion process will default to iOS15/macOS12 and the mlprogram
backend. You can change this behavior by providing a minimum_deployment_target
or convert_to
value.mlprogram
backend is used.mlprogram
:
RangeDim
is used and no upper-bound is set (with a positive number), an exception will be raised.inputs
parameter but there are undetermined dim in input shape (for example, TF with "None" in input placeholder), it will be sanitized to a finite number (default_size + 1) and raise a warning.coremltools.optimize.coreml.get_weights_metadata
. This information can be used to customize optimization across ops when using coremltools.optimize.coreml
APIs.repeat_interleave
and unflatten
.batch_norm
, conv
, con
v_transpose
, expand_dims
, gru
, instance_norm
, inverse
, l2_norm
, layer_norm
, linear
, local_response_norm
, log
, lstm
, matmul
, reshape_like
, resample
, resize
, reverse
, reverse_sequence
, rnn
, rsqrt
, slice_by_index
, slice_by_size
, sliding_windows
, squeeze
, transpose
.Special thanks to our external contributors for this release: @fukatani, @pcuenca, @KWiecko, @comeweber and @sercand
coremltools.optimize
for model quantization and compression
coremltools.optimize.coreml
for compressing coreml models, in a data free manner. coremltools.compresstion_utils.*
APIs have been moved herecoremltools.optimize.torch
for compressing torch model with training data and fine-tuning. The fine tuned torch model can then be converted using coremltools.convert
pass_pipeline
parameter has been added to coremltools.convert
to allow controls over which optimizations are performed.randn
, randn_like
, scaled_dot_product_attention
, stft
, tile
coremltools.models.ml_program.compression_utils
is deprecated.Core ML tools 7.0 guide: https://coremltools.readme.io/v7.0/
Special thanks to our external contributors for this release: @fukatani, @pcuenca, @mlaves, @cclauss, @smpanaro, @nikalra, @jszaday
pass_pipeline
parameter to coremltools.convert
.utils.make_pipeline
.converters.mil.debugging_utils.extract_submodel
Special thanks to our external contributors for this release: @fukatani, @nikalra and @kevin-keraudren.
torch==1.13.1
and torchvision==0.14.1
.torch.fft
, torchvision.ops.nms
, torch.atan2
, torch.bitwise_and
, torch.numel
,tf.signal
, tf.tensor_scatter_nd_add
.clamp
op.topk
(k not determined during compile time).padding='valid'
in PyTorch convolution.Special thanks to our external contributors for this release: @fukatani, @ChinChangYang, @danvargg, @bhushan23 and @cjblocker.
2.10
.baddbmm
, glu
, hstack
, remainder
, weight_norm
, hann_window
, randint
, cross
, trace
, and reshape_as.
repeat
and expand
op.where
op with only one input.'bhcq,bhck→bhqk’
.Special thanks to our external contributors for this release: @fukatani, @piraka9011, @giorgiop, @hollance, @SangamSwadiK, @RobertRiachi, @waylybaye, @GaganNarula, and @sunnypurewal.
coremltools.compression_utils
1.1.2
).1.12.1
).2.8
.coremltools.ImageType
used with inputs.CPU_AND_NE
to select the model runtime to the Neural engine and CPU.full_like
, resample
, reshape_like
, pixel_unshuffle
, topk
crop_resize
, gather
, gather_nd
, topk
, upsample_bilinear
.useCPUOnly
parameter from coremltools.convert
and coremltools.models.MLModel
. Use coremltools.ComputeUnit
instead.pixel_unshuffle
, resample
, topk
CPU_AND_NE
AdaptiveAvgPool2d
, cosine_similarity
, eq
, linalg.norm
, linalg.matrix_norm
, linalg.vector_norm
, ne
, PixelUnshuffle
identity_n
TensorFlow op