mct-nightly 2.3.0.20250522.558__py3-none-any.whl → 2.3.0.20250523.601__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.20250522.558
3
+ Version: 2.3.0.20250523.601
4
4
  Summary: A Model Compression Toolkit for neural networks
5
5
  Author-email: ssi-dnn-dev@sony.com
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,5 +1,5 @@
1
- mct_nightly-2.3.0.20250522.558.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
- model_compression_toolkit/__init__.py,sha256=4LBAGa7M1gM4u9CTm2gQ9xxa8wcgUq9dZ6rw3Yn3U1o,1557
1
+ mct_nightly-2.3.0.20250523.601.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
+ model_compression_toolkit/__init__.py,sha256=kbat4rP9HQwW-TV_lhwH8T2LSub816Le2SOMWSMjsW8,1557
3
3
  model_compression_toolkit/constants.py,sha256=KNgiNLpsMgSYyXMNEbHXd4bFNerQc1D6HH3vpbUq_Gs,4086
4
4
  model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
5
5
  model_compression_toolkit/logger.py,sha256=L3q7tn3Uht0i_7phnlOWMR2Te2zvzrt2HOz9vYEInts,4529
@@ -333,11 +333,11 @@ model_compression_toolkit/exporter/model_exporter/keras/int8_tflite_exporter.py,
333
333
  model_compression_toolkit/exporter/model_exporter/keras/keras_export_facade.py,sha256=NzcX7rxLk__Kpuim_VXaOHS4tyiRtRBoERPE00GbdfA,5862
334
334
  model_compression_toolkit/exporter/model_exporter/keras/mctq_keras_exporter.py,sha256=qXXkv3X_wb7t622EOHwXIxfGLGaDqh0T0y4UxREi4Bo,1976
335
335
  model_compression_toolkit/exporter/model_exporter/pytorch/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
336
- model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=UPVkEUQCMZ4Lld6CRnEOPEmlfe5vcQZG0Q3FwRBodD4,4021
336
+ model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=kmddLPXN47b4UOlip8u7zfILcw7rvKHp5UZ_-nII_9U,5369
337
337
  model_compression_toolkit/exporter/model_exporter/pytorch/export_serialization_format.py,sha256=bPevy6OBqng41PqytBR55e6cBEuyrUS0H8dWX4zgjQ4,967
338
338
  model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=v6DwLNZX5RcWHUfYXfJZXNFXPfHsMm5Wl0N29o0diSc,8856
339
339
  model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_torchscript_pytorch_exporter.py,sha256=ksWV2A-Njo-wAxQ_Ye2sLIZXBWJ_WNyjT7-qFFwvV2o,2897
340
- model_compression_toolkit/exporter/model_exporter/pytorch/pytorch_export_facade.py,sha256=I2YZOwzTMLcclGJoruFrHJlOt5mepodX7mGw_GbnqxA,6372
340
+ model_compression_toolkit/exporter/model_exporter/pytorch/pytorch_export_facade.py,sha256=7xuUrHPMiifn23sWfeiqR9wkYhm8EweDRL_vF-JSxMY,6642
341
341
  model_compression_toolkit/exporter/model_wrapper/__init__.py,sha256=7CF2zvpTrIEm8qnbuHnLZyTZkwBBxV24V8QA0oxGbh0,1187
342
342
  model_compression_toolkit/exporter/model_wrapper/fw_agnostic/__init__.py,sha256=pKAdbTCFM_2BrZXUtTIw0ouKotrWwUDF_hP3rPwCM2k,696
343
343
  model_compression_toolkit/exporter/model_wrapper/fw_agnostic/get_inferable_quantizers.py,sha256=Bd3QhAR__YC9Xmobd5qHv9ofh_rPn_eTFV0sXizcBnY,2297
