mct-nightly 2.3.0.20250425.557__py3-none-any.whl → 2.3.0.20250427.609__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.20250425.557
3
+ Version: 2.3.0.20250427.609
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.20250425.557.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
- model_compression_toolkit/__init__.py,sha256=kXjmCqsExE8DYRx8JTVs4AhVXF1GF94SPL9EcfyLeks,1557
1
+ mct_nightly-2.3.0.20250427.609.dist-info/licenses/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
2
+ model_compression_toolkit/__init__.py,sha256=n5rc5Vyh3AmYQB3AKBl-pAmV5IKGzeqqRm3AOQFlSa4,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
@@ -233,7 +233,7 @@ model_compression_toolkit/core/pytorch/back2framework/factory_model_builder.py,s
233
233
  model_compression_toolkit/core/pytorch/back2framework/float_model_builder.py,sha256=tLrlUyYhxVKVjkad1ZAtbRra0HedB3iVfIkZ_dYnQ-4,3419
234
234
  model_compression_toolkit/core/pytorch/back2framework/instance_builder.py,sha256=BBHBfTqeWm7L3iDyPBpk0jxvj-rBg1QWI23imkjfIl0,1467
235
235
  model_compression_toolkit/core/pytorch/back2framework/mixed_precision_model_builder.py,sha256=K4L8FzJFM8_Ge2MHYkSqzCtoZe-ejEhVq8C1RgecyOc,14531
236
- model_compression_toolkit/core/pytorch/back2framework/pytorch_model_builder.py,sha256=WccaNiHK12IIimYu29E1oJkQHUdhPCBcIRutefTQ3Ag,19903
236
+ model_compression_toolkit/core/pytorch/back2framework/pytorch_model_builder.py,sha256=9l5ZsEd4lwCSzT6VNItj5rw996BI_eH71x_uV-4gIRM,21101
237
237
  model_compression_toolkit/core/pytorch/back2framework/quantized_model_builder.py,sha256=qZNNOlNTTV4ZKPG3q5GDXkIVTPUEr8dvxAS_YiMORmg,3456
238
238
  model_compression_toolkit/core/pytorch/back2framework/quantization_wrapper/__init__.py,sha256=cco4TmeIDIh32nj9ZZXVkws4dd9F2UDrmjKzTN8G0V0,697
239
239
  model_compression_toolkit/core/pytorch/back2framework/quantization_wrapper/quantized_layer_wrapper.py,sha256=q2JDw10NKng50ee2i9faGzWZ-IydnR2aOMGSn9RoZmc,5773
@@ -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.20250425.557.dist-info/METADATA,sha256=3W1evd1H2JL0wpqb1frzmmX5nz2fqHcMib1y3remRt8,25560
532
- mct_nightly-2.3.0.20250425.557.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
533
- mct_nightly-2.3.0.20250425.557.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
534
- mct_nightly-2.3.0.20250425.557.dist-info/RECORD,,
531
+ mct_nightly-2.3.0.20250427.609.dist-info/METADATA,sha256=uT9gv4F4QKU-7z2fkoBSftfQMo-eUFG_n2ANL1X9DbA,25560
532
+ mct_nightly-2.3.0.20250427.609.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
533
+ mct_nightly-2.3.0.20250427.609.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
534
+ mct_nightly-2.3.0.20250427.609.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.20250425.000557"
30
+ __version__ = "2.3.0.20250427.000609"
@@ -234,7 +234,9 @@ class PytorchModel(torch.nn.Module):
234
234
  self.wrapper = wrapper
235
235
  self.get_activation_quantizer_holder = get_activation_quantizer_holder_fn
236
236
  self.reuse_groups = {}
237
- self._add_modules()
237
+ self._reused_nodes = []
238
+
239
+ self._add_all_modules()
238
240
 
239
241
  # todo: Move to parent class BaseModelBuilder
240
242
  @property
@@ -286,17 +288,37 @@ class PytorchModel(torch.nn.Module):
286
288
  node_op = self.wrapper(node, node_builder(node))
287
289
  return node_op
288
290
 
289
- def _add_modules(self):
291
+ def _add_all_modules(self):
292
+ """
293
+ Build and add the modules and functional nodes from node_sort list as attributes to PytorchModel.
294
+ To assure all required nodes for the reused nodes are already initialized, adds none-reused nodes first,
295
+ then adds the reused nodes.
296
+ """
297
+ self._add_modules(reused_nodes_only=False) # add none-reused nodes
298
+ self._add_modules(reused_nodes_only=True) # add reused nodes
299
+
300
+ def _add_modules(self, reused_nodes_only=False):
290
301
  """
291
302
  Build and add the modules and functional nodes from node_sort list as attributes to PytorchModel
303
+ Args:
304
+ reused_nodes_only: whether to go over the reuse nodes list or not.
305
+ In case reuse_nodes_only is False - will go over all nodes, and add reused nodes to self._reused_nodes
306
+ In case reuse_nodes_only is True - will go over self._reused_nodes only.
307
+
292
308
  """
293
- for node in self.node_sort:
294
- if node.reuse:
295
- # If the node is reused, retrieve the original module
309
+ nodes = self._reused_nodes if reused_nodes_only else self.node_sort
310
+ for node in nodes:
311
+ if node.reuse and reused_nodes_only:
296
312
  if node.reuse_group not in self.reuse_groups:
297
- Logger.critical(f"Reuse group {node.reuse_group} not found for node {node.name}")
313
+ raise Exception(f"Reuse group {node.reuse_group} not found for node {node.name}. "
314
+ f"Make sure you first call the method with reused_nodes_only=False")
315
+ else:
316
+ node_op = self.reuse_groups[node.reuse_group] # retrieve the original module
317
+
318
+ elif node.reuse: # add node to reused list, and go over the list after all other nodes were created
319
+ self._reused_nodes.append(node)
320
+ continue
298
321
 
299
- node_op = self.reuse_groups[node.reuse_group]
300
322
  else:
301
323
  # If it's not reused, create a new module
302
324
  node_op = self.wrap(node)