From be71127adebd019c4a3207a7e91cc493d8493000 Mon Sep 17 00:00:00 2001 From: liord Date: Mon, 2 Dec 2024 11:55:22 +0200 Subject: [PATCH] PR fixes: 1. Created mct_current_schema.py for one place to update the schema version, and replaced all the imports in mct to work with this location. 2. Replaced metadata dictionary with dataclass. --- model_compression_toolkit/constants.py | 6 --- .../core/common/graph/base_node.py | 4 +- .../resource_utilization_data.py | 2 +- .../candidate_node_quantization_config.py | 2 +- .../quantization/node_quantization_config.py | 2 +- .../qparams_activations_computation.py | 2 +- .../set_node_quantization_config.py | 2 +- ...ply_activation_bias_correction_to_graph.py | 2 +- .../apply_bias_correction_to_graph.py | 2 +- .../substitutions/batchnorm_reconstruction.py | 2 +- .../shift_negative_activation.py | 2 +- model_compression_toolkit/metadata.py | 26 +++++----- .../schema/mct_current_schema.py | 11 +++++ .../schema/schema_functions.py | 37 +++++++++++++++ .../target_platform_capabilities/schema/v1.py | 47 ++++++++++--------- .../target_platform/__init__.py | 2 +- .../target_platform/target_platform_model.py | 14 +----- .../target_platform_model_component.py | 40 ---------------- .../operations_to_layers.py | 2 +- .../target_platform_capabilities.py | 2 +- .../tpc_models/imx500_tpc/v1/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v1/tpc_keras.py | 2 +- .../tpc_models/imx500_tpc/v1/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v1_lut/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v1_lut/tpc_keras.py | 2 +- .../imx500_tpc/v1_lut/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v1_pot/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v1_pot/tpc_keras.py | 2 +- .../imx500_tpc/v1_pot/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v2/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v2/tpc_keras.py | 2 +- .../tpc_models/imx500_tpc/v2/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v2_lut/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v2_lut/tpc_keras.py | 2 +- .../imx500_tpc/v2_lut/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v3/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v3/tpc_keras.py | 2 +- .../tpc_models/imx500_tpc/v3/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v3_lut/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v3_lut/tpc_keras.py | 2 +- .../imx500_tpc/v3_lut/tpc_pytorch.py | 2 +- .../tpc_models/imx500_tpc/v4/tp_model.py | 4 +- .../tpc_models/imx500_tpc/v4/tpc_keras.py | 2 +- .../tpc_models/imx500_tpc/v4/tpc_pytorch.py | 2 +- .../tpc_models/qnnpack_tpc/v1/tp_model.py | 4 +- .../tpc_models/qnnpack_tpc/v1/tpc_keras.py | 2 +- .../tpc_models/qnnpack_tpc/v1/tpc_pytorch.py | 2 +- .../tpc_models/tflite_tpc/v1/tp_model.py | 4 +- .../tpc_models/tflite_tpc/v1/tpc_keras.py | 2 +- .../tpc_models/tflite_tpc/v1/tpc_pytorch.py | 2 +- .../helpers/generate_test_tp_model.py | 4 +- tests/common_tests/test_tp_model.py | 2 +- .../tflite_int8/imx500_int8_tp_model.py | 4 +- .../bn_attributes_quantization_test.py | 4 +- .../const_quantization_test.py | 2 +- .../feature_networks/mixed_precision_tests.py | 2 +- .../weights_mixed_precision_tests.py | 2 +- .../function_tests/test_custom_layer.py | 4 +- .../function_tests/test_hmse_error_method.py | 4 +- .../function_tests/test_layer_fusing.py | 2 +- .../test_node_quantization_configurations.py | 2 +- .../non_parallel_tests/test_keras_tp_model.py | 2 +- .../function_tests/layer_fusing_test.py | 2 +- .../function_tests/test_pytorch_tp_model.py | 2 +- .../bn_attributes_quantization_test.py | 4 +- .../feature_models/const_quantization_test.py | 4 +- .../mixed_precision_activation_test.py | 2 +- .../mixed_precision_weights_test.py | 4 +- 68 files changed, 166 insertions(+), 175 deletions(-) create mode 100644 model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py create mode 100644 model_compression_toolkit/target_platform_capabilities/schema/schema_functions.py delete mode 100644 model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model_component.py diff --git a/model_compression_toolkit/constants.py b/model_compression_toolkit/constants.py index 8e19e4361..ec335a608 100644 --- a/model_compression_toolkit/constants.py +++ b/model_compression_toolkit/constants.py @@ -18,12 +18,6 @@ TENSORFLOW = 'tensorflow' PYTORCH = 'pytorch' -# Metadata fields -MCT_VERSION = 'mct_version' -TPC_MINOR_VERSION = 'tpc_minor_version' -TPC_PATCH_VERSION = 'tpc_patch_version' -TPC_PLATFORM_TYPE = 'tpc_platform_type' -TPC_SCHEMA = 'tpc_schema' WEIGHTS_SIGNED = True # Minimal threshold to use for quantization ranges: diff --git a/model_compression_toolkit/core/common/graph/base_node.py b/model_compression_toolkit/core/common/graph/base_node.py index de60617e6..4b560f301 100644 --- a/model_compression_toolkit/core/common/graph/base_node.py +++ b/model_compression_toolkit/core/common/graph/base_node.py @@ -22,9 +22,9 @@ ACTIVATION_N_BITS_ATTRIBUTE, FP32_BYTES_PER_PARAMETER from model_compression_toolkit.core.common.quantization.node_quantization_config import WeightsAttrQuantizationConfig from model_compression_toolkit.logger import Logger +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import QuantizationConfigOptions, \ + OpQuantizationConfig from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities, LayerFilterParams -from model_compression_toolkit.target_platform_capabilities.schema.v1 import OpQuantizationConfig, \ - QuantizationConfigOptions class BaseNode: diff --git a/model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization_data.py b/model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization_data.py index 67ec4df40..b826b2c19 100644 --- a/model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization_data.py +++ b/model_compression_toolkit/core/common/mixed_precision/resource_utilization_tools/resource_utilization_data.py @@ -24,7 +24,7 @@ from model_compression_toolkit.core.common.graph.edge import EDGE_SINK_INDEX from model_compression_toolkit.core.graph_prep_runner import graph_preparation_runner from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities -from model_compression_toolkit.target_platform_capabilities.schema.v1 import QuantizationConfigOptions +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import QuantizationConfigOptions def compute_resource_utilization_data(in_model: Any, diff --git a/model_compression_toolkit/core/common/quantization/candidate_node_quantization_config.py b/model_compression_toolkit/core/common/quantization/candidate_node_quantization_config.py index 33b1b47e7..0fe5c7c94 100644 --- a/model_compression_toolkit/core/common/quantization/candidate_node_quantization_config.py +++ b/model_compression_toolkit/core/common/quantization/candidate_node_quantization_config.py @@ -17,7 +17,7 @@ from model_compression_toolkit.core import QuantizationConfig from model_compression_toolkit.core.common.quantization.node_quantization_config import BaseNodeQuantizationConfig, \ NodeWeightsQuantizationConfig, NodeActivationQuantizationConfig -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig, \ OpQuantizationConfig from model_compression_toolkit.logger import Logger diff --git a/model_compression_toolkit/core/common/quantization/node_quantization_config.py b/model_compression_toolkit/core/common/quantization/node_quantization_config.py index 069848248..cfc36698e 100644 --- a/model_compression_toolkit/core/common/quantization/node_quantization_config.py +++ b/model_compression_toolkit/core/common/quantization/node_quantization_config.py @@ -25,7 +25,7 @@ from model_compression_toolkit.core.common.quantization.quantization_config import QuantizationConfig, \ QuantizationErrorMethod -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig, \ OpQuantizationConfig diff --git a/model_compression_toolkit/core/common/quantization/quantization_params_generation/qparams_activations_computation.py b/model_compression_toolkit/core/common/quantization/quantization_params_generation/qparams_activations_computation.py index 324b8f603..ca3d7c733 100644 --- a/model_compression_toolkit/core/common/quantization/quantization_params_generation/qparams_activations_computation.py +++ b/model_compression_toolkit/core/common/quantization/quantization_params_generation/qparams_activations_computation.py @@ -16,7 +16,7 @@ from typing import Dict, Union from model_compression_toolkit.target_platform_capabilities.target_platform import QuantizationMethod -from model_compression_toolkit.target_platform_capabilities.schema.v1 import Signedness +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness from model_compression_toolkit.core.common.collectors.statistics_collector import BaseStatsCollector from model_compression_toolkit.core.common.quantization import quantization_params_generation from model_compression_toolkit.core.common.node_prior_info import NodePriorInfo diff --git a/model_compression_toolkit/core/common/quantization/set_node_quantization_config.py b/model_compression_toolkit/core/common/quantization/set_node_quantization_config.py index 6e489aaaa..2e6cc8d9d 100644 --- a/model_compression_toolkit/core/common/quantization/set_node_quantization_config.py +++ b/model_compression_toolkit/core/common/quantization/set_node_quantization_config.py @@ -33,7 +33,7 @@ from model_compression_toolkit.core.common.quantization.quantization_fn_selection import \ get_weights_quantization_fn from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework import TargetPlatformCapabilities -from model_compression_toolkit.target_platform_capabilities.schema.v1 import OpQuantizationConfig, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import OpQuantizationConfig, \ QuantizationConfigOptions diff --git a/model_compression_toolkit/core/common/statistics_correction/apply_activation_bias_correction_to_graph.py b/model_compression_toolkit/core/common/statistics_correction/apply_activation_bias_correction_to_graph.py index cc473e48f..5e3945ca1 100644 --- a/model_compression_toolkit/core/common/statistics_correction/apply_activation_bias_correction_to_graph.py +++ b/model_compression_toolkit/core/common/statistics_correction/apply_activation_bias_correction_to_graph.py @@ -17,7 +17,7 @@ from model_compression_toolkit.core.common import BaseNode, Graph from model_compression_toolkit.core.common.framework_implementation import FrameworkImplementation from model_compression_toolkit.core.common.quantization.node_quantization_config import WeightsAttrQuantizationConfig -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig def apply_activation_bias_correction_to_graph(graph: Graph, diff --git a/model_compression_toolkit/core/common/statistics_correction/apply_bias_correction_to_graph.py b/model_compression_toolkit/core/common/statistics_correction/apply_bias_correction_to_graph.py index f22128b09..72dd834bd 100644 --- a/model_compression_toolkit/core/common/statistics_correction/apply_bias_correction_to_graph.py +++ b/model_compression_toolkit/core/common/statistics_correction/apply_bias_correction_to_graph.py @@ -19,7 +19,7 @@ from model_compression_toolkit.core.common import Graph, BaseNode from model_compression_toolkit.core.common.framework_implementation import FrameworkImplementation from model_compression_toolkit.core.common.quantization.node_quantization_config import WeightsAttrQuantizationConfig -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig def apply_bias_correction_to_graph(graph_to_apply_bias_correction: Graph, diff --git a/model_compression_toolkit/core/common/substitutions/batchnorm_reconstruction.py b/model_compression_toolkit/core/common/substitutions/batchnorm_reconstruction.py index b995b9335..256501365 100644 --- a/model_compression_toolkit/core/common/substitutions/batchnorm_reconstruction.py +++ b/model_compression_toolkit/core/common/substitutions/batchnorm_reconstruction.py @@ -27,7 +27,7 @@ from model_compression_toolkit.core.common.graph.base_node import BaseNode from model_compression_toolkit.core.common.graph.graph_matchers import NodeOperationMatcher from model_compression_toolkit.target_platform_capabilities.target_platform import QuantizationMethod -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig class BatchNormalizationReconstruction(common.BaseSubstitution): diff --git a/model_compression_toolkit/core/common/substitutions/shift_negative_activation.py b/model_compression_toolkit/core/common/substitutions/shift_negative_activation.py index da4af3368..73e216885 100644 --- a/model_compression_toolkit/core/common/substitutions/shift_negative_activation.py +++ b/model_compression_toolkit/core/common/substitutions/shift_negative_activation.py @@ -23,7 +23,7 @@ from model_compression_toolkit.constants import THRESHOLD, SIGNED, SHIFT_NEGATIVE_NON_LINEAR_NUM_BITS from model_compression_toolkit.core.common.graph.graph_matchers import NodeOperationMatcher from model_compression_toolkit.target_platform_capabilities.target_platform import QuantizationMethod -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig from model_compression_toolkit.core.common.quantization.set_node_quantization_config import create_node_activation_qc, \ set_quantization_configs_to_node from model_compression_toolkit.core.common.quantization.core_config import CoreConfig diff --git a/model_compression_toolkit/metadata.py b/model_compression_toolkit/metadata.py index 607a1dba5..192baad82 100644 --- a/model_compression_toolkit/metadata.py +++ b/model_compression_toolkit/metadata.py @@ -12,12 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== +from dataclasses import dataclass, asdict from typing import Dict, Any -from model_compression_toolkit.constants import MCT_VERSION, TPC_MINOR_VERSION, OPERATORS_SCHEDULING, \ - FUSED_NODES_MAPPING, \ - CUTS, MAX_CUT, OP_ORDER, OP_RECORD, SHAPE, NODE_OUTPUT_INDEX, NODE_NAME, TOTAL_SIZE, MEM_ELEMENTS, TPC_SCHEMA, \ - TPC_PATCH_VERSION, TPC_PLATFORM_TYPE +from model_compression_toolkit.constants import OPERATORS_SCHEDULING, FUSED_NODES_MAPPING, CUTS, MAX_CUT, OP_ORDER, \ + OP_RECORD, SHAPE, NODE_OUTPUT_INDEX, NODE_NAME, TOTAL_SIZE, MEM_ELEMENTS from model_compression_toolkit.core.common.graph.memory_graph.compute_graph_max_cut import SchedulerInfo from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities @@ -50,15 +49,16 @@ def get_versions_dict(tpc) -> Dict: """ # imported inside to avoid circular import error from model_compression_toolkit import __version__ as mct_version - tpc_minor_version = f'{tpc.tp_model.tpc_minor_version}' - tpc_patch_version = f'{tpc.tp_model.tpc_patch_version}' - tpc_platform_type = f'{tpc.tp_model.tpc_platform_type}' - tpc_schema = f'{tpc.tp_model.SCHEMA_VERSION}' - return {MCT_VERSION: mct_version, - TPC_MINOR_VERSION: tpc_minor_version, - TPC_PATCH_VERSION: tpc_patch_version, - TPC_PLATFORM_TYPE: tpc_platform_type, - TPC_SCHEMA: tpc_schema} + + @dataclass + class TPCVersions: + mct_version: str + tpc_minor_version: str = f'{tpc.tp_model.tpc_minor_version}' + tpc_patch_version: str = f'{tpc.tp_model.tpc_patch_version}' + tpc_platform_type: str = f'{tpc.tp_model.tpc_platform_type}' + tpc_schema: str = f'{tpc.tp_model.SCHEMA_VERSION}' + + return asdict(TPCVersions(mct_version)) def get_scheduler_metadata(scheduler_info: SchedulerInfo) -> Dict[str, Any]: diff --git a/model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py b/model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py new file mode 100644 index 000000000..ee6c85ea1 --- /dev/null +++ b/model_compression_toolkit/target_platform_capabilities/schema/mct_current_schema.py @@ -0,0 +1,11 @@ +import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema + +Signedness = schema.Signedness +AttributeQuantizationConfig = schema.AttributeQuantizationConfig +OpQuantizationConfig = schema.OpQuantizationConfig +QuantizationConfigOptions = schema.QuantizationConfigOptions +OperatorsSetBase = schema.OperatorsSetBase +OperatorsSet = schema.OperatorsSet +OperatorSetConcat= schema.OperatorSetConcat +Fusing = schema.Fusing +TargetPlatformModel = schema.TargetPlatformModel diff --git a/model_compression_toolkit/target_platform_capabilities/schema/schema_functions.py b/model_compression_toolkit/target_platform_capabilities/schema/schema_functions.py new file mode 100644 index 000000000..105136647 --- /dev/null +++ b/model_compression_toolkit/target_platform_capabilities/schema/schema_functions.py @@ -0,0 +1,37 @@ +# Copyright 2024 Sony Semiconductor Israel, Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================== +import copy +from typing import Any, Dict + + +def clone_and_edit_object_params(obj: Any, **kwargs: Dict) -> Any: + """ + Clones the given object and edit some of its parameters. + + Args: + obj: An object to clone. + **kwargs: Keyword arguments to edit in the cloned object. + + Returns: + Edited copy of the given object. + """ + + obj_copy = copy.deepcopy(obj) + for k, v in kwargs.items(): + assert hasattr(obj_copy, + k), f'Edit parameter is possible only for existing parameters in the given object, ' \ + f'but {k} is not a parameter of {obj_copy}.' + setattr(obj_copy, k, v) + return obj_copy diff --git a/model_compression_toolkit/target_platform_capabilities/schema/v1.py b/model_compression_toolkit/target_platform_capabilities/schema/v1.py index 0dbae339b..019454642 100644 --- a/model_compression_toolkit/target_platform_capabilities/schema/v1.py +++ b/model_compression_toolkit/target_platform_capabilities/schema/v1.py @@ -28,8 +28,7 @@ from model_compression_toolkit.target_platform_capabilities.immutable import ImmutableClass from model_compression_toolkit.target_platform_capabilities.target_platform.current_tp_model import \ get_current_tp_model, _current_tp_model -from model_compression_toolkit.target_platform_capabilities.target_platform.target_platform_model_component import \ - TargetPlatformModelComponent +from model_compression_toolkit.target_platform_capabilities.schema.schema_functions import clone_and_edit_object_params class Signedness(Enum): @@ -45,27 +44,6 @@ class Signedness(Enum): UNSIGNED = 2 -def clone_and_edit_object_params(obj: Any, **kwargs: Dict) -> Any: - """ - Clones the given object and edit some of its parameters. - - Args: - obj: An object to clone. - **kwargs: Keyword arguments to edit in the cloned object. - - Returns: - Edited copy of the given object. - """ - - obj_copy = copy.deepcopy(obj) - for k, v in kwargs.items(): - assert hasattr(obj_copy, - k), f'Edit parameter is possible only for existing parameters in the given object, ' \ - f'but {k} is not a parameter of {obj_copy}.' - setattr(obj_copy, k, v) - return obj_copy - - class AttributeQuantizationConfig: """ Hold the quantization configuration of a weight attribute of a layer. @@ -387,6 +365,29 @@ def get_info(self): return {f'option {i}': cfg.get_info() for i, cfg in enumerate(self.quantization_config_list)} +class TargetPlatformModelComponent: + """ + Component of TargetPlatformModel (Fusing, OperatorsSet, etc.) + """ + def __init__(self, name: str): + """ + + Args: + name: Name of component. + """ + self.name = name + _current_tp_model.get().append_component(self) + + def get_info(self) -> Dict[str, Any]: + """ + + Returns: Get information about the component to display (return an empty dictionary. + the actual component should fill it with info). + + """ + return {} + + class OperatorsSetBase(TargetPlatformModelComponent): """ Base class to represent a set of operators. diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/__init__.py b/model_compression_toolkit/target_platform_capabilities/target_platform/__init__.py index fd72ac6fd..e01363b71 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/__init__.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/__init__.py @@ -16,7 +16,7 @@ from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attribute_filter import AttributeFilter from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework import TargetPlatformCapabilities, OperationsSetToLayers, Smaller, SmallerEq, NotEq, Eq, GreaterEq, Greater, LayerFilterParams, OperationsToLayers, get_current_tpc from model_compression_toolkit.target_platform_capabilities.target_platform.target_platform_model import get_default_quantization_config_options -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, OperatorsSet, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OperatorsSet, \ OperatorSetConcat, Signedness, AttributeQuantizationConfig, OpQuantizationConfig, QuantizationConfigOptions, Fusing from mct_quantizers import QuantizationMethod diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model.py b/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model.py index 212988b80..f2b6dec49 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model.py @@ -14,7 +14,7 @@ # ============================================================================== from model_compression_toolkit.target_platform_capabilities.target_platform.current_tp_model import get_current_tp_model -from model_compression_toolkit.target_platform_capabilities.schema.v1 import QuantizationConfigOptions +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import QuantizationConfigOptions def get_default_quantization_config_options() -> QuantizationConfigOptions: @@ -28,15 +28,3 @@ def get_default_quantization_config_options() -> QuantizationConfigOptions: return get_current_tp_model().default_qco -def get_default_quantization_config(): - """ - - Returns: The default OpQuantizationConfig of the model. This is the OpQuantizationConfig - to use when a layer's options is queried and it wasn't specified in the TargetPlatformCapabilities. - This OpQuantizationConfig is the single option in the default QuantizationConfigOptions. - - """ - - return get_current_tp_model().get_default_op_quantization_config() - - diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model_component.py b/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model_component.py deleted file mode 100644 index fbe0ad4c0..000000000 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/target_platform_model_component.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2022 Sony Semiconductor Israel, Inc. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== -from typing import Any, Dict - -from model_compression_toolkit.target_platform_capabilities.target_platform.current_tp_model import _current_tp_model - - -class TargetPlatformModelComponent: - """ - Component of TargetPlatformModel (Fusing, OperatorsSet, etc.) - """ - def __init__(self, name: str): - """ - - Args: - name: Name of component. - """ - self.name = name - _current_tp_model.get().append_component(self) - - def get_info(self) -> Dict[str, Any]: - """ - - Returns: Get information about the component to display (return an empty dictionary. - the actual component should fill it with info). - - """ - return {} diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/operations_to_layers.py b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/operations_to_layers.py index 58f32dc10..669a068a7 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/operations_to_layers.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/operations_to_layers.py @@ -18,7 +18,7 @@ from model_compression_toolkit.logger import Logger from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.current_tpc import _current_tpc from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.target_platform_capabilities_component import TargetPlatformCapabilitiesComponent -from model_compression_toolkit.target_platform_capabilities.schema.v1 import OperatorsSetBase, OperatorSetConcat +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import OperatorsSetBase, OperatorSetConcat from model_compression_toolkit import DefaultDict diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/target_platform_capabilities.py b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/target_platform_capabilities.py index 55c25ffd7..ef0cd5713 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/target_platform_capabilities.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/target_platform_capabilities.py @@ -24,7 +24,7 @@ from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.target_platform_capabilities_component import TargetPlatformCapabilitiesComponent from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.layer_filter_params import LayerFilterParams from model_compression_toolkit.target_platform_capabilities.immutable import ImmutableClass -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, OperatorsSetBase, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OperatorsSetBase, \ OpQuantizationConfig, QuantizationConfigOptions from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.current_tpc import _current_tpc diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tp_model.py index 004ce0f28..27d032c29 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_keras.py index 202d9802c..43ca2b4e0 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_DEPTHWISE_KERNEL, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_pytorch.py index a5b5af2c9..345e525a4 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, PYTORCH_KERNEL, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tp_model.py index f455e4168..9da497022 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ WEIGHTS_QUANTIZATION_METHOD, IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_keras.py index 81a902047..9bf658512 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_pytorch.py index e69e76082..9e03c497f 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_lut/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tp_model.py index 58aed4ded..24f3e6eae 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_keras.py index 4e291a0af..0bca7062f 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_DEPTHWISE_KERNEL, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_pytorch.py index ac98a618a..7c5ac0769 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v1_pot/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tp_model.py index 0003fc9f0..947c1608f 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_keras.py index cfb4bef23..b84430911 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_DEPTHWISE_KERNEL, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_pytorch.py index af3b35f23..471ed4ae0 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, PYTORCH_KERNEL, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tp_model.py index 167a6b9c2..31ba2d9ab 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ WEIGHTS_QUANTIZATION_METHOD, IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_keras.py index 375dde0b8..192464bac 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_pytorch.py index faabbdfe3..6d05fe910 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v2_lut/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tp_model.py index 2c997e37f..b053ea9eb 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_keras.py index 52248b18a..27f79c562 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_DEPTHWISE_KERNEL, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_pytorch.py index 39cc71373..3f52dfe1e 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, PYTORCH_KERNEL, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tp_model.py index 8891ccc1d..9102fcc02 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ WEIGHTS_QUANTIZATION_METHOD, IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_keras.py index 4b24aa73e..ffd712a8c 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_pytorch.py index 3069b07c5..458470bea 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v3_lut/tpc_pytorch.py @@ -23,7 +23,7 @@ from torch.nn import ReLU, ReLU6, PReLU, SiLU, Sigmoid, Tanh, Hardswish, LeakyReLU from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, leaky_relu -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tp_model.py index 6a3da25b0..493190b12 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tp_model.py @@ -15,11 +15,11 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, WEIGHTS_N_BITS, \ IMX500_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_keras.py index b6a190ac5..419a52c11 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.verify_packages import FOUND_SONY_CUSTOM_LAYERS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_DEPTHWISE_KERNEL, \ diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_pytorch.py index e1c552c11..6a39a854a 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/imx500_tpc/v4/tpc_pytorch.py @@ -25,7 +25,7 @@ import torch.nn.functional as F from torch.nn.functional import relu, relu6, prelu, silu, hardtanh, hardswish, hardsigmoid, leaky_relu, gelu -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, PYTORCH_KERNEL, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tp_model.py index fb6d864cc..232630f30 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tp_model.py @@ -15,10 +15,10 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, QNNPACK_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_keras.py index fa8fb07e9..73c6dd1f8 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_keras.py @@ -16,7 +16,7 @@ from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, \ KERAS_DEPTHWISE_KERNEL, BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_pytorch.py index b13e6d8c7..f1a0e39ef 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/qnnpack_tpc/v1/tpc_pytorch.py @@ -16,7 +16,7 @@ from torch.nn import Conv2d, Linear, BatchNorm2d, ConvTranspose2d, Hardtanh, ReLU, ReLU6 from torch.nn.functional import relu, relu6, hardtanh -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR, \ BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tp_model.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tp_model.py index 3c7e7e01c..b0a69c6e7 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tp_model.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tp_model.py @@ -15,10 +15,10 @@ from typing import List, Tuple import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.target_platform_capabilities.constants import BIAS_ATTR, KERNEL_ATTR, TFLITE_TP_MODEL -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, Signedness, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, Signedness, \ AttributeQuantizationConfig, OpQuantizationConfig tp = mct.target_platform diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_keras.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_keras.py index ad9626837..a5101f819 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_keras.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_keras.py @@ -15,7 +15,7 @@ import tensorflow as tf from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, BIAS diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_pytorch.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_pytorch.py index e12dbcbee..6af810100 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/tflite_tpc/v1/tpc_pytorch.py @@ -16,7 +16,7 @@ from torch.nn import AvgPool2d, MaxPool2d from torch.nn.functional import avg_pool2d, max_pool2d, interpolate -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR, \ BIAS diff --git a/tests/common_tests/helpers/generate_test_tp_model.py b/tests/common_tests/helpers/generate_test_tp_model.py index 19b8390ed..83faaa43e 100644 --- a/tests/common_tests/helpers/generate_test_tp_model.py +++ b/tests/common_tests/helpers/generate_test_tp_model.py @@ -15,12 +15,12 @@ import copy from typing import Dict, List, Any -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH, ACTIVATION_N_BITS_ATTRIBUTE, \ SUPPORTED_INPUT_ACTIVATION_NBITS_ATTRIBUTE from model_compression_toolkit.target_platform_capabilities.constants import OPS_SET_LIST, KERNEL_ATTR, BIAS_ATTR, \ WEIGHTS_N_BITS -from model_compression_toolkit.target_platform_capabilities.schema.v1 import Signedness, OpQuantizationConfig, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness, OpQuantizationConfig, \ QuantizationConfigOptions from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_op_quantization_configs, generate_tp_model import model_compression_toolkit as mct diff --git a/tests/common_tests/test_tp_model.py b/tests/common_tests/test_tp_model.py index 298d0dc4a..ed8a52b59 100644 --- a/tests/common_tests/test_tp_model.py +++ b/tests/common_tests/test_tp_model.py @@ -16,7 +16,7 @@ import unittest import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.constants import FLOAT_BITWIDTH from model_compression_toolkit.core.common import BaseNode from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR diff --git a/tests/keras_tests/exporter_tests/tflite_int8/imx500_int8_tp_model.py b/tests/keras_tests/exporter_tests/tflite_int8/imx500_int8_tp_model.py index 0470bc613..8e8f2eac4 100644 --- a/tests/keras_tests/exporter_tests/tflite_int8/imx500_int8_tp_model.py +++ b/tests/keras_tests/exporter_tests/tflite_int8/imx500_int8_tp_model.py @@ -17,7 +17,7 @@ import tensorflow as tf from packaging import version -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, BIAS, \ KERAS_DEPTHWISE_KERNEL, WEIGHTS_N_BITS @@ -33,7 +33,7 @@ Conv2DTranspose import model_compression_toolkit as mct -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, OpQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OpQuantizationConfig tp = mct.target_platform diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/bn_attributes_quantization_test.py b/tests/keras_tests/feature_networks_tests/feature_networks/bn_attributes_quantization_test.py index 7942824c5..8051b7154 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/bn_attributes_quantization_test.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/bn_attributes_quantization_test.py @@ -16,11 +16,11 @@ import numpy as np import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from mct_quantizers import QuantizationMethod, KerasQuantizationWrapper from model_compression_toolkit import DefaultDict from model_compression_toolkit.core.keras.constants import GAMMA, BETA -from model_compression_toolkit.target_platform_capabilities.schema.v1 import Signedness +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS, BIAS_ATTR from tests.common_tests.helpers.generate_test_tp_model import generate_test_attr_configs, \ DEFAULT_WEIGHT_ATTR_CONFIG, KERNEL_BASE_CONFIG, generate_test_op_qc, BIAS_CONFIG diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/const_quantization_test.py b/tests/keras_tests/feature_networks_tests/feature_networks/const_quantization_test.py index dbba20909..5d61c9d12 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/const_quantization_test.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/const_quantization_test.py @@ -17,7 +17,7 @@ import numpy as np import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.core import MixedPrecisionQuantizationConfig from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.v4.tp_model import generate_tp_model, \ get_op_quantization_configs diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_tests.py b/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_tests.py index 591818683..0d8bae6e5 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_tests.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_tests.py @@ -18,7 +18,7 @@ import tensorflow as tf from keras.activations import sigmoid, softmax -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from mct_quantizers import KerasActivationQuantizationHolder from model_compression_toolkit import DefaultDict from model_compression_toolkit.core.keras.constants import SIGMOID, SOFTMAX, BIAS diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/weights_mixed_precision_tests.py b/tests/keras_tests/feature_networks_tests/feature_networks/weights_mixed_precision_tests.py index 8522531b7..1e6f06deb 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/weights_mixed_precision_tests.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/weights_mixed_precision_tests.py @@ -17,7 +17,7 @@ import numpy as np import tensorflow as tf -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from mct_quantizers import KerasQuantizationWrapper from model_compression_toolkit.core.keras.constants import KERNEL from model_compression_toolkit.defaultdict import DefaultDict diff --git a/tests/keras_tests/function_tests/test_custom_layer.py b/tests/keras_tests/function_tests/test_custom_layer.py index e8b786c38..b56f1828b 100644 --- a/tests/keras_tests/function_tests/test_custom_layer.py +++ b/tests/keras_tests/function_tests/test_custom_layer.py @@ -18,8 +18,8 @@ import tensorflow as tf import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema -from model_compression_toolkit.target_platform_capabilities.schema.v1 import Signedness +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness from model_compression_toolkit.target_platform_capabilities.constants import BIAS_ATTR, KERNEL_ATTR from tests.common_tests.helpers.generate_test_tp_model import generate_test_attr_configs, DEFAULT_WEIGHT_ATTR_CONFIG, \ KERNEL_BASE_CONFIG, BIAS_CONFIG diff --git a/tests/keras_tests/function_tests/test_hmse_error_method.py b/tests/keras_tests/function_tests/test_hmse_error_method.py index 9b9e33967..6d1f0f586 100644 --- a/tests/keras_tests/function_tests/test_hmse_error_method.py +++ b/tests/keras_tests/function_tests/test_hmse_error_method.py @@ -19,7 +19,7 @@ from tensorflow.keras import layers import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit import DefaultDict from model_compression_toolkit.core import QuantizationConfig from model_compression_toolkit.constants import THRESHOLD, RANGE_MAX, NUM_QPARAM_HESSIAN_SAMPLES @@ -30,7 +30,7 @@ calculate_quantization_params from model_compression_toolkit.core.keras.constants import KERNEL, GAMMA from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, KERAS_KERNEL, BIAS -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import generate_keras_tpc from model_compression_toolkit.core.keras.default_framework_info import DEFAULT_KERAS_INFO from model_compression_toolkit.core.keras.keras_implementation import KerasImplementation diff --git a/tests/keras_tests/function_tests/test_layer_fusing.py b/tests/keras_tests/function_tests/test_layer_fusing.py index 5100dcef0..0c8a5b2e6 100644 --- a/tests/keras_tests/function_tests/test_layer_fusing.py +++ b/tests/keras_tests/function_tests/test_layer_fusing.py @@ -2,7 +2,7 @@ import numpy as np import tensorflow as tf -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.core import DEFAULTCONFIG from model_compression_toolkit.core.common.fusion.layer_fusing import fusion from model_compression_toolkit.core.common.quantization.set_node_quantization_config import \ diff --git a/tests/keras_tests/function_tests/test_node_quantization_configurations.py b/tests/keras_tests/function_tests/test_node_quantization_configurations.py index 08507cbab..82f2f4069 100644 --- a/tests/keras_tests/function_tests/test_node_quantization_configurations.py +++ b/tests/keras_tests/function_tests/test_node_quantization_configurations.py @@ -23,7 +23,7 @@ power_of_two_selection_histogram from model_compression_toolkit.core.common.quantization.quantizers.uniform_quantizers import power_of_two_quantizer from model_compression_toolkit.core.keras.constants import KERNEL, BIAS -from model_compression_toolkit.target_platform_capabilities.schema.v1 import AttributeQuantizationConfig +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import AttributeQuantizationConfig from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_op_quantization_configs diff --git a/tests/keras_tests/non_parallel_tests/test_keras_tp_model.py b/tests/keras_tests/non_parallel_tests/test_keras_tp_model.py index da48b9187..6f4478aff 100644 --- a/tests/keras_tests/non_parallel_tests/test_keras_tp_model.py +++ b/tests/keras_tests/non_parallel_tests/test_keras_tp_model.py @@ -22,7 +22,7 @@ from tensorflow.keras.applications.mobilenet_v2 import MobileNetV2 -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.core.common import BaseNode from tests.common_tests.helpers.generate_test_tp_model import generate_test_op_qc, generate_test_attr_configs diff --git a/tests/pytorch_tests/function_tests/layer_fusing_test.py b/tests/pytorch_tests/function_tests/layer_fusing_test.py index ad23bc623..ccf131ddd 100644 --- a/tests/pytorch_tests/function_tests/layer_fusing_test.py +++ b/tests/pytorch_tests/function_tests/layer_fusing_test.py @@ -17,7 +17,7 @@ from torch.nn import Conv2d, ReLU, SiLU, Sigmoid, Linear, Hardtanh from torch.nn.functional import relu, relu6 -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.target_platform_capabilities.target_platform import LayerFilterParams from model_compression_toolkit.core.pytorch.default_framework_info import DEFAULT_PYTORCH_INFO from model_compression_toolkit.core.pytorch.pytorch_implementation import PytorchImplementation diff --git a/tests/pytorch_tests/function_tests/test_pytorch_tp_model.py b/tests/pytorch_tests/function_tests/test_pytorch_tp_model.py index d3ce92a8a..cb7c7647d 100644 --- a/tests/pytorch_tests/function_tests/test_pytorch_tp_model.py +++ b/tests/pytorch_tests/function_tests/test_pytorch_tp_model.py @@ -23,7 +23,7 @@ from torchvision.models import mobilenet_v2 import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.core import MixedPrecisionQuantizationConfig from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.constants import PYTORCH diff --git a/tests/pytorch_tests/model_tests/feature_models/bn_attributes_quantization_test.py b/tests/pytorch_tests/model_tests/feature_models/bn_attributes_quantization_test.py index 1515b69b9..e51ead220 100644 --- a/tests/pytorch_tests/model_tests/feature_models/bn_attributes_quantization_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/bn_attributes_quantization_test.py @@ -16,7 +16,7 @@ from torch import nn import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from mct_quantizers import QuantizationMethod, PytorchQuantizationWrapper from model_compression_toolkit import DefaultDict from model_compression_toolkit.core.pytorch.constants import GAMMA, BETA @@ -24,7 +24,7 @@ BIAS_ATTR from tests.common_tests.helpers.generate_test_tp_model import generate_test_attr_configs, \ DEFAULT_WEIGHT_ATTR_CONFIG, KERNEL_BASE_CONFIG, generate_test_op_qc, BIAS_CONFIG -from model_compression_toolkit.target_platform_capabilities.schema.v1 import Signedness +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness from tests.pytorch_tests.model_tests.base_pytorch_test import BasePytorchTest from tests.pytorch_tests.utils import get_layers_from_model_by_type diff --git a/tests/pytorch_tests/model_tests/feature_models/const_quantization_test.py b/tests/pytorch_tests/model_tests/feature_models/const_quantization_test.py index 4231169ac..fea672a49 100644 --- a/tests/pytorch_tests/model_tests/feature_models/const_quantization_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/const_quantization_test.py @@ -17,8 +17,8 @@ import torch.nn as nn import numpy as np import model_compression_toolkit as mct -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema -from model_compression_toolkit.target_platform_capabilities.schema.v1 import Signedness +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness from model_compression_toolkit.core import MixedPrecisionQuantizationConfig from model_compression_toolkit.core.pytorch.utils import to_torch_tensor, torch_tensor_to_numpy, set_model from tests.pytorch_tests.model_tests.base_pytorch_feature_test import BasePytorchFeatureNetworkTest diff --git a/tests/pytorch_tests/model_tests/feature_models/mixed_precision_activation_test.py b/tests/pytorch_tests/model_tests/feature_models/mixed_precision_activation_test.py index b917a628e..881bfda44 100644 --- a/tests/pytorch_tests/model_tests/feature_models/mixed_precision_activation_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/mixed_precision_activation_test.py @@ -23,7 +23,7 @@ from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, PYTORCH_KERNEL, \ BIAS from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities, OperationsSetToLayers -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, OperatorsSet, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OperatorsSet, \ QuantizationConfigOptions from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_op_quantization_configs from tests.common_tests.helpers.generate_test_tp_model import generate_tp_model_with_activation_mp diff --git a/tests/pytorch_tests/model_tests/feature_models/mixed_precision_weights_test.py b/tests/pytorch_tests/model_tests/feature_models/mixed_precision_weights_test.py index 4e9d72f55..38a112550 100644 --- a/tests/pytorch_tests/model_tests/feature_models/mixed_precision_weights_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/mixed_precision_weights_test.py @@ -16,7 +16,7 @@ import numpy as np from torch.nn import Conv2d -import model_compression_toolkit.target_platform_capabilities.schema.v1 as schema +import model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema as schema from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.core import ResourceUtilization from model_compression_toolkit.core.common.mixed_precision.distance_weighting import MpDistanceWeighting @@ -25,7 +25,7 @@ from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS_ATTR from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities, \ OperationsSetToLayers -from model_compression_toolkit.target_platform_capabilities.schema.v1 import TargetPlatformModel, OperatorsSet, \ +from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OperatorsSet, \ QuantizationConfigOptions from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_tp_model, \ get_op_quantization_configs