mct-nightly 2.3.0.20250429.622__py3-none-any.whl → 2.3.0.20250430.538__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.20250429.622
3
+ Version: 2.3.0.20250430.538
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.20250429.622.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
- model_compression_toolkit/__init__.py,sha256=PrThtvqTwsbfiKBPdckZFWhbBXaRfAATT21j_WbV8pA,1557
1
+ mct_nightly-2.3.0.20250430.538.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
+ model_compression_toolkit/__init__.py,sha256=_uN22zhCLe0oS_Ex9lxOL4jmaLZUIfp9zJ82XXgBrqQ,1557
3
3
  model_compression_toolkit/constants.py,sha256=iJ6vfTjC2oFIZWt8wvHoxEw5YJi3yl0Hd4q30_8q0Zc,3958
4
4
  model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
5
5
  model_compression_toolkit/logger.py,sha256=L3q7tn3Uht0i_7phnlOWMR2Te2zvzrt2HOz9vYEInts,4529
@@ -335,7 +335,7 @@ model_compression_toolkit/exporter/model_exporter/keras/mctq_keras_exporter.py,s
335
335
  model_compression_toolkit/exporter/model_exporter/pytorch/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
336
336
  model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=UPVkEUQCMZ4Lld6CRnEOPEmlfe5vcQZG0Q3FwRBodD4,4021
337
337
  model_compression_toolkit/exporter/model_exporter/pytorch/export_serialization_format.py,sha256=bPevy6OBqng41PqytBR55e6cBEuyrUS0H8dWX4zgjQ4,967
338
- model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=G2X_lDx6u12U4ErEuEHCdNczh0qSGWObySw3upEys6Q,7506
338
+ model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=5DHg8ch8_DtSQ7M5Aw3LcZLSVFqFH556cKcosp3Ik-I,8720
339
339
  model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_torchscript_pytorch_exporter.py,sha256=ksWV2A-Njo-wAxQ_Ye2sLIZXBWJ_WNyjT7-qFFwvV2o,2897
340
340
  model_compression_toolkit/exporter/model_exporter/pytorch/pytorch_export_facade.py,sha256=8vYGKa58BkasvoHejYaPwubOJPcW0s-RY79_Kkw0Hy8,6236
341
341
  model_compression_toolkit/exporter/model_wrapper/__init__.py,sha256=7CF2zvpTrIEm8qnbuHnLZyTZkwBBxV24V8QA0oxGbh0,1187
@@ -528,7 +528,7 @@ model_compression_toolkit/xquant/pytorch/model_analyzer.py,sha256=b93o800yVB3Z-i
528
528
  model_compression_toolkit/xquant/pytorch/pytorch_report_utils.py,sha256=UVN_S9ULHBEldBpShCOt8-soT8YTQ5oE362y96qF_FA,3950
529
529
  model_compression_toolkit/xquant/pytorch/similarity_functions.py,sha256=CERxq5K8rqaiE-DlwhZBTUd9x69dtYJlkHOPLB54vm8,2354
530
530
  model_compression_toolkit/xquant/pytorch/tensorboard_utils.py,sha256=mkoEktLFFHtEKzzFRn_jCnxjhJolK12TZ5AQeDHzUO8,9767
531
- mct_nightly-2.3.0.20250429.622.dist-info/METADATA,sha256=R9WTA_IVw4cvLIbQbGpmzTl_ujwHc4RNElUajWHnSNE,25101
532
- mct_nightly-2.3.0.20250429.622.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
533
- mct_nightly-2.3.0.20250429.622.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
534
- mct_nightly-2.3.0.20250429.622.dist-info/RECORD,,
531
+ mct_nightly-2.3.0.20250430.538.dist-info/METADATA,sha256=8l9P7bLANjVXo-Z5_aR8x8VtcIWHhdYNNHQmoOS6cig,25101
532
+ mct_nightly-2.3.0.20250430.538.dist-info/WHEEL,sha256=ck4Vq1_RXyvS4Jt6SI0Vz6fyVs4GWg7AINwpsaGEgPE,91
533
+ mct_nightly-2.3.0.20250430.538.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
534
+ mct_nightly-2.3.0.20250430.538.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.20250429.000622"
30
+ __version__ = "2.3.0.20250430.000538"
@@ -24,11 +24,11 @@ from model_compression_toolkit.core.pytorch.utils import to_torch_tensor
24
24
  from model_compression_toolkit.exporter.model_exporter.pytorch.base_pytorch_exporter import BasePyTorchExporter
25
25
  from mct_quantizers import pytorch_quantizers
26
26
 
27
-
28
27
  if FOUND_ONNX:
29
28
  import onnx
30
29
  from mct_quantizers.pytorch.metadata import add_onnx_metadata
31
30
 
31
+
32
32
  class FakelyQuantONNXPyTorchExporter(BasePyTorchExporter):
33
33
  """
34
34
  Exporter for fakely-quant PyTorch models.
@@ -63,7 +63,7 @@ if FOUND_ONNX:
63
63
  self._use_onnx_custom_quantizer_ops = use_onnx_custom_quantizer_ops
64
64
  self._onnx_opset_version = onnx_opset_version
65
65
 
66
- def export(self) -> None:
66
+ def export(self, output_names=None) -> None:
67
67
  """
68
68
  Convert an exportable (fully-quantized) PyTorch model to a fakely-quant model
69
69
  (namely, weights that are in fake-quant format) and fake-quant layers for the activations.
@@ -95,6 +95,28 @@ if FOUND_ONNX:
95
95
  Logger.info(f"Exporting fake-quant onnx model: {self.save_model_path}")
96
96
 
97
97
  model_input = to_torch_tensor(next(self.repr_dataset()))
98
+ model_output = self.model(*model_input) if isinstance(model_input, (list, tuple)) else self.model(
99
+ model_input)
100
+
101
+ if output_names is None:
102
+ # Determine number of outputs and prepare output_names and dynamic_axes
103
+ if isinstance(model_output, (list, tuple)):
104
+ output_names = [f"output_{i}" for i in range(len(model_output))]
105
+ dynamic_axes = {'input': {0: 'batch_size'}}
106
+ dynamic_axes.update({name: {0: 'batch_size'} for name in output_names})
107
+ else:
108
+ output_names = ['output']
109
+ dynamic_axes = {'input': {0: 'batch_size'}, 'output': {0: 'batch_size'}}
110
+ else:
111
+ if isinstance(model_output, (list, tuple)):
112
+ num_of_outputs = len(model_output)
113
+ else:
114
+ num_of_outputs = 1
115
+ assert len(output_names) == num_of_outputs, (f"Mismatch between number of requested output names "
116
+ f"({output_names}) and model output count "
117
+ f"({num_of_outputs}):\n")
118
+ dynamic_axes = {'input': {0: 'batch_size'}}
119
+ dynamic_axes.update({name: {0: 'batch_size'} for name in output_names})
98
120
 
99
121
  if hasattr(self.model, 'metadata'):
100
122
  onnx_bytes = BytesIO()
@@ -104,9 +126,8 @@ if FOUND_ONNX:
104
126
  opset_version=self._onnx_opset_version,
105
127
  verbose=False,
106
128
  input_names=['input'],
107
- output_names=['output'],
108
- dynamic_axes={'input': {0: 'batch_size'},
109
- 'output': {0: 'batch_size'}})
129
+ output_names=output_names,
130
+ dynamic_axes=dynamic_axes)
110
131
  onnx_model = onnx.load_from_string(onnx_bytes.getvalue())
111
132
  onnx_model = add_onnx_metadata(onnx_model, self.model.metadata)
112
133
  onnx.save_model(onnx_model, self.save_model_path)
@@ -117,9 +138,8 @@ if FOUND_ONNX:
117
138
  opset_version=self._onnx_opset_version,
118
139
  verbose=False,
119
140
  input_names=['input'],
120
- output_names=['output'],
121
- dynamic_axes={'input': {0: 'batch_size'},
122
- 'output': {0: 'batch_size'}})
141
+ output_names=output_names,
142
+ dynamic_axes=dynamic_axes)
123
143
 
124
144
  for layer in self.model.children():
125
145
  # Set disable for reuse for weight quantizers if quantizer was reused