mct-nightly 2.3.0.20250401.618__py3-none-any.whl → 2.3.0.20250402.536__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mct-nightly
3
- Version: 2.3.0.20250401.618
3
+ Version: 2.3.0.20250402.536
4
4
  Summary: A Model Compression Toolkit for neural networks
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -1,5 +1,5 @@
1
- mct_nightly-2.3.0.20250401.618.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
- model_compression_toolkit/__init__.py,sha256=sgIxUWX9jDSvUZnwMqs3nHNjXfhgFSfniDDr2vvRTuQ,1557
1
+ mct_nightly-2.3.0.20250402.536.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
+ model_compression_toolkit/__init__.py,sha256=dhPx1u7eKO_zAY9CefOYP31YislX9FLOXxMFWv9PVJo,1557
3
3
  model_compression_toolkit/constants.py,sha256=2ltuH-gdaLZoZV4CPUgKjC3S9ojz2z4OTVdenyVEypU,3912
4
4
  model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
5
5
  model_compression_toolkit/logger.py,sha256=L3q7tn3Uht0i_7phnlOWMR2Te2zvzrt2HOz9vYEInts,4529
@@ -435,13 +435,14 @@ model_compression_toolkit/target_platform_capabilities/constants.py,sha256=BFSgD
435
435
  model_compression_toolkit/target_platform_capabilities/immutable.py,sha256=YhROBiXEIB3TU-bAFrnL3qbAsb1yuWPBAQ_CLOJbYUU,1827
436
436
  model_compression_toolkit/target_platform_capabilities/tpc_io_handler.py,sha256=4ydTWWKv_PEOAFok2JtxFNj8rav-0IlqcXKF6lnhHNE,4157
437
437
  model_compression_toolkit/target_platform_capabilities/schema/__init__.py,sha256=pKAdbTCFM_2BrZXUtTIw0ouKotrWwUDF_hP3rPwCM2k,696
438
- model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py,sha256=PvO8eHxnb3A55gyExT5fZGnOUl3ce7BbbT5SPxCEXNo,541
438
+ model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py,sha256=hf539WJ3nBGn0RnALXrKmAPnbhJ-VmWmLIa207x8b4M,541
439
439
  model_compression_toolkit/target_platform_capabilities/schema/schema_functions.py,sha256=vBkXxVJagm9JKB9cdm4Pvi7u_luriXUjvNn0-m8Zr0k,4653
440
440
  model_compression_toolkit/target_platform_capabilities/schema/v1.py,sha256=4CGpWENuOyjwaIMaGrFI0Act7jsSeT7m94pjrv91dxE,27516
441
+ model_compression_toolkit/target_platform_capabilities/schema/v2.py,sha256=vUhCocA0EcjdR741Yv48W4Kr5Pq22Miebhm7F9GKb3Y,6086
441
442
  model_compression_toolkit/target_platform_capabilities/targetplatform2framework/__init__.py,sha256=XjNws3zoiJkeH4ixKqrLA5xBvpv5rq31qX7wYQjNpZM,1447
442
443
  model_compression_toolkit/target_platform_capabilities/targetplatform2framework/attach2fw.py,sha256=HJ8uc3PFfyxg-WpVXPBg4mGaox8Z9bRqtQNbRfIyAk4,3745
443
- model_compression_toolkit/target_platform_capabilities/targetplatform2framework/attach2keras.py,sha256=mxc3DBbUi-HDFgSx8Nmnyxr8SIdbx8lmtcRMsQl1BLE,7578
444
- model_compression_toolkit/target_platform_capabilities/targetplatform2framework/attach2pytorch.py,sha256=WPCqs_aFGE28XJf7KKB-SlrYoUNOcD9epgoaqQMCJMw,6320
444
+ model_compression_toolkit/target_platform_capabilities/targetplatform2framework/attach2keras.py,sha256=AE09QLE_QKwNqUTZbkZP9XLJStG1ECiTWmEGuXZTEsQ,7652
445
+ model_compression_toolkit/target_platform_capabilities/targetplatform2framework/attach2pytorch.py,sha256=-zbPmzQJal-1vZiQ6vIBBBnlEOB2DTb09koA0Aj4I_I,6396
445
446
  model_compression_toolkit/target_platform_capabilities/targetplatform2framework/attribute_filter.py,sha256=jfhszvuD2Fyy6W2KjlLzXBQKFzTqGAaDZeFVr4-ONQw,8776
446
447
  model_compression_toolkit/target_platform_capabilities/targetplatform2framework/current_tpc.py,sha256=_kFG0USYa6yzvLsi82_Vusv_KR8Hi7J1u680pPXECuo,2192
447
448
  model_compression_toolkit/target_platform_capabilities/targetplatform2framework/framework_quantization_capabilities.py,sha256=UKzckLYLdBcFAptyKnVMwpPpfRkmF0SK1Kl0g0eGjQA,9710
@@ -526,7 +527,7 @@ model_compression_toolkit/xquant/pytorch/model_analyzer.py,sha256=b93o800yVB3Z-i
526
527
  model_compression_toolkit/xquant/pytorch/pytorch_report_utils.py,sha256=UVN_S9ULHBEldBpShCOt8-soT8YTQ5oE362y96qF_FA,3950
527
528
  model_compression_toolkit/xquant/pytorch/similarity_functions.py,sha256=CERxq5K8rqaiE-DlwhZBTUd9x69dtYJlkHOPLB54vm8,2354
528
529
  model_compression_toolkit/xquant/pytorch/tensorboard_utils.py,sha256=mkoEktLFFHtEKzzFRn_jCnxjhJolK12TZ5AQeDHzUO8,9767
529
- mct_nightly-2.3.0.20250401.618.dist-info/METADATA,sha256=53LoSDV2ox7X64SeEb9OwP4UsuLi75QeSwyFLponCrQ,27098
530
- mct_nightly-2.3.0.20250401.618.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
531
- mct_nightly-2.3.0.20250401.618.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
532
- mct_nightly-2.3.0.20250401.618.dist-info/RECORD,,
530
+ mct_nightly-2.3.0.20250402.536.dist-info/METADATA,sha256=v7bHr6SXyb9qkbAmhb3xAHDXzinP-56xYnw-3SMtHVc,27098
531
+ mct_nightly-2.3.0.20250402.536.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
532
+ mct_nightly-2.3.0.20250402.536.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
533
+ mct_nightly-2.3.0.20250402.536.dist-info/RECORD,,
@@ -27,4 +27,4 @@ from model_compression_toolkit import data_generation
27
27
  from model_compression_toolkit import pruning
28
28
  from model_compression_toolkit.trainable_infrastructure.keras.load_model import keras_load_quantized_model
29
29
 
30
- __version__ = "2.3.0.20250401.000618"
30
+ __version__ = "2.3.0.20250402.000536"
@@ -1,4 +1,4 @@
1
- import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema
1
+ import model_compression_toolkit.target_platform_capabilities.schema.v2 as schema
2
2
 
3
3
  OperatorSetNames = schema.OperatorSetNames
4
4
  Signedness = schema.Signedness
