mct-nightly 1.10.0.20240101.post439__py3-none-any.whl → 1.10.0.20240102.post421__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.1
2
2
  Name: mct-nightly
3
- Version: 1.10.0.20240101.post439
3
+ Version: 1.10.0.20240102.post421
4
4
  Summary: A Model Compression Toolkit for neural networks
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -303,12 +303,12 @@ model_compression_toolkit/exporter/model_exporter/fw_agonstic/__init__.py,sha256
303
303
  model_compression_toolkit/exporter/model_exporter/fw_agonstic/exporter.py,sha256=eSC6gEMc9KY5EwVRam9pJCBpCm0ksUeobKV_JAOap9M,2017
304
304
  model_compression_toolkit/exporter/model_exporter/fw_agonstic/quantization_format.py,sha256=oRlw_LG0UNi8Vl77E1U6WDBsEp1eNaphUbG9rSZkSl4,800
305
305
  model_compression_toolkit/exporter/model_exporter/keras/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
306
- model_compression_toolkit/exporter/model_exporter/keras/base_keras_exporter.py,sha256=Are89mV0cPZ11PSHnriWCMJzTLPhughxZNwdEo_aqU8,1690
307
- model_compression_toolkit/exporter/model_exporter/keras/export_serialization_format.py,sha256=mfc-0Mmajt4fstbwQPWGbeZYb4yexij8Fkv-Vll7sNk,1014
306
+ model_compression_toolkit/exporter/model_exporter/keras/base_keras_exporter.py,sha256=-wr2n0yRlmFixXBeZuxg6Rzlvz-ZFUX-PJgSXhgMrEo,1593
307
+ model_compression_toolkit/exporter/model_exporter/keras/export_serialization_format.py,sha256=v_-rOsWDFI-3k8CoJIr-XzT7ny8WXpAMteWRWtTzaeg,963
308
308
  model_compression_toolkit/exporter/model_exporter/keras/fakely_quant_keras_exporter.py,sha256=E_1IqFYAGUMOrt3U_JK1k--8D0WzWPbjZH_IRLGw_wY,11478
309
- model_compression_toolkit/exporter/model_exporter/keras/fakely_quant_tflite_exporter.py,sha256=qiWyiIp-WLDj1r924oeQc-M4WCi-HTk2vw0ISipy7Nk,3196
309
+ model_compression_toolkit/exporter/model_exporter/keras/fakely_quant_tflite_exporter.py,sha256=lwwbEAmPmlU89DXmBjmDT6Yk1W6ss96LQ52oAHxvtFw,3209
310
310
  model_compression_toolkit/exporter/model_exporter/keras/int8_tflite_exporter.py,sha256=nGtpDTeH5Tdp7sjyuXsy_9TPpijDYp4nkz366DUUJ0Q,8048
311
- model_compression_toolkit/exporter/model_exporter/keras/keras_export_facade.py,sha256=mJdiih4jQ_pr6r5PxQE4TipqpCzsH4S3Qq7zpi-8MRs,6007
311
+ model_compression_toolkit/exporter/model_exporter/keras/keras_export_facade.py,sha256=O-GApieS7_zLkpygnN0YvDK-HkCChwA4bSExbI5jvQ8,5998
312
312
  model_compression_toolkit/exporter/model_exporter/keras/mctq_keras_exporter.py,sha256=qXXkv3X_wb7t622EOHwXIxfGLGaDqh0T0y4UxREi4Bo,1976
313
313
  model_compression_toolkit/exporter/model_exporter/pytorch/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
314
314
  model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=UPVkEUQCMZ4Lld6CRnEOPEmlfe5vcQZG0Q3FwRBodD4,4021
@@ -474,8 +474,8 @@ model_compression_toolkit/trainable_infrastructure/keras/quantize_wrapper.py,sha
474
474
  model_compression_toolkit/trainable_infrastructure/keras/quantizer_utils.py,sha256=MVwXNymmFRB2NXIBx4e2mdJ1RfoHxRPYRgjb1MQP5kY,1797
475
475
  model_compression_toolkit/trainable_infrastructure/pytorch/__init__.py,sha256=huHoBUcKNB6BnY6YaUCcFvdyBtBI172ZoUD8ZYeNc6o,696
476
476
  model_compression_toolkit/trainable_infrastructure/pytorch/base_pytorch_quantizer.py,sha256=SbvRlIdE32PEBsINt1bhSqvrKL_zbM9V-aeSkOn-sw4,3083
477
- mct_nightly-1.10.0.20240101.post439.dist-info/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
478
- mct_nightly-1.10.0.20240101.post439.dist-info/METADATA,sha256=JJl4aiW3kYdqZ4N8m_Fn-fPvOPHjS4AP6Dd4vjS8gCM,17141
479
- mct_nightly-1.10.0.20240101.post439.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
480
- mct_nightly-1.10.0.20240101.post439.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
481
- mct_nightly-1.10.0.20240101.post439.dist-info/RECORD,,
477
+ mct_nightly-1.10.0.20240102.post421.dist-info/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
478
+ mct_nightly-1.10.0.20240102.post421.dist-info/METADATA,sha256=Wo83EPwubPoSUM-v8xvhW2zuWl0M4cOeXNlnEwtlvyw,17141
479
+ mct_nightly-1.10.0.20240102.post421.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
480
+ mct_nightly-1.10.0.20240102.post421.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
481
+ mct_nightly-1.10.0.20240102.post421.dist-info/RECORD,,
@@ -19,10 +19,8 @@ import keras
19
19
 
20
20
  import tensorflow as tf
21
21
  from packaging import version
22
- if version.parse(tf.__version__) >= version.parse("2.13"):
23
- TMP_KERAS_EXPORT_FORMAT = ".keras"
24
- else:
25
- TMP_KERAS_EXPORT_FORMAT = ".h5"
22
+
23
+ DEFAULT_KERAS_EXPORT_EXTENTION = '.keras'
26
24
 
27
25
 
28
26
  class BaseKerasExporter(Exporter):
@@ -19,11 +19,11 @@ class KerasExportSerializationFormat(Enum):
19
19
  """
20
20
  Specify which serialization format to use for exporting a quantized Keras model.
21
21
 
22
- KERAS_H5 - .keras (TF2.13 and above) or .h5 (TF2.12 and below) file format
22
+ KERAS - .keras file format
23
23
 
24
24
  TFLITE - .tflite file format
25
25
 
26
26
  """
27
27
 
28
- KERAS_H5 = 0
28
+ KERAS = 0
29
29
  TFLITE = 1
@@ -20,10 +20,9 @@ import tensorflow as tf
20
20
  import keras.models
21
21
 
22
22
  from model_compression_toolkit.logger import Logger
23
- from model_compression_toolkit.exporter.model_exporter.keras.base_keras_exporter import TMP_KERAS_EXPORT_FORMAT
24
23
  from model_compression_toolkit.exporter.model_exporter.keras.fakely_quant_keras_exporter import FakelyQuantKerasExporter
25
24
  from model_compression_toolkit.trainable_infrastructure.keras.load_model import keras_load_quantized_model
26
-
25
+ from model_compression_toolkit.exporter.model_exporter.keras.base_keras_exporter import DEFAULT_KERAS_EXPORT_EXTENTION
27
26
 
28
27
  class FakelyQuantTFLiteExporter(FakelyQuantKerasExporter):
29
28
  """
@@ -58,7 +57,7 @@ class FakelyQuantTFLiteExporter(FakelyQuantKerasExporter):
58
57
  """
59
58
  # Use Keras exporter to quantize model's weights before converting it to TFLite.
60
59
  # Since exporter saves the model, we use a tmp path for saving, and then we delete it automatically.
61
- with tempfile.NamedTemporaryFile(suffix=TMP_KERAS_EXPORT_FORMAT) as tmp_file:
60
+ with tempfile.NamedTemporaryFile(suffix=DEFAULT_KERAS_EXPORT_EXTENTION) as tmp_file:
62
61
  FakelyQuantKerasExporter(self.model,
63
62
  self.is_layer_exportable_fn,
64
63
  tmp_file.name,
@@ -32,14 +32,14 @@ if FOUND_TF:
32
32
  from model_compression_toolkit.exporter.model_exporter.keras.mctq_keras_exporter import MCTQKerasExporter
33
33
 
34
34
  supported_serialization_quantization_export_dict = {
35
- KerasExportSerializationFormat.KERAS_H5: [QuantizationFormat.FAKELY_QUANT, QuantizationFormat.MCTQ],
35
+ KerasExportSerializationFormat.KERAS: [QuantizationFormat.FAKELY_QUANT, QuantizationFormat.MCTQ],
36
36
  KerasExportSerializationFormat.TFLITE: [QuantizationFormat.FAKELY_QUANT, QuantizationFormat.INT8]
37
37
  }
38
38
 
39
39
  def keras_export_model(model: keras.models.Model,
40
40
  save_model_path: str,
41
41
  is_layer_exportable_fn: Callable = is_keras_layer_exportable,
42
- serialization_format: KerasExportSerializationFormat = KerasExportSerializationFormat.KERAS_H5,
42
+ serialization_format: KerasExportSerializationFormat = KerasExportSerializationFormat.KERAS,
43
43
  quantization_format : QuantizationFormat = QuantizationFormat.MCTQ) -> Dict[str, type]:
44
44
  """
45
45
  Export a Keras quantized model to a h5 or tflite model.
@@ -63,7 +63,7 @@ if FOUND_TF:
63
63
 
64
64
  """
65
65
 
66
- if serialization_format == KerasExportSerializationFormat.KERAS_H5:
66
+ if serialization_format == KerasExportSerializationFormat.KERAS:
67
67
  if quantization_format == QuantizationFormat.FAKELY_QUANT:
68
68
  exporter = FakelyQuantKerasExporter(model,
69
69
  is_layer_exportable_fn,