mct-nightly 2.0.0.20240403.423__py3-none-any.whl → 2.0.0.20240404.424__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: 2.0.0.20240403.423
3
+ Version: 2.0.0.20240404.424
4
4
  Summary: A Model Compression Toolkit for neural networks
5
5
  Home-page: UNKNOWN
6
6
  License: UNKNOWN
@@ -1,16 +1,15 @@
1
- model_compression_toolkit/__init__.py,sha256=rr-lU1cO0RuS_7QNw41uShlq2s0ILvvtATqaUT-NKzo,1573
1
+ model_compression_toolkit/__init__.py,sha256=lJlwXgpNCKdbNOfoMIxzBiVzQu9sxWFTlnhSNS2ky00,1573
2
2
  model_compression_toolkit/constants.py,sha256=KW_HUEPmQEYqCvWGyORqkYxpvO7w5LViB5J5D-pm_6o,3648
3
3
  model_compression_toolkit/defaultdict.py,sha256=LSc-sbZYXENMCw3U9F4GiXuv67IKpdn0Qm7Fr11jy-4,2277
4
4
  model_compression_toolkit/logger.py,sha256=3DByV41XHRR3kLTJNbpaMmikL8icd9e1N-nkQAY9oDk,4567
5
5
  model_compression_toolkit/core/__init__.py,sha256=TrRgkWpT1AN2Faw1M_1HXyJkJnbxfn9p-RigDZl7pg0,1982
6
6
  model_compression_toolkit/core/analyzer.py,sha256=dbsD61pakp_9JXNyAScLdtJvcXny9jr_cMbET0Bd3Sg,2975
7
- model_compression_toolkit/core/exporter.py,sha256=Zo_C5GjIzihtJOyGp-xeCVhY_qohkVz_EGyrSZCbWRM,4115
8
7
  model_compression_toolkit/core/graph_prep_runner.py,sha256=Ftqm59hT5TGWmSNkY9bFZkVfCacpGyZfCe-6yZR5WY0,10100
9
8
  model_compression_toolkit/core/quantization_prep_runner.py,sha256=hFhDkS8GwzXZ7Ho_9qbbb8DAAWs3OONOfMSD5OU_b0o,6153
10
9
  model_compression_toolkit/core/runner.py,sha256=NKSC6ujfQPy6dKtJVwxyK2zNDd64eyR5csYy9lBrCPA,11836
11
10
  model_compression_toolkit/core/common/__init__.py,sha256=Wh127PbXcETZX_d1PQqZ71ETK3J9XO5A-HpadGUbj6o,1447
12
11
  model_compression_toolkit/core/common/base_substitutions.py,sha256=xDFSmVVs_iFSZfajytI0cuQaNRNcwHX3uqOoHgVUvxQ,1666
13
- model_compression_toolkit/core/common/framework_implementation.py,sha256=njBP3elCFiSHyT2Y9zT1ISyDeQFR3j5UzPR4XQK2KnY,21152
12
+ model_compression_toolkit/core/common/framework_implementation.py,sha256=pOT9ZmRFL9FY92uUtigrO3sbWGiyVDhHAM1fbA4b5yo,20752
14
13
  model_compression_toolkit/core/common/framework_info.py,sha256=1ZMMGS9ip-kSflqkartyNRt9aQ5ub1WepuTRcTy-YSQ,6337
15
14
  model_compression_toolkit/core/common/memory_computation.py,sha256=ixoSpV5ZYZGyzhre3kQcvR2sNA8KBsPZ3lgbkDnw9Cs,1205
16
15
  model_compression_toolkit/core/common/model_builder_mode.py,sha256=jll9-59OPaE3ug7Y9-lLyV99_FoNHxkGZMgcm0Vkpss,1324
@@ -149,7 +148,7 @@ model_compression_toolkit/core/keras/__init__.py,sha256=mjbqLD-KcG3eNeCYpu1GBS7V
149
148
  model_compression_toolkit/core/keras/constants.py,sha256=Uv3c0UdW55pIVQNW_1HQlgl-dHXREkltOLyzp8G1mTQ,3163
150
149
  model_compression_toolkit/core/keras/custom_layer_validation.py,sha256=f-b14wuiIgitBe7d0MmofYhDCTO3IhwJgwrh-Hq_t_U,1192