@@ -0,0 +1,177 @@
1
+ # Copyright 2025 Sony Semiconductor Israel, Inc. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ # ==============================================================================
15
+ import pprint
16
+ from enum import Enum
17
+ from typing import Dict, Any, Tuple, Optional
18
+
19
+ from pydantic import BaseModel, root_validator
20
+
21
+ from mct_quantizers import QuantizationMethod
22
+ from model_compression_toolkit.constants import FLOAT_BITWIDTH
23
+ from model_compression_toolkit.logger import Logger
24
+ from model_compression_toolkit.target_platform_capabilities.schema.v1 import (
25
+ Signedness,
26
+ AttributeQuantizationConfig,
27
+ OpQuantizationConfig,
28
+ QuantizationConfigOptions,
29
+ TargetPlatformModelComponent,
30
+ OperatorsSetBase,
31
+ OperatorsSet,
32
+ OperatorSetGroup,
33
+ Fusing)
34
+
35
+
36
+ class OperatorSetNames(str, Enum):
37
+ CONV = "Conv"
38
+ DEPTHWISE_CONV = "DepthwiseConv2D"
39
+ CONV_TRANSPOSE = "ConvTranspose"
40
+ FULLY_CONNECTED = "FullyConnected"
41
+ CONCATENATE = "Concatenate"
42
+ STACK = "Stack"
43
+ UNSTACK = "Unstack"
44
+ GATHER = "Gather"
45
+ EXPAND = "Expend"
46
+ BATCH_NORM = "BatchNorm"
47
+ L2NORM = "L2Norm"
48
+ RELU = "ReLU"
49
+ RELU6 = "ReLU6"
50
+ LEAKY_RELU = "LeakyReLU"
51
+ ELU = "Elu"
52
+ HARD_TANH = "HardTanh"
53
+ ADD = "Add"
54
+ SUB = "Sub"
55
+ MUL = "Mul"
56
+ DIV = "Div"
57
+ MIN = "Min"
58
+ MAX = "Max"
59
+ PRELU = "PReLU"
60
+ ADD_BIAS = "AddBias"
61
+ SWISH = "Swish"
62
+ SIGMOID = "Sigmoid"
63
+ SOFTMAX = "Softmax"
64
+ LOG_SOFTMAX = "LogSoftmax"
65
+ TANH = "Tanh"
66
+ GELU = "Gelu"
67
+ HARDSIGMOID = "HardSigmoid"
68
+ HARDSWISH = "HardSwish"
69
+ FLATTEN = "Flatten"
70
+ GET_ITEM = "GetItem"
71
+ RESHAPE = "Reshape"
72
+ UNSQUEEZE = "Unsqueeze"
73
+ SQUEEZE = "Squeeze"
74
+ PERMUTE = "Permute"
75
+ TRANSPOSE = "Transpose"
76
+ DROPOUT = "Dropout"
77
+ SPLIT_CHUNK = "SplitChunk"
78
+ MAXPOOL = "MaxPool"
79
+ AVGPOOL = "AvgPool"
80
+ SIZE = "Size"
81
+ SHAPE = "Shape"
82
+ EQUAL = "Equal"
83
+ ARGMAX = "ArgMax"
84
+ TOPK = "TopK"
85
+ FAKE_QUANT = "FakeQuant"
86
+ COMBINED_NON_MAX_SUPPRESSION = "CombinedNonMaxSuppression"
87
+ BOX_DECODE = "BoxDecode"
88
+ ZERO_PADDING2D = "ZeroPadding2D"
89
+ CAST = "Cast"
90
+ RESIZE = "Resize"
91
+ PAD = "Pad"
92
+ FOLD = "Fold"
93
+ STRIDED_SLICE = "StridedSlice"
94
+ SSD_POST_PROCESS = "SSDPostProcess"
95
+
96
+ @classmethod
97
+ def get_values(cls):
98
+ return [v.value for v in cls]
99
+
100
+
101
+ class TargetPlatformCapabilities(BaseModel):
102
+ """
103
+ Represents the hardware configuration used for quantized model inference.
104
+
105
+ Attributes:
106
+ default_qco (QuantizationConfigOptions): Default quantization configuration options for the model.
107
+ operator_set (Optional[Tuple[OperatorsSet, ...]]): Tuple of operator sets within the model.
108
+ fusing_patterns (Optional[Tuple[Fusing, ...]]): Tuple of fusing patterns for the model.
109
+ tpc_minor_version (Optional[int]): Minor version of the Target Platform Configuration.
110
+ tpc_patch_version (Optional[int]): Patch version of the Target Platform Configuration.
111
+ tpc_platform_type (Optional[str]): Type of the platform for the Target Platform Configuration.
112
+ add_metadata (bool): Flag to determine if metadata should be added.
113
+ name (str): Name of the Target Platform Model.
114
+ is_simd_padding (bool): Indicates if SIMD padding is applied.
115
+ SCHEMA_VERSION (int): Version of the schema for the Target Platform Model.
116
+ """
117
+ default_qco: QuantizationConfigOptions
118
+ operator_set: Optional[Tuple[OperatorsSet, ...]]
119
+ fusing_patterns: Optional[Tuple[Fusing, ...]]
120
+ tpc_minor_version: Optional[int]
121
+ tpc_patch_version: Optional[int]
122
+ tpc_platform_type: Optional[str]
123
+ add_metadata: bool = True
124
+ name: Optional[str] = "default_tpc"
125
+ is_simd_padding: bool = False
126
+
127
+ SCHEMA_VERSION: int = 2
128
+
129
+ class Config:
130
+ frozen = True
131
+
132
+ @root_validator(allow_reuse=True)
133
+ def validate_after_initialization(cls, values: Dict[str, Any]) -> Dict[str, Any]:
134
+ """
135
+ Perform validation after the model has been instantiated.
136
+
137
+ Args:
138
+ values (Dict[str, Any]): The instantiated target platform model.
139
+
140
+ Returns:
141
+ Dict[str, Any]: The validated values.
142
+ """
143
+ # Validate `default_qco`
144
+ default_qco = values.get('default_qco')
145
+ if len(default_qco.quantization_configurations) != 1:
146
+ Logger.critical("Default QuantizationConfigOptions must contain exactly one option.") # pragma: no cover
147
+
148
+ # Validate `operator_set` uniqueness
149
+ operator_set = values.get('operator_set')
150
+ if operator_set is not None:
151
+ opsets_names = [
152
+ op.name.value if isinstance(op.name, OperatorSetNames) else op.name
153
+ for op in operator_set
154
+ ]
155
+ if len(set(opsets_names)) != len(opsets_names):
156
+ Logger.critical("Operator Sets must have unique names.") # pragma: no cover
157
+
158
+ return values
159
+
160
+ def get_info(self) -> Dict[str, Any]:
161
+ """
162
+ Get a dictionary summarizing the TargetPlatformCapabilities properties.
163
+
164
+ Returns:
165
+ Dict[str, Any]: Summary of the TargetPlatformCapabilities properties.
166
+ """
167
+ return {
168
+ "Model name": self.name,
169
+ "Operators sets": [o.get_info() for o in self.operator_set] if self.operator_set else [],
170
+ "Fusing patterns": [f.get_info() for f in self.fusing_patterns] if self.fusing_patterns else [],
171
+ }
172
+
173
+ def show(self):
174
+ """
175
+ Display the TargetPlatformCapabilities.
176
+ """
177
+ pprint.pprint(self.get_info(), sort_dicts=False)
@@ -93,6 +93,7 @@ class AttachTpcToKeras(AttachTpcToFramework):
93
93
  OperatorSetNames.TOPK: [tf.nn.top_k],
94
94
  OperatorSetNames.FAKE_QUANT: [tf.quantization.fake_quant_with_min_max_vars],
95
95
  OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION: [tf.image.combined_non_max_suppression],
96
+ OperatorSetNames.BOX_DECODE: [], # no such operator in keras
96
97
  OperatorSetNames.ZERO_PADDING2D: [ZeroPadding2D],
97
98
  OperatorSetNames.CAST: [tf.cast],
98
99
  OperatorSetNames.STRIDED_SLICE: [tf.strided_slice],
@@ -97,7 +97,8 @@ class AttachTpcToPytorch(AttachTpcToFramework):
97
97
  OperatorSetNames.L2NORM: [LayerFilterParams(torch.nn.functional.normalize,
98
98
  Eq('p', 2) | Eq('p', None))],
99
99
  OperatorSetNames.SSD_POST_PROCESS: [], # no such operator in pytorch
100
- OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION: [] # no such operator in pytorch
100
+ OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION: [], # no such operator in pytorch
101
+ OperatorSetNames.BOX_DECODE: [] # no such operator in pytorch
101
102
  }
102
103
 
103
104
  pytorch_linear_attr_mapping = {KERNEL_ATTR: DefaultDict(default_value=PYTORCH_KERNEL),