From c280dd878fc66a32385afb0ad0411ce7a302c1bf Mon Sep 17 00:00:00 2001 From: Ofir Gordon Date: Sun, 5 Jan 2025 17:59:53 +0200 Subject: [PATCH] align tests and use CustomOpsetLayers --- model_compression_toolkit/core/__init__.py | 2 +- .../quantization/quantization_config.py | 19 +++++++++-- .../targetplatform2framework/attach2fw.py | 33 +++++-------------- .../bn_attributes_quantization_test.py | 3 +- .../feature_networks/manual_bit_selection.py | 3 +- .../requires_mixed_precision_test.py | 3 +- .../mixed_precision_bops_test.py | 3 +- .../feature_networks/mixed_precision_tests.py | 3 +- .../weights_mixed_precision_tests.py | 3 +- ...vation_weights_composition_substitution.py | 3 +- .../function_tests/test_custom_layer.py | 3 +- .../function_tests/test_hmse_error_method.py | 3 +- .../function_tests/test_layer_fusing.py | 3 +- .../test_resource_utilization_data.py | 3 +- .../test_set_layer_to_bitwidth.py | 3 +- ...t_weights_activation_split_substitution.py | 3 +- .../test_tensorboard_writer.py | 3 +- .../function_tests/layer_fusing_test.py | 3 +- .../resource_utilization_data_test.py | 3 +- .../bn_attributes_quantization_test.py | 3 +- .../feature_models/const_quantization_test.py | 3 +- .../feature_models/manual_bit_selection.py | 3 +- .../mixed_precision_activation_test.py | 3 +- .../mixed_precision_bops_test.py | 3 +- .../mixed_precision_weights_test.py | 3 +- .../model_tests/feature_models/qat_test.py | 3 +- 26 files changed, 48 insertions(+), 75 deletions(-) diff --git a/model_compression_toolkit/core/__init__.py b/model_compression_toolkit/core/__init__.py index b8f6ee3e9..cb41daafd 100644 --- a/model_compression_toolkit/core/__init__.py +++ b/model_compression_toolkit/core/__init__.py @@ -18,7 +18,7 @@ from model_compression_toolkit.core.common.quantization.debug_config import DebugConfig from model_compression_toolkit.core.common.quantization import quantization_config from model_compression_toolkit.core.common.mixed_precision import mixed_precision_quantization_config -from model_compression_toolkit.core.common.quantization.quantization_config import QuantizationConfig, QuantizationErrorMethod, DEFAULTCONFIG +from model_compression_toolkit.core.common.quantization.quantization_config import QuantizationConfig, QuantizationErrorMethod, DEFAULTCONFIG, CustomOpsetLayers from model_compression_toolkit.core.common.quantization.bit_width_config import BitWidthConfig from model_compression_toolkit.core.common.quantization.core_config import CoreConfig from model_compression_toolkit.core.common.mixed_precision.resource_utilization_tools.resource_utilization import ResourceUtilization diff --git a/model_compression_toolkit/core/common/quantization/quantization_config.py b/model_compression_toolkit/core/common/quantization/quantization_config.py index c54d5b4d7..50078fee9 100644 --- a/model_compression_toolkit/core/common/quantization/quantization_config.py +++ b/model_compression_toolkit/core/common/quantization/quantization_config.py @@ -16,11 +16,24 @@ from dataclasses import dataclass import math from enum import Enum -from typing import Optional, Dict +from typing import Optional, Dict, NamedTuple, List +from model_compression_toolkit import DefaultDict from model_compression_toolkit.constants import MIN_THRESHOLD -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers + + +class CustomOpsetLayers(NamedTuple): + """ + This struct is used to define a set of operators to map to a custom operator set defined in the TPC. + + Args: + operators: a list of framework operators to map to a certain custom opset name. + attr_mapping: a mapping between an opset name to a mapping between its attributes' general names and names in + the framework. + """ + + operators: List + attr_mapping: Optional[Dict[str, DefaultDict]] = None class QuantizationErrorMethod(Enum): diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2fw.py b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2fw.py index 71ab6a477..0c752e517 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2fw.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2fw.py @@ -1,25 +1,12 @@ -from typing import Dict, NamedTuple, List, Any, Optional +from typing import Dict, Optional -from model_compression_toolkit import DefaultDict from model_compression_toolkit.logger import Logger from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, \ OperatorsSet from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities, \ OperationsSetToLayers - -class CustomOpsetLayers(NamedTuple): - """ - This struct is used to define a set of operators to map to a custom operator set defined in the TPC. - - Args: - operators: a list of framework operators to map to a certain custom opset name. - attr_mapping: a mapping between an opset name to a mapping between its attributes' general names and names in - the framework. - """ - - operators: List - attr_mapping: Optional[Dict[str, DefaultDict]] = None +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers class AttachTpcToFramework: @@ -33,7 +20,7 @@ def __init__(self): self._opset2attr_mapping = None # Mapping of operation sets to their corresponding framework-specific layers def attach(self, tpc_model: TargetPlatformModel, - custom_opset2layer: Optional[Dict[str, CustomOpsetLayers]] = None + custom_opset2layer: Optional[Dict[str, 'CustomOpsetLayers']] = None ) -> TargetPlatformCapabilities: """ Attaching a TargetPlatformModel which includes a platform capabilities description to specific @@ -57,15 +44,11 @@ def attach(self, tpc_model: TargetPlatformModel, for opset in tpc_model.operator_set: if isinstance(opset, OperatorsSet): # filter out OperatorsSetConcat if opset.name in custom_opset2layer: - operators = custom_opset2layer[opset.name] - if len(operators) == 1: - OperationsSetToLayers(opset.name, operators[0]) - elif len(operators) == 2: - OperationsSetToLayers(opset.name, operators[0], attr_mapping=operators[1]) - else: - raise ValueError(f"Custom operator set to layer mapping should include up to 2 elements - " - f"a list of layers to attach to the operator and an optional mapping of " - f"attributes names, but given a mapping contains {len(operators)} elements.") + custom_opset_layers = custom_opset2layer[opset.name] + OperationsSetToLayers(opset.name, + layers=custom_opset_layers.operators, + attr_mapping=custom_opset_layers.attr_mapping) + elif opset.name in self._opset2layer: # Note that if the user provided a custom operator set with a name that exists in our # pre-defined set of operator sets, we prioritize the user's custom opset definition 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 3cb0d020b..52b957f2d 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 @@ -22,8 +22,7 @@ from model_compression_toolkit.core.keras.constants import GAMMA, BETA 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 model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers 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 tests.keras_tests.feature_networks_tests.base_keras_feature_test import BaseKerasFeatureNetworkTest diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/manual_bit_selection.py b/tests/keras_tests/feature_networks_tests/feature_networks/manual_bit_selection.py index 33f440159..eb83f903a 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/manual_bit_selection.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/manual_bit_selection.py @@ -22,8 +22,7 @@ QuantizationConfigOptions from model_compression_toolkit.target_platform_capabilities.schema.schema_functions import \ get_config_options_by_operators_set -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.common_tests.helpers.generate_test_tp_model import generate_test_op_qc, generate_test_attr_configs, \ generate_custom_test_tp_model from tests.common_tests.helpers.tpcs_for_tests.v3.tp_model import get_tp_model diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision/requires_mixed_precision_test.py b/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision/requires_mixed_precision_test.py index ec47756fe..a82ddd149 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision/requires_mixed_precision_test.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision/requires_mixed_precision_test.py @@ -18,8 +18,7 @@ from packaging import version -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2keras import \ AttachTpcToKeras diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_bops_test.py b/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_bops_test.py index 9abc17528..ac7933cc8 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_bops_test.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/mixed_precision_bops_test.py @@ -17,8 +17,7 @@ QuantizationConfig from keras.layers import Conv2D, Conv2DTranspose, DepthwiseConv2D, Dense, BatchNormalization, ReLU, Input, Add -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.keras_tests.feature_networks_tests.base_keras_feature_test import BaseKerasFeatureNetworkTest from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_op_quantization_configs import tensorflow as tf 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 80d4c2073..9d9f4de4b 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 @@ -24,8 +24,7 @@ from model_compression_toolkit.core import QuantizationConfig, CoreConfig from model_compression_toolkit.core.keras.constants import SIGMOID, SOFTMAX, BIAS from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, BIAS_ATTR, KERAS_KERNEL -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.common_tests.helpers.generate_test_tp_model import generate_test_op_qc, generate_test_attr_configs from tests.keras_tests.exporter_tests.tflite_int8.imx500_int8_tp_model import get_op_quantization_configs from tests.keras_tests.feature_networks_tests.base_keras_feature_test import BaseKerasFeatureNetworkTest 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 5631b10e6..7854b6f99 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 @@ -24,8 +24,7 @@ from model_compression_toolkit.defaultdict import DefaultDict from model_compression_toolkit.core.common.mixed_precision.distance_weighting import MpDistanceWeighting from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, KERAS_KERNEL, BIAS_ATTR, BIAS -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import \ get_op_quantization_configs, generate_keras_tpc from tests.common_tests.helpers.generate_test_tp_model import generate_test_op_qc, generate_test_attr_configs diff --git a/tests/keras_tests/function_tests/test_activation_weights_composition_substitution.py b/tests/keras_tests/function_tests/test_activation_weights_composition_substitution.py index b3de282d9..f88f9f271 100644 --- a/tests/keras_tests/function_tests/test_activation_weights_composition_substitution.py +++ b/tests/keras_tests/function_tests/test_activation_weights_composition_substitution.py @@ -20,8 +20,7 @@ from packaging import version import tensorflow as tf -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2keras import \ AttachTpcToKeras from tests.common_tests.helpers.generate_test_tp_model import generate_test_op_qc, generate_test_attr_configs diff --git a/tests/keras_tests/function_tests/test_custom_layer.py b/tests/keras_tests/function_tests/test_custom_layer.py index 13329e3e4..e82e89884 100644 --- a/tests/keras_tests/function_tests/test_custom_layer.py +++ b/tests/keras_tests/function_tests/test_custom_layer.py @@ -23,8 +23,7 @@ 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 model_compression_toolkit.target_platform_capabilities.target_platform import LayerFilterParams -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers 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 ff47e3085..39558f643 100644 --- a/tests/keras_tests/function_tests/test_hmse_error_method.py +++ b/tests/keras_tests/function_tests/test_hmse_error_method.py @@ -31,8 +31,7 @@ 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.mct_current_schema import AttributeQuantizationConfig -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2keras import \ AttachTpcToKeras from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import generate_keras_tpc diff --git a/tests/keras_tests/function_tests/test_layer_fusing.py b/tests/keras_tests/function_tests/test_layer_fusing.py index 7905daa82..730f78115 100644 --- a/tests/keras_tests/function_tests/test_layer_fusing.py +++ b/tests/keras_tests/function_tests/test_layer_fusing.py @@ -7,8 +7,7 @@ from model_compression_toolkit.core.common.fusion.layer_fusing import fusion from model_compression_toolkit.core.keras.default_framework_info import DEFAULT_KERAS_INFO from model_compression_toolkit.core.keras.keras_implementation import KerasImplementation -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2keras import \ AttachTpcToKeras from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import \ diff --git a/tests/keras_tests/function_tests/test_resource_utilization_data.py b/tests/keras_tests/function_tests/test_resource_utilization_data.py index 1241c107b..cd8b4d49e 100644 --- a/tests/keras_tests/function_tests/test_resource_utilization_data.py +++ b/tests/keras_tests/function_tests/test_resource_utilization_data.py @@ -26,8 +26,7 @@ from model_compression_toolkit.core.keras.constants import DEPTHWISE_KERNEL, KERNEL from model_compression_toolkit.core.keras.graph_substitutions.substitutions.separableconv_decomposition import \ POINTWISE_KERNEL -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.common_tests.helpers.generate_test_tp_model import generate_test_op_qc, generate_test_attr_configs from tests.keras_tests.tpc_keras import get_tpc_with_activation_mp_keras diff --git a/tests/keras_tests/function_tests/test_set_layer_to_bitwidth.py b/tests/keras_tests/function_tests/test_set_layer_to_bitwidth.py index 8d2d4d271..c612163cc 100644 --- a/tests/keras_tests/function_tests/test_set_layer_to_bitwidth.py +++ b/tests/keras_tests/function_tests/test_set_layer_to_bitwidth.py @@ -20,8 +20,7 @@ from keras import Input from keras.layers import Conv2D -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers if tf.__version__ >= "2.13": from keras.src.engine.input_layer import InputLayer diff --git a/tests/keras_tests/function_tests/test_weights_activation_split_substitution.py b/tests/keras_tests/function_tests/test_weights_activation_split_substitution.py index 7e8f674ee..e3f6020cb 100644 --- a/tests/keras_tests/function_tests/test_weights_activation_split_substitution.py +++ b/tests/keras_tests/function_tests/test_weights_activation_split_substitution.py @@ -17,8 +17,7 @@ import keras import unittest -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers if tf.__version__ >= "2.13": from keras.src.layers import Conv2D, Conv2DTranspose, DepthwiseConv2D, Dense, BatchNormalization, ReLU, Input diff --git a/tests/keras_tests/non_parallel_tests/test_tensorboard_writer.py b/tests/keras_tests/non_parallel_tests/test_tensorboard_writer.py index c03811e90..987d6f5b6 100644 --- a/tests/keras_tests/non_parallel_tests/test_tensorboard_writer.py +++ b/tests/keras_tests/non_parallel_tests/test_tensorboard_writer.py @@ -32,8 +32,7 @@ from model_compression_toolkit.core.keras.default_framework_info import DEFAULT_KERAS_INFO from model_compression_toolkit.core.keras.keras_implementation import KerasImplementation from model_compression_toolkit.logger import Logger -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2keras import \ AttachTpcToKeras from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import generate_keras_tpc diff --git a/tests/pytorch_tests/function_tests/layer_fusing_test.py b/tests/pytorch_tests/function_tests/layer_fusing_test.py index 3a3803bb7..0ab6db09e 100644 --- a/tests/pytorch_tests/function_tests/layer_fusing_test.py +++ b/tests/pytorch_tests/function_tests/layer_fusing_test.py @@ -22,8 +22,7 @@ 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 -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2pytorch import \ AttachTpcToPytorch from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import \ diff --git a/tests/pytorch_tests/function_tests/resource_utilization_data_test.py b/tests/pytorch_tests/function_tests/resource_utilization_data_test.py index 55328c975..6eefe763d 100644 --- a/tests/pytorch_tests/function_tests/resource_utilization_data_test.py +++ b/tests/pytorch_tests/function_tests/resource_utilization_data_test.py @@ -21,8 +21,7 @@ from model_compression_toolkit.core import QuantizationConfig from model_compression_toolkit.core.pytorch.reader.node_holders import DummyPlaceHolder -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import \ get_op_quantization_configs from model_compression_toolkit.core.pytorch.constants import KERNEL 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 0348143f4..ca1c09f3e 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 @@ -23,8 +23,7 @@ from model_compression_toolkit.core.pytorch.constants import GAMMA, BETA from model_compression_toolkit.target_platform_capabilities.constants import KERNEL_ATTR, PYTORCH_KERNEL, BIAS, \ BIAS_ATTR -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers 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.mct_current_schema import Signedness 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 017bb4fa9..cda176144 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 @@ -21,8 +21,7 @@ from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import Signedness from model_compression_toolkit.core import MixedPrecisionQuantizationConfig, CoreConfig, QuantizationConfig from model_compression_toolkit.core.pytorch.utils import to_torch_tensor, torch_tensor_to_numpy, set_model -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.common_tests.helpers.tpcs_for_tests.v4.tp_model import get_tp_model as get_tp_v4 from tests.common_tests.helpers.tpcs_for_tests.v3.tp_model import get_tp_model as get_tp_v3 from tests.pytorch_tests.model_tests.base_pytorch_feature_test import BasePytorchFeatureNetworkTest diff --git a/tests/pytorch_tests/model_tests/feature_models/manual_bit_selection.py b/tests/pytorch_tests/model_tests/feature_models/manual_bit_selection.py index 525a4441c..5d012769c 100644 --- a/tests/pytorch_tests/model_tests/feature_models/manual_bit_selection.py +++ b/tests/pytorch_tests/model_tests/feature_models/manual_bit_selection.py @@ -24,8 +24,7 @@ QuantizationConfigOptions from model_compression_toolkit.target_platform_capabilities.schema.schema_functions import \ get_config_options_by_operators_set -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.common_tests.helpers.generate_test_tp_model import generate_custom_test_tp_model from tests.common_tests.helpers.tpcs_for_tests.v3.tp_model import get_tp_model from tests.pytorch_tests.model_tests.feature_models.mixed_precision_activation_test import \ 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 13d14e168..337f7dd8b 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 @@ -27,8 +27,7 @@ from model_compression_toolkit.target_platform_capabilities.target_platform import TargetPlatformCapabilities, OperationsSetToLayers from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OperatorsSet, \ QuantizationConfigOptions -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers 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 from tests.pytorch_tests.model_tests.base_pytorch_test import BasePytorchTest diff --git a/tests/pytorch_tests/model_tests/feature_models/mixed_precision_bops_test.py b/tests/pytorch_tests/model_tests/feature_models/mixed_precision_bops_test.py index e6758fc41..7016a84fd 100644 --- a/tests/pytorch_tests/model_tests/feature_models/mixed_precision_bops_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/mixed_precision_bops_test.py @@ -15,8 +15,7 @@ import torch.nn from model_compression_toolkit.core import MixedPrecisionQuantizationConfig, ResourceUtilization, MixedPrecisionQuantizationConfig from model_compression_toolkit.core.pytorch.reader.node_holders import DummyPlaceHolder -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from tests.pytorch_tests.model_tests.base_pytorch_test import BasePytorchTest from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_op_quantization_configs 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 3c79c30ff..1fa5fa58e 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 @@ -27,8 +27,7 @@ OperationsSetToLayers from model_compression_toolkit.target_platform_capabilities.schema.mct_current_schema import TargetPlatformModel, OperatorsSet, \ QuantizationConfigOptions -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import get_tp_model, \ get_op_quantization_configs from tests.common_tests.helpers.generate_test_tp_model import generate_mixed_precision_test_tp_model diff --git a/tests/pytorch_tests/model_tests/feature_models/qat_test.py b/tests/pytorch_tests/model_tests/feature_models/qat_test.py index 3fd72af38..1d68ad95e 100644 --- a/tests/pytorch_tests/model_tests/feature_models/qat_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/qat_test.py @@ -33,8 +33,7 @@ from model_compression_toolkit.core.pytorch.utils import to_torch_tensor from model_compression_toolkit.qat.pytorch.quantizer.base_pytorch_qat_weight_quantizer import \ BasePytorchQATWeightTrainableQuantizer -from model_compression_toolkit.target_platform_capabilities.target_platform.targetplatform2framework.attach2fw import \ - CustomOpsetLayers +from model_compression_toolkit.core.common.quantization.quantization_config import CustomOpsetLayers from model_compression_toolkit.target_platform_capabilities.tpc_models.imx500_tpc.latest import generate_pytorch_tpc, \ get_op_quantization_configs from model_compression_toolkit.trainable_infrastructure import TrainingMethod