151
150
  model_compression_toolkit/core/keras/default_framework_info.py,sha256=Ha4HTHuiw_KTS5Po1Xnv6GyK9eprpDhYWf-eooS62Ys,4961
152
- model_compression_toolkit/core/keras/keras_implementation.py,sha256=wg5ZkmQZc15w8k_VkXwAhfHQbZL3gpZZblYv_70-qxA,29399
151
+ model_compression_toolkit/core/keras/keras_implementation.py,sha256=NDHLl19I-xQrQGcsAwTcFjnIjCRn31xaPrqDYm8g_dg,29027
153
152
  model_compression_toolkit/core/keras/keras_model_validation.py,sha256=1wNV2clFdC9BzIELRLSO2uKf0xqjLqlkTJudwtCeaJk,1722
154
153
  model_compression_toolkit/core/keras/keras_node_prior_info.py,sha256=Aqh31wOPaiZcJIOm-uJwzev0eTMdJyXaOk97rs4z7BU,3879
155
154
  model_compression_toolkit/core/keras/resource_utilization_data_facade.py,sha256=Xmk2ZL5CaYdb7iG62HdtZ1F64vap7ffnrsuR3e3G5hc,4851
@@ -173,7 +172,6 @@ model_compression_toolkit/core/keras/graph_substitutions/substitutions/linear_co
173
172
  model_compression_toolkit/core/keras/graph_substitutions/substitutions/matmul_substitution.py,sha256=kjwlKtm5yhNgWVVcW6mN-hn7enwAnn_8-TUZvxZBiQs,4112
174
173
  model_compression_toolkit/core/keras/graph_substitutions/substitutions/multi_head_attention_decomposition.py,sha256=l9PUREBf4aRwWILiybdteveeUbh7js-i-hLt8Ma0e4c,26771
175
174
  model_compression_toolkit/core/keras/graph_substitutions/substitutions/relu_bound_to_power_of_2.py,sha256=IdKOg6AWZWMcmDbOuNdxetS5_zTarXIIffdYL7JTdvk,3872
176
- model_compression_toolkit/core/keras/graph_substitutions/substitutions/remove_relu_upper_bound.py,sha256=cJQTDzTDQKAJ7EQ20tfsmReGA_OoTIN793MwVe1Ok8g,2387
177
175
  model_compression_toolkit/core/keras/graph_substitutions/substitutions/residual_collapsing.py,sha256=gSqUYh76tP7NcZfqFSnuPIrUpyBh6UjjcPJtJxZtOZk,3181
178
176
  model_compression_toolkit/core/keras/graph_substitutions/substitutions/scale_equalization.py,sha256=ryes9y1ie-vjBGso2TeO4EXxVk69Ew3iSAhshPz1Ou4,5542
179
177
  model_compression_toolkit/core/keras/graph_substitutions/substitutions/separableconv_decomposition.py,sha256=TEaHlIbXj_ZjIdT5TmAICD3WLD3u_7g0fLWQcNzTJuM,7941
@@ -211,7 +209,7 @@ model_compression_toolkit/core/pytorch/__init__.py,sha256=Rf1RcYmelmdZmBV5qOKvKW
211
209
  model_compression_toolkit/core/pytorch/constants.py,sha256=NI-J7REuxn06oEIHsmJ4GqtNC3TbV8xlkJjt5Ar-c4U,2626
212
210
  model_compression_toolkit/core/pytorch/default_framework_info.py,sha256=r1XyzUFvrjGcJHQM5ETLsMZIG2yHCr9HMjqf0ti9inw,4175
213
211
  model_compression_toolkit/core/pytorch/pytorch_device_config.py,sha256=IoMvTch5awAEPvB6Tg6ANhFGXvfSgv7JLsUBlxpMwk4,4330
214
- model_compression_toolkit/core/pytorch/pytorch_implementation.py,sha256=Yr5ldjroFaoImOlPw3DhqL5uWV-WHyn7TS3kGRWyTjI,27082
212
+ model_compression_toolkit/core/pytorch/pytorch_implementation.py,sha256=dakO4Nj-tFfs53y6dJyXbpoljx2n3ZqmMoB4CFWGNSQ,26868
215
213
  model_compression_toolkit/core/pytorch/pytorch_node_prior_info.py,sha256=n_B4a6FMwM9D2w8kzy3oenBWZgXNZuIZgTJC6JEuTy0,3250
216
214
  model_compression_toolkit/core/pytorch/resource_utilization_data_facade.py,sha256=E6ifk1HdO60k4IRH2EFBzAYWtwUlrGqJoQ66nknpHoQ,4983
217
215
  model_compression_toolkit/core/pytorch/utils.py,sha256=dRPiteBg2dBNsHwZyYzXiCIAjnelSoeZZsDXlsTw5JQ,2880
@@ -311,7 +309,7 @@ model_compression_toolkit/exporter/model_exporter/keras/mctq_keras_exporter.py,s
311
309
  model_compression_toolkit/exporter/model_exporter/pytorch/__init__.py,sha256=uZ2RigbY9O2PJ0Il8wPpS_s7frgg9WUGd_SHeKGyl1A,699
312
310
  model_compression_toolkit/exporter/model_exporter/pytorch/base_pytorch_exporter.py,sha256=UPVkEUQCMZ4Lld6CRnEOPEmlfe5vcQZG0Q3FwRBodD4,4021
313
311
  model_compression_toolkit/exporter/model_exporter/pytorch/export_serialization_format.py,sha256=bPevy6OBqng41PqytBR55e6cBEuyrUS0H8dWX4zgjQ4,967
314
- model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=JmxSa8mwL-HaTY1fS0UEpKJVlg95W_eBYudpeVRnRDo,5137
312
+ model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_onnx_pytorch_exporter.py,sha256=TedEyQN9TQzRnb8afQVF4Kx28IeyEJRWiUloQxkBHAY,5136
315
313
  model_compression_toolkit/exporter/model_exporter/pytorch/fakely_quant_torchscript_pytorch_exporter.py,sha256=ksWV2A-Njo-wAxQ_Ye2sLIZXBWJ_WNyjT7-qFFwvV2o,2897
316
314
  model_compression_toolkit/exporter/model_exporter/pytorch/pytorch_export_facade.py,sha256=iVKanLUALkK7WIDmNLpcvHu02EO47GM-T8iLr4srp-Q,6351
317
315
  model_compression_toolkit/exporter/model_wrapper/__init__.py,sha256=7CF2zvpTrIEm8qnbuHnLZyTZkwBBxV24V8QA0oxGbh0,1187
@@ -340,7 +338,7 @@ model_compression_toolkit/gptq/keras/gptq_keras_implementation.py,sha256=axBwnCS
340
338
  model_compression_toolkit/gptq/keras/gptq_loss.py,sha256=rbRkF15MYd6nq4G49kcjb_dPTa-XNq9cTkrb93mXawo,6241
341
339
  model_compression_toolkit/gptq/keras/gptq_training.py,sha256=6TseqtBzZkLqyc3hiRVdA1dv01us6Y_Su05CBboGjjc,18438
342
340
  model_compression_toolkit/gptq/keras/graph_info.py,sha256=5IvgGlJlgOmQYmldjdCBv7tuzAoY0HazatG5Pedrg0Q,4639
343
- model_compression_toolkit/gptq/keras/quantization_facade.py,sha256=l4UNddc9tX1YxfvPB_4NsqqkRh79d2YwR2L2rnVzYBU,14057
341
+ model_compression_toolkit/gptq/keras/quantization_facade.py,sha256=yRgiikyeELar4jlsdcf5pO9HQcxiyhKiAXY3lsMixew,13913
344
342
  model_compression_toolkit/gptq/keras/quantizer/__init__.py,sha256=-DK1CDXvlsnEbki4lukZLpl6Xrbo91_jcqxXlG5Eg6Q,963
345
343
  model_compression_toolkit/gptq/keras/quantizer/base_keras_gptq_quantizer.py,sha256=2YU-x4-Q5f6hkUJf0tw6vcwdNwRMHdefrFjhhyHYsvA,4782
346
344
  model_compression_toolkit/gptq/keras/quantizer/quant_utils.py,sha256=Vt7Qb8i4JsE4sFtcjpfM4FTXTtfV1t6SwfoNH8a_Iaw,5055
@@ -357,7 +355,7 @@ model_compression_toolkit/gptq/pytorch/gptq_loss.py,sha256=kDuWw-6zh17wZpYWh4Xa9
357
355
  model_compression_toolkit/gptq/pytorch/gptq_pytorch_implementation.py,sha256=tECPTavxn8EEwgLaP2zvxdJH6Vg9jC0YOIMJ7857Sdc,1268
358
356
  model_compression_toolkit/gptq/pytorch/gptq_training.py,sha256=ksFXtepAsk-66xk7OPciG05kU9sgAUrWqjOgplsGSnw,15808
359
357
  model_compression_toolkit/gptq/pytorch/graph_info.py,sha256=yXJzDd24zfGs2_vfMovxD1WSh1RxXoPxN4GztOf3P5c,3967
360
- model_compression_toolkit/gptq/pytorch/quantization_facade.py,sha256=7haHpYlD-qWwk06wpbPMOFPs_nWS4QnWNaeGIrLKAm0,12495
358
+ model_compression_toolkit/gptq/pytorch/quantization_facade.py,sha256=bImrTw9rrAVc3VD4nmrXmBo_K4fuf5m5XPPf8ybOThs,12430
361
359
  model_compression_toolkit/gptq/pytorch/quantizer/__init__.py,sha256=ZHNHo1yzye44m9_ht4UUZfTpK01RiVR3Tr74-vtnOGI,968
362
360
  model_compression_toolkit/gptq/pytorch/quantizer/base_pytorch_gptq_quantizer.py,sha256=TCA1hAc7raPnrjl06sjFtVM4XUtLtuwAhCGX4U3KGZo,4137
363
361
  model_compression_toolkit/gptq/pytorch/quantizer/quant_utils.py,sha256=OocYYRqvl7rZ37QT0hTzfJnWGiNCPskg7cziTlR7TRk,3893
@@ -377,9 +375,9 @@ model_compression_toolkit/pruning/pytorch/pruning_facade.py,sha256=cSuvHHCqgr7k9
377
375
  model_compression_toolkit/ptq/__init__.py,sha256=Z_hkmTh7aLFei1DJKV0oNVUbrv_Q_0CTw-qD85Xf8UM,904
378
376
  model_compression_toolkit/ptq/runner.py,sha256=_c1dSjlPPpsx59Vbg1buhG9bZq__OORz1VlPkwjJzoc,2552
379
377
  model_compression_toolkit/ptq/keras/__init__.py,sha256=cco4TmeIDIh32nj9ZZXVkws4dd9F2UDrmjKzTN8G0V0,697
380
- model_compression_toolkit/ptq/keras/quantization_facade.py,sha256=QkZHN_jsC3WDuKT6FbJfPcRlq6XddYeAnZRBhRBH7eI,9057
378
+ model_compression_toolkit/ptq/keras/quantization_facade.py,sha256=5Doa5Rwer84DRgJxLa2e6aX9B4yGYdmFGgiv71_wD9o,8992
381
379
  model_compression_toolkit/ptq/pytorch/__init__.py,sha256=cco4TmeIDIh32nj9ZZXVkws4dd9F2UDrmjKzTN8G0V0,697
382
- model_compression_toolkit/ptq/pytorch/quantization_facade.py,sha256=4No5_g7wReXNDhj4Vcco-DLDWjZoqaJLOTBJQyEVtv4,7583
380
+ model_compression_toolkit/ptq/pytorch/quantization_facade.py,sha256=QW7lMRuuonupLPZ2w2PDIQd7qpDZ_euLInhskTc1Yes,7518
383
381
  model_compression_toolkit/qat/__init__.py,sha256=kj2qsZh_Ca7PncsHKcaL5EVT2H8g4hYtvaQ3KFxOkwE,1143
384
382
  model_compression_toolkit/qat/common/__init__.py,sha256=6tLZ4R4pYP6QVztLVQC_jik2nES3l4uhML0qUxZrezk,829
385
383
  model_compression_toolkit/qat/common/qat_config.py,sha256=zoq0Vb74vCY7WlWD8JH_KPrHDoUHSvMc3gcO53u7L2U,3394
@@ -471,8 +469,8 @@ model_compression_toolkit/trainable_infrastructure/keras/quantize_wrapper.py,sha
471
469
  model_compression_toolkit/trainable_infrastructure/keras/quantizer_utils.py,sha256=MVwXNymmFRB2NXIBx4e2mdJ1RfoHxRPYRgjb1MQP5kY,1797
472
470
  model_compression_toolkit/trainable_infrastructure/pytorch/__init__.py,sha256=huHoBUcKNB6BnY6YaUCcFvdyBtBI172ZoUD8ZYeNc6o,696
473
471
  model_compression_toolkit/trainable_infrastructure/pytorch/base_pytorch_quantizer.py,sha256=7bbzqJN8ZAycVDvZr_5xC-niTAR5df8f03Kooev_pfg,3047
474
- mct_nightly-2.0.0.20240403.423.dist-info/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
475
- mct_nightly-2.0.0.20240403.423.dist-info/METADATA,sha256=dHTEKAHtl1x-dI2jaHQiDYi7QJInTciTrVMfjF2DzxQ,18795
476
- mct_nightly-2.0.0.20240403.423.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
477
- mct_nightly-2.0.0.20240403.423.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
478
- mct_nightly-2.0.0.20240403.423.dist-info/RECORD,,
472
+ mct_nightly-2.0.0.20240404.424.dist-info/LICENSE.md,sha256=aYSSIb-5AFPeITTvXm1UAoe0uYBiMmSS8flvXaaFUks,10174
473
+ mct_nightly-2.0.0.20240404.424.dist-info/METADATA,sha256=4ID8UlB0QTcYADss82tFhwAwGOBOPZdmbuT7kIJLWm8,18795
474
+ mct_nightly-2.0.0.20240404.424.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
475
+ mct_nightly-2.0.0.20240404.424.dist-info/top_level.txt,sha256=gsYA8juk0Z-ZmQRKULkb3JLGdOdz8jW_cMRjisn9ga4,26
476
+ mct_nightly-2.0.0.20240404.424.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.0.0.20240403.000423"
30
+ __version__ = "2.0.0.20240404.000424"
@@ -250,15 +250,6 @@ class FrameworkImplementation(ABC):
250
250
  raise NotImplemented(f'{self.__class__.__name__} have to implement the '
251
251
  f'framework\'s get_residual_collapsing_substitution method.') # pragma: no cover
252
252
 
253
- @abstractmethod
254
- def get_substitutions_pre_build(self) -> List[common.BaseSubstitution]:
255
- """
256
-
257
- Returns: A list of the framework substitutions used before we build a quantized model.
258
-
259
- """
260
- raise NotImplemented(f'{self.__class__.__name__} have to implement the '
261
- f'framework\'s get_substitutions_pre_build method.') # pragma: no cover
262
253
 
263
254
  @abstractmethod
264
255
  def get_substitutions_post_statistics_collection(self, quant_config: QuantizationConfig) -> List[
@@ -83,8 +83,6 @@ from model_compression_toolkit.core.keras.graph_substitutions.substitutions.inpu
83
83
  InputScalingWithPad
84
84
  from model_compression_toolkit.core.keras.graph_substitutions.substitutions.relu_bound_to_power_of_2 import \
85
85
  ReLUBoundToPowerOfTwo
86
- from model_compression_toolkit.core.keras.graph_substitutions.substitutions.remove_relu_upper_bound import \
87
- RemoveReLUUpperBound
88
86
  from model_compression_toolkit.core.keras.graph_substitutions.substitutions.multi_head_attention_decomposition import \
89
87
  MultiHeadAttentionDecomposition
90
88
  from model_compression_toolkit.core.keras.graph_substitutions.substitutions.scale_equalization import \
@@ -321,14 +319,6 @@ class KerasImplementation(FrameworkImplementation):
321
319
  substitutions_list.append(InputScalingWithPad())
322
320
  return substitutions_list
323
321
 
324
- def get_substitutions_pre_build(self) -> List[common.BaseSubstitution]:
325
- """
326
-
327
- Returns: A list of the framework substitutions used before we build a quantized model.
328
-
329
- """
330
-
331
- return [RemoveReLUUpperBound()]
332
322
 
333
323
  def get_substitutions_virtual_weights_activation_coupling(self) -> List[common.BaseSubstitution]:
334
324
  """
@@ -304,11 +304,6 @@ class PytorchImplementation(FrameworkImplementation):
304
304
  Logger.critical('Input scaling is currently not supported for Pytorch.')
305
305
  return substitutions_list
306
306
 
307
- def get_substitutions_pre_build(self) -> List[common.BaseSubstitution]:
308
- """
309
- Returns: A list of the framework substitutions used before we build a quantized module.
310
- """
311
- return []
312
307
 
313
308
  def get_substitutions_virtual_weights_activation_coupling(self) -> List[common.BaseSubstitution]:
314
309
  """
@@ -103,7 +103,7 @@ class FakelyQuantONNXPyTorchExporter(BasePyTorchExporter):
103
103
  with custom quantizers.
104
104
  """
105
105
 
106
- for n, m in self.model.named_children():
106
+ for n, m in self.model.named_modules():
107
107
  if isinstance(m, PytorchActivationQuantizationHolder):
108
108
  assert isinstance(m.activation_holder_quantizer, pytorch_quantizers.BasePyTorchInferableQuantizer)
109
109
  m.activation_holder_quantizer.enable_custom_impl()
@@ -23,12 +23,10 @@ from model_compression_toolkit.constants import TENSORFLOW, FOUND_TF
23
23
  from model_compression_toolkit.core.common.user_info import UserInformation
24
24
  from model_compression_toolkit.gptq.common.gptq_config import GradientPTQConfig
25
25
  from model_compression_toolkit.core.common.mixed_precision.resource_utilization_tools.resource_utilization import ResourceUtilization
26
- from model_compression_toolkit.core.common.framework_info import FrameworkInfo
27
26
  from model_compression_toolkit.core.common.mixed_precision.mixed_precision_quantization_config import MixedPrecisionQuantizationConfig
28
27
  from model_compression_toolkit.core import CoreConfig
29
28
  from model_compression_toolkit.core.runner import core_runner
30
29
  from model_compression_toolkit.gptq.runner import gptq_runner
31
- from model_compression_toolkit.core.exporter import export_model
32
30
  from model_compression_toolkit.core.analyzer import analyzer_model_quantization
33
31
  from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework import TargetPlatformCapabilities
34
32
 
@@ -25,7 +25,6 @@ from model_compression_toolkit.core.common.mixed_precision.resource_utilization_
25
25
  from model_compression_toolkit.core.runner import core_runner
26
26
  from model_compression_toolkit.gptq.keras.quantization_facade import GPTQ_MOMENTUM
27
27
  from model_compression_toolkit.gptq.runner import gptq_runner
28
- from model_compression_toolkit.core.exporter import export_model
29
28
  from model_compression_toolkit.core.analyzer import analyzer_model_quantization
30
29
  from model_compression_toolkit.core import CoreConfig
31
30
  from model_compression_toolkit.core.common.mixed_precision.mixed_precision_quantization_config import \
@@ -24,7 +24,6 @@ from model_compression_toolkit.core.common.mixed_precision.resource_utilization_
24
24
  from model_compression_toolkit.core.common.mixed_precision.mixed_precision_quantization_config import \
25
25
  MixedPrecisionQuantizationConfig
26
26
  from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework import TargetPlatformCapabilities
27
- from model_compression_toolkit.core.exporter import export_model
28
27
  from model_compression_toolkit.core.runner import core_runner
29
28
  from model_compression_toolkit.ptq.runner import ptq_runner
30
29
 
@@ -25,7 +25,6 @@ from model_compression_toolkit.core.common.mixed_precision.mixed_precision_quant
25
25
  MixedPrecisionQuantizationConfig
26
26
  from model_compression_toolkit.core.runner import core_runner
27
27
  from model_compression_toolkit.ptq.runner import ptq_runner
28
- from model_compression_toolkit.core.exporter import export_model
29
28
  from model_compression_toolkit.core.analyzer import analyzer_model_quantization
30
29
 
31
30
 
@@ -1,90 +0,0 @@
1
- # Copyright 2022 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
-
16
-
17
- from typing import Tuple, Any
18
-
19
- from model_compression_toolkit.core.common.framework_implementation import FrameworkImplementation
20
- from model_compression_toolkit.core.common import FrameworkInfo
21
- from model_compression_toolkit.core.common.graph.base_graph import Graph
22
- from model_compression_toolkit.core.common.model_builder_mode import ModelBuilderMode
23
- from model_compression_toolkit.core.common.quantization.quantize_graph_weights import quantize_graph_weights
24
-
25
- from model_compression_toolkit.core.common.substitutions.apply_substitutions import substitute
26
- from model_compression_toolkit.core.common.user_info import UserInformation
27
-
28
- from model_compression_toolkit.core.common.visualization.tensorboard_writer import TensorboardWriter
29
-
30
-
31
- def _quantize_model(tg: Graph,
32
- fw_info: FrameworkInfo,
33
- fw_impl: FrameworkImplementation,
34
- tb_w: TensorboardWriter) -> Tuple[Any, UserInformation]:
35
- """
36
- Quantize graph's weights, and build a quantized framework model from it.
37
-
38
- Args:
39
- tg: A prepared for quantization graph.
40
- fw_info: Information needed for quantization about the specific framework (e.g., kernel channels indices, groups of layers by how they should be quantized, etc.).
41
- fw_impl: FrameworkImplementation object with a specific framework methods implementation.
42
- tb_w: TensorBoardWriter object to log events.
43
-
44
- Returns:
45
- Quantized model in the input framework, and information the user may need in order to use the quantized model.
46
- """
47
-
48
- quantized_tg = quantize_graph_weights(tg)
49
- if tb_w is not None:
50
- tb_w.add_graph(quantized_tg, 'after_quantization')
51
- ######################################
52
- # Back2Framework
53
- ######################################
54
- # Before building a quantized model, first apply some substitutions.
55
- quantized_tg = substitute(quantized_tg,
56
- fw_impl.get_substitutions_pre_build())
57
-
58
- quantized_model, user_info = fw_impl.model_builder(quantized_tg,
59
- mode=ModelBuilderMode.QUANTIZED,
60
- fw_info=fw_info)
61
- return quantized_model, user_info
62
-
63
-
64
- def export_model(tg,
65
- fw_info,
66
- fw_impl,
67
- tb_w,
68
- bit_widths_config):
69
-
70
- """
71
- A function for quantizing the graph's weights and build a quantized framework model from it.
72
-
73
- Args:
74
- tg: A prepared for quantization graph.
75
- fw_info: Information needed for quantization about the specific framework (e.g., kernel channels indices, groups of layers by how they should be quantized, etc.).
76
- fw_impl: FrameworkImplementation object with a specific framework methods implementation.
77
- tb_w: TensorBoardWriter object to log events.
78
- bit_widths_config: mixed-precision bit configuration to be added to model user_info
79
-
80
- Returns:
81
- Quantized model in the input framework, and information the user may need in order to use the quantized model.
82
- """
83
- quantized_model, user_info = _quantize_model(tg,
84
- fw_info,
85
- fw_impl,
86
- tb_w)
87
- user_info.mixed_precision_cfg = bit_widths_config
88
-
89
- return quantized_model, user_info
90
-
@@ -1,61 +0,0 @@
1
- # Copyright 2021 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
-
16
-
17
- from tensorflow.keras.layers import ReLU
18
-
19
- from model_compression_toolkit.core import common
20
- from model_compression_toolkit.core.common import Graph, BaseNode
21
- from model_compression_toolkit.core.common.graph.graph_matchers import NodeOperationMatcher,NodeFrameworkAttrMatcher
22
- from model_compression_toolkit.core.keras.constants import RELU_MAX_VALUE
23
- from model_compression_toolkit.constants import THRESHOLD
24
- from model_compression_toolkit.logger import Logger
25
-
26
- MATCHER = NodeOperationMatcher(ReLU) & NodeFrameworkAttrMatcher(RELU_MAX_VALUE, None).logic_not()
27
-
28
-
29
- class RemoveReLUUpperBound(common.BaseSubstitution):
30
- """
31
- Remove ReLU upper bound if its activation threshold bounds it anyway at
32
- the same value.
33
- """
34
-
35
-
36
- def __init__(self):
37
- """
38
- Initialize a RemoveReLUUpperBound object.
39
- """
40
- super().__init__(matcher_instance=MATCHER)
41
-
42
- def substitute(self,
43
- graph: Graph,
44
- node: BaseNode) -> Graph:
45
- """
46
- Remove ReLU upper bound if its activation threshold bounds it anyway at
47
- the same value.
48
-
49
- Args:
50
- graph: Graph we apply the substitution on.
51
- node: Node to remove its bound.
52
-
53
- Returns:
54
- Graph after applying the substitution.
55
- """
56
- if node.final_activation_quantization_cfg and \
57
- node.final_activation_quantization_cfg.activation_quantization_params.get(THRESHOLD) == \
58
- node.framework_attr.get(RELU_MAX_VALUE):
59
- node.framework_attr[RELU_MAX_VALUE] = None
60
- Logger.info(f'Removing upper bound of {node.name}. Threshold and upper bound are equal.')
61
- return graph