@@ -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.20250522.558.dist-info/METADATA,sha256=49TbF1ArMZd_en-qSBIOFeQZ9B4jj94bjOABrQcggx4,25135
532
- mct_nightly-2.3.0.20250522.558.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
533
- mct_nightly-2.3.0.20250522.558.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
534
- mct_nightly-2.3.0.20250522.558.dist-info/RECORD,,
531
+ mct_nightly-2.3.0.20250523.601.dist-info/METADATA,sha256=G5J-yLvF68u133KBY6u5mACfZlFlONNxsM9ZoQZznUk,25135
532
+ mct_nightly-2.3.0.20250523.601.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
533
+ mct_nightly-2.3.0.20250523.601.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
534
+ mct_nightly-2.3.0.20250523.601.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.20250522.000558"
30
+ __version__ = "2.3.0.20250523.000601"
@@ -19,8 +19,42 @@ import torch.nn
19
19
 
20
20
  from mct_quantizers import PytorchQuantizationWrapper
21
21
  from mct_quantizers.common.constants import LAYER, WEIGHTS_QUANTIZERS
22
+ from model_compression_toolkit.logger import Logger
22
23
  from model_compression_toolkit.exporter.model_exporter.fw_agonstic.exporter import Exporter
23
24
 
25
+ def find_and_assign_metadata_attr(model: torch.nn.Module, attr_name: str = 'metadata'):
26
+ """
27
+ Searches for a given attribute in the model and its submodules.
28
+ If found, assigns the first occurrence to the top-level model under the same attribute name.
29
+ Warn if the attribute is not found or found in multiple places.
30
+
31
+ Args:
32
+ model (torch.nn.Module): The model to search.
33
+ attr_name (str): The name of the attribute to look for. Default is 'metadata'.
34
+ """
35
+ found_attrs = []
36
+
37
+ def _search(m):
38
+ """Recursively search the model and its submodules for the attribute."""
39
+ if hasattr(m, attr_name):
40
+ found_attrs.append(getattr(m, attr_name))
41
+ for child in m.children():
42
+ _search(child)
43
+
44
+ _search(model)
45
+
46
+ if not found_attrs:
47
+ # Warn if the attribute was not found anywhere
48
+ Logger.warning(f"Attribute '{attr_name}' not found in the model or its submodules.")
49
+ else:
50
+ setattr(model, attr_name, found_attrs[0])
51
+
52
+ if len(found_attrs) > 1:
53
+ # Warn if the attribute was found in multiple places
54
+ Logger.warning(
55
+ f"Attribute '{attr_name}' found in {len(found_attrs)} places. "
56
+ f"Only the first one was assigned to 'model.metadata'.")
57
+
24
58
 
25
59
  def _set_quantized_weights_in_wrapper(layer:PytorchQuantizationWrapper):
26
60
  """
@@ -30,6 +30,8 @@ if FOUND_TORCH:
30
30
  from model_compression_toolkit.exporter.model_exporter.pytorch.fakely_quant_onnx_pytorch_exporter import FakelyQuantONNXPyTorchExporter
31
31
  from model_compression_toolkit.exporter.model_exporter.pytorch.fakely_quant_torchscript_pytorch_exporter import FakelyQuantTorchScriptPyTorchExporter
32
32
  from model_compression_toolkit.exporter.model_wrapper.pytorch.validate_layer import is_pytorch_layer_exportable
33
+ from model_compression_toolkit.exporter.model_exporter.pytorch.base_pytorch_exporter import \
34
+ find_and_assign_metadata_attr
33
35
 
34
36
  if version.parse(torch.__version__) >= version.parse("2.4"):
35
37
  DEFAULT_ONNX_OPSET_VERSION = 20
@@ -65,6 +67,8 @@ if FOUND_TORCH:
65
67
  onnx_opset_version: ONNX opset version to use for exported ONNX model.
66
68
 
67
69
  """
70
+ # Ensure 'metadata' is available directly on the model, if present in submodules
71
+ find_and_assign_metadata_attr(model)
68
72
 
69
73
  if serialization_format == PytorchExportSerializationFormat.TORCHSCRIPT:
70
74
  if quantization_format in supported_serialization_quantization_export_dict[serialization_format]: