Skip to content

Commit 870213b

Browse files
6.1 Release (#1675)
6.1 Release
1 parent 3efa98d commit 870213b

File tree

361 files changed

+12414
-8978
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

361 files changed

+12414
-8978
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ test_py37_pytorch:
9898
WHEEL_PATH: build/dist/*cp37*10_15*
9999

100100
test_py37_tf1:
101-
<<: *test_macos_pkg
101+
<<: *test_macos_pkg_with_reqs
102102
tags:
103103
- macos12
104104
dependencies:
@@ -107,9 +107,10 @@ test_py37_tf1:
107107
PYTHON: "3.7"
108108
TEST_PACKAGE: coremltools.converters.mil.frontend.tensorflow
109109
WHEEL_PATH: build/dist/*cp37*10_15*
110+
REQUIREMENTS: reqs/test_tf1.pip
110111

111112
test_py37_tf2:
112-
<<: *test_macos_pkg_with_reqs
113+
<<: *test_macos_pkg
113114
tags:
114115
- macos12
115116
dependencies:
@@ -118,7 +119,6 @@ test_py37_tf2:
118119
PYTHON: "3.7"
119120
TEST_PACKAGE: coremltools.converters.mil.frontend.tensorflow2
120121
WHEEL_PATH: build/dist/*cp37*10_15*
121-
REQUIREMENTS: reqs/test_tf2.pip
122122

123123
test_py37_mil:
124124
<<: *test_macos_pkg

coremltools/__init__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,10 @@
2424
from enum import Enum as _Enum
2525
from logging import getLogger as _getLogger
2626

27-
28-
# Backup root logger handlers
29-
_root_logger = _getLogger()
30-
_root_logger_handlers_backup = _root_logger.handlers.copy()
31-
3227
from .version import __version__
3328

29+
_logger = _getLogger(__name__)
30+
3431
# This is the basic Core ML specification format understood by iOS 11.0
3532
SPECIFICATION_VERSION = 1
3633

@@ -63,6 +60,9 @@
6360
# New versions for iOS 16.0
6461
_SPECIFICATION_VERSION_IOS_16 = 7
6562

63+
# New versions for iOS 17.0
64+
_SPECIFICATION_VERSION_IOS_17 = 8
65+
6666
class ComputeUnit(_Enum):
6767
'''
6868
The set of processing-unit configurations the model can use to make predictions.
@@ -79,6 +79,7 @@ class ComputeUnit(_Enum):
7979
_SPECIFICATION_VERSION_IOS_14: "CoreML4",
8080
_SPECIFICATION_VERSION_IOS_15: "CoreML5",
8181
_SPECIFICATION_VERSION_IOS_16: "CoreML6",
82+
_SPECIFICATION_VERSION_IOS_17: "CoreML7",
8283
}
8384

8485
# Default specification version for each backend
@@ -122,9 +123,3 @@ class ComputeUnit(_Enum):
122123

123124
if _ENABLE_PROFILING:
124125
_sys.setprofile(_profiler)
125-
126-
# Restore root logger handlers
127-
_root_logger = _getLogger()
128-
_coreml_logger = _getLogger(__name__)
129-
_coreml_logger.handlers = _root_logger.handlers.copy()
130-
_root_logger.handlers = _root_logger_handlers_backup

coremltools/_deps/__init__.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
List of all external dependancies for this package. Imported as
88
optional includes
99
"""
10-
from distutils.version import StrictVersion as _StrictVersion
11-
import logging as _logging
12-
from packaging import version
1310
import platform as _platform
1411
import re as _re
1512
import sys as _sys
13+
from distutils.version import StrictVersion as _StrictVersion
14+
15+
from packaging import version
16+
17+
from coremltools import _logger as logger
1618

1719

1820
def _get_version(version):
@@ -24,7 +26,7 @@ def _get_version(version):
2426

2527
def _warn_if_above_max_supported_version(package_name, package_version, max_supported_version):
2628
if _get_version(package_version) > _StrictVersion(max_supported_version):
27-
_logging.warning(
29+
logger.warning(
2830
"%s version %s has not been tested with coremltools. You may run into unexpected errors. "
2931
"%s %s is the most recent version that has been tested."
3032
% (package_name, package_version, package_name, max_supported_version)
@@ -64,7 +66,7 @@ def __get_sklearn_version(version):
6466
_SKLEARN_MIN_VERSION
6567
) or _SKLEARN_VERSION > _StrictVersion(_SKLEARN_MAX_VERSION):
6668
_HAS_SKLEARN = False
67-
_logging.warning(
69+
logger.warning(
6870
(
6971
"scikit-learn version %s is not supported. Minimum required version: %s. "
7072
"Maximum required version: %s. "
@@ -100,7 +102,7 @@ def __get_sklearn_version(version):
100102
_TF_1_MIN_VERSION = "1.12.0"
101103
_TF_1_MAX_VERSION = "1.15.4"
102104
_TF_2_MIN_VERSION = "2.1.0"
103-
_TF_2_MAX_VERSION = "2.8.0"
105+
_TF_2_MAX_VERSION = "2.10.0"
104106

105107
try:
106108
import tensorflow
@@ -116,7 +118,7 @@ def __get_sklearn_version(version):
116118

117119
if _HAS_TF_1:
118120
if tf_ver < _StrictVersion(_TF_1_MIN_VERSION):
119-
_logging.warning(
121+
logger.warning(
120122
(
121123
"TensorFlow version %s is not supported. Minimum required version: %s ."
122124
"TensorFlow conversion will be disabled."
@@ -126,7 +128,7 @@ def __get_sklearn_version(version):
126128
_warn_if_above_max_supported_version("TensorFlow", tensorflow.__version__, _TF_1_MAX_VERSION)
127129
elif _HAS_TF_2:
128130
if tf_ver < _StrictVersion(_TF_2_MIN_VERSION):
129-
_logging.warn(
131+
logger.warning(
130132
(
131133
"TensorFlow version %s is not supported. Minimum required version: %s ."
132134
"TensorFlow conversion will be disabled."

coremltools/converters/_converters_entry.py

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,42 @@
66
import collections
77
import gc
88
import os
9-
import warnings
109

1110
from coremltools import (
12-
ComputeUnit as _ComputeUnit,
13-
__version__ as _ct_version,
14-
_LOWEST_ALLOWED_SPECIFICATION_VERSION_FOR_NEURALNETWORK,
1511
_LOWEST_ALLOWED_SPECIFICATION_VERSION_FOR_MILPROGRAM,
16-
)
17-
from coremltools.converters.mil.mil.passes.quantization_passes import (
18-
AbstractQuantizationPass,
19-
ComputePrecision as precision,
20-
FP16ComputePrecision
21-
)
22-
from coremltools.converters.mil.input_types import (
23-
ClassifierConfig,
24-
ImageType,
25-
InputType,
26-
TensorType,
27-
)
12+
_LOWEST_ALLOWED_SPECIFICATION_VERSION_FOR_NEURALNETWORK)
13+
from coremltools import ComputeUnit as _ComputeUnit
14+
from coremltools import __version__ as _ct_version
15+
from coremltools._deps import _HAS_TF_1, _HAS_TF_2, _HAS_TORCH
16+
from coremltools.converters._profile_utils import _profile
17+
from coremltools.converters.mil._deployment_compatibility import (
18+
AvailableTarget, check_deployment_compatibility)
2819
from coremltools.converters.mil.converter import mil_convert
20+
from coremltools.converters.mil.input_types import (ClassifierConfig,
21+
ImageType, InputType,
22+
TensorType)
2923
from coremltools.converters.mil.mil import Program, types
30-
from coremltools._deps import _HAS_TORCH, _HAS_TF_1, _HAS_TF_2
31-
from coremltools.converters._profile_utils import _profile
32-
33-
from coremltools.models import _METADATA_VERSION, _METADATA_SOURCE
24+
from coremltools.converters.mil.mil.passes.quantization_passes import \
25+
ComputePrecision as precision
26+
from coremltools.converters.mil.mil.passes.quantization_passes import \
27+
FP16ComputePrecision
28+
from coremltools.models import _METADATA_SOURCE, _METADATA_VERSION
3429
from coremltools.models.utils import _MLPACKAGE_EXTENSION
35-
from coremltools.converters.mil._deployment_compatibility import (
36-
AvailableTarget,
37-
check_deployment_compatibility,
38-
)
3930

4031
if _HAS_TF_1:
4132
import tensorflow as tf
33+
4234
from coremltools.converters.mil.frontend.tensorflow.load import TF1Loader
4335
if _HAS_TF_2:
4436
import tensorflow as tf
37+
4538
from coremltools.converters.mil.frontend.tensorflow2.load import TF2Loader
4639

4740
if _HAS_TORCH:
4841
import torch
49-
from coremltools.converters.mil.frontend.torch.load import (
50-
_torchscript_from_model as pytorch_load,
51-
)
42+
43+
from coremltools.converters.mil.frontend.torch.load import \
44+
_torchscript_from_model as pytorch_load
5245

5346
@_profile
5447
def convert(

coremltools/converters/libsvm/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
55

66

7-
from . import _libsvm_converter
8-
from . import _libsvm_util
9-
107
from ..._deps import _HAS_LIBSVM
8+
from . import _libsvm_converter, _libsvm_util
119

1210
if _HAS_LIBSVM:
1311
from libsvm import svmutil as _svmutil

coremltools/converters/libsvm/_libsvm_converter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
# Use of this source code is governed by a BSD-3-clause license that can be
44
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
55

6+
from coremltools import __version__ as ct_version
7+
from coremltools.models import _METADATA_SOURCE, _METADATA_VERSION
8+
69
from ... import SPECIFICATION_VERSION
710
from ..._deps import _HAS_LIBSVM
8-
from coremltools import __version__ as ct_version
9-
from coremltools.models import _METADATA_VERSION, _METADATA_SOURCE
1011

1112

1213
def _infer_min_num_features(model):
@@ -55,10 +56,9 @@ def convert(libsvm_model, feature_names, target, input_length, probability):
5556
raise RuntimeError("libsvm not found. libsvm conversion API is disabled.")
5657

5758
from libsvm import svm as _svm
58-
from ...proto import SVM_pb2
59-
from ...proto import Model_pb2
60-
from ...proto import FeatureTypes_pb2
59+
6160
from ...models import MLModel
61+
from ...proto import Model_pb2
6262

6363
svm_type_enum = libsvm_model.param.svm_type
6464

coremltools/converters/libsvm/_libsvm_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ def load_model(model_path):
2828
if not (_HAS_LIBSVM):
2929
raise RuntimeError("libsvm not found. libsvm conversion API is disabled.")
3030

31-
from svmutil import svm_load_model # From libsvm
3231
import os
3332

33+
from svmutil import svm_load_model # From libsvm
34+
3435
if not os.path.exists(model_path):
3536
raise IOError("Expected a valid file path. %s does not exist" % model_path)
3637
return svm_load_model(model_path)

coremltools/converters/mil/__init__.py

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,14 @@
33
# Use of this source code is governed by a BSD-3-clause license that can be
44
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
55

6-
from .mil import (
7-
Block,
8-
builder,
9-
Builder,
10-
curr_block,
11-
DefaultInputs,
12-
Function,
13-
get_existing_symbol,
14-
get_new_symbol,
15-
get_new_variadic_symbol,
16-
InputSpec,
17-
InternalVar,
18-
ListInputType,
19-
ListVar,
20-
mil_list,
21-
Operation,
22-
Placeholder,
23-
Program,
24-
register_op,
25-
SPACES,
26-
SUPPORT_FLOAT_TYPES,
27-
SUPPORT_INT_TYPES,
28-
Symbol,
29-
TupleInputType,
30-
Var,
31-
)
326

33-
from .frontend.torch import register_torch_op
34-
35-
from .input_types import (
36-
ClassifierConfig,
37-
ColorLayout,
38-
InputType,
39-
TensorType,
40-
ImageType,
41-
RangeDim,
42-
Shape,
43-
EnumeratedShapes,
44-
)
45-
46-
from coremltools.converters.mil.frontend.tensorflow.tf_op_registry import register_tf_op
7+
from .mil import (SPACES, SUPPORT_FLOAT_TYPES, SUPPORT_INT_TYPES, Block,
8+
Builder, DefaultInputs, Function, InputSpec, InternalVar,
9+
ListInputType, ListVar, Operation, Placeholder, Program,
10+
Symbol, TupleInputType, Var, builder, curr_block,
11+
get_existing_symbol, get_new_symbol, get_new_variadic_symbol,
12+
mil_list, register_op)
13+
from .input_types import (ClassifierConfig, ColorLayout, EnumeratedShapes,
14+
ImageType, InputType, RangeDim, Shape, TensorType)
15+
from .frontend.tensorflow.tf_op_registry import register_tf_op
16+
from .frontend.torch import register_torch_op

coremltools/converters/mil/_deployment_compatibility.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
from enum import IntEnum
77

8-
from coremltools import (
9-
_SPECIFICATION_VERSION_IOS_13,
10-
_SPECIFICATION_VERSION_IOS_14,
11-
_SPECIFICATION_VERSION_IOS_15,
12-
_SPECIFICATION_VERSION_IOS_16,
13-
)
8+
from coremltools import (_SPECIFICATION_VERSION_IOS_13,
9+
_SPECIFICATION_VERSION_IOS_14,
10+
_SPECIFICATION_VERSION_IOS_15,
11+
_SPECIFICATION_VERSION_IOS_16,
12+
_SPECIFICATION_VERSION_IOS_17)
1413

1514

1615
class AvailableTarget(IntEnum):
@@ -19,6 +18,7 @@ class AvailableTarget(IntEnum):
1918
iOS14 = _SPECIFICATION_VERSION_IOS_14
2019
iOS15 = _SPECIFICATION_VERSION_IOS_15
2120
iOS16 = _SPECIFICATION_VERSION_IOS_16
21+
iOS17 = _SPECIFICATION_VERSION_IOS_17
2222

2323
# macOS versions (aliases of iOS versions)
2424
macOS15 = _SPECIFICATION_VERSION_IOS_13
@@ -28,18 +28,21 @@ class AvailableTarget(IntEnum):
2828
macOS11 = _SPECIFICATION_VERSION_IOS_14
2929
macOS12 = _SPECIFICATION_VERSION_IOS_15
3030
macOS13 = _SPECIFICATION_VERSION_IOS_16
31+
macOS14 = _SPECIFICATION_VERSION_IOS_17
3132

3233
# watchOS versions (aliases of iOS versions)
3334
watchOS6 = _SPECIFICATION_VERSION_IOS_13
3435
watchOS7 = _SPECIFICATION_VERSION_IOS_14
3536
watchOS8 = _SPECIFICATION_VERSION_IOS_15
3637
watchOS9 = _SPECIFICATION_VERSION_IOS_16
38+
watchOS10 = _SPECIFICATION_VERSION_IOS_17
3739

3840
# tvOS versions (aliases of iOS versions)
3941
tvOS13 = _SPECIFICATION_VERSION_IOS_13
4042
tvOS14 = _SPECIFICATION_VERSION_IOS_14
4143
tvOS15 = _SPECIFICATION_VERSION_IOS_15
4244
tvOS16 = _SPECIFICATION_VERSION_IOS_16
45+
tvOS17 = _SPECIFICATION_VERSION_IOS_17
4346

4447
# customized __str__
4548
def __str__(self):

coremltools/converters/mil/backend/backend_helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
55

66
from coremltools.converters.mil.input_types import ColorLayout
7-
from coremltools.converters.mil.mil.passes.name_sanitization_utils import NameSanitizer
7+
from coremltools.converters.mil.mil.passes.name_sanitization_utils import \
8+
NameSanitizer
89
from coremltools.proto import FeatureTypes_pb2 as ft
910

11+
1012
def _get_probability_var_for_classifier(prog, classifier_config):
1113
'''
1214
Return the var which will be used to construct the dictionary for the classifier.

0 commit comments

Comments
 (0)