From 37c09bb6e08b12c2eff4ad9499d0bc1c286105f7 Mon Sep 17 00:00:00 2001 From: Ofir Gordon Date: Sun, 5 Jan 2025 16:19:51 +0200 Subject: [PATCH] fix PR comments and modify opset names enum (change to str enum and removed OPSET prefix) --- .../quantization/quantization_config.py | 4 +- .../target_platform_capabilities/schema/v1.py | 114 ++++++++-------- .../targetplatform2framework/attach2fw.py | 18 ++- .../targetplatform2framework/attach2keras.py | 128 +++++++++--------- .../attach2pytorch.py | 124 ++++++++--------- .../operations_to_layers.py | 2 +- .../get_target_platform_capabilities.py | 8 +- .../tpc_models/imx500_tpc/v1/tp_model.py | 80 +++++------ .../tpc_models/qnnpack_tpc/v1/tp_model.py | 18 +-- .../tpc_models/tflite_tpc/v1/tp_model.py | 60 ++++---- .../xquant/keras/keras_report_utils.py | 2 +- .../helpers/tpcs_for_tests/__init__.py | 14 ++ .../helpers/tpcs_for_tests/v1/tp_model.py | 82 +++++------ .../helpers/tpcs_for_tests/v1_lut/tp_model.py | 82 +++++------ .../helpers/tpcs_for_tests/v1_pot/tp_model.py | 82 +++++------ .../helpers/tpcs_for_tests/v2/tp_model.py | 82 +++++------ .../helpers/tpcs_for_tests/v2_lut/tp_model.py | 82 +++++------ .../helpers/tpcs_for_tests/v3/tp_model.py | 88 ++++++------ .../helpers/tpcs_for_tests/v3_lut/tp_model.py | 86 ++++++------ .../helpers/tpcs_for_tests/v4/tp_model.py | 106 +++++++-------- .../feature_networks/activation_16bit_test.py | 8 +- .../const_quantization_test.py | 12 +- .../feature_networks/manual_bit_selection.py | 12 +- .../feature_networks/mixed_precision_tests.py | 2 +- .../test_quant_config_filtering.py | 8 +- .../function_tests/layer_fusing_test.py | 10 +- .../test_quant_config_filtering.py | 8 +- .../feature_models/activation_16bit_test.py | 12 +- .../feature_models/manual_bit_selection.py | 8 +- 29 files changed, 686 insertions(+), 656 deletions(-) diff --git a/model_compression_toolkit/core/common/quantization/quantization_config.py b/model_compression_toolkit/core/common/quantization/quantization_config.py index eb5f6d5d4..62a99a0f7 100644 --- a/model_compression_toolkit/core/common/quantization/quantization_config.py +++ b/model_compression_toolkit/core/common/quantization/quantization_config.py @@ -20,6 +20,8 @@ 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 QuantizationErrorMethod(Enum): @@ -88,7 +90,7 @@ class QuantizationConfig: concat_threshold_update: bool = False activation_bias_correction: bool = False activation_bias_correction_threshold: float = 0.0 - custom_tpc_opset_to_layer: Optional[Dict[str, Tuple[List[Any], Optional[Dict[str, DefaultDict]]]]] = None + custom_tpc_opset_to_layer: Optional[Dict[str, CustomOpsetLayers]] = None # Default quantization configuration the library use. diff --git a/model_compression_toolkit/target_platform_capabilities/schema/v1.py b/model_compression_toolkit/target_platform_capabilities/schema/v1.py index c06ad63c9..a00d32953 100644 --- a/model_compression_toolkit/target_platform_capabilities/schema/v1.py +++ b/model_compression_toolkit/target_platform_capabilities/schema/v1.py @@ -24,63 +24,63 @@ class OperatorSetNames(str, Enum): - OPSET_CONV = "Conv" - OPSET_DEPTHWISE_CONV = "DepthwiseConv2D" - OPSET_CONV_TRANSPOSE = "ConvTranspose" - OPSET_FULLY_CONNECTED = "FullyConnected" - OPSET_CONCATENATE = "Concatenate" - OPSET_STACK = "Stack" - OPSET_UNSTACK = "Unstack" - OPSET_GATHER = "Gather" - OPSET_EXPAND = "Expend" - OPSET_BATCH_NORM = "BatchNorm" - OPSET_L2NORM = "L2Norm" - OPSET_RELU = "ReLU" - OPSET_RELU6 = "ReLU6" - OPSET_LEAKY_RELU = "LEAKYReLU" - OPSET_ELU = "Elu" - OPSET_HARD_TANH = "HardTanh" - OPSET_ADD = "Add" - OPSET_SUB = "Sub" - OPSET_MUL = "Mul" - OPSET_DIV = "Div" - OPSET_MIN = "Min" - OPSET_MAX = "Max" - OPSET_PRELU = "PReLU" - OPSET_ADD_BIAS = "AddBias" - OPSET_SWISH = "Swish" - OPSET_SIGMOID = "Sigmoid" - OPSET_SOFTMAX = "Softmax" - OPSET_LOG_SOFTMAX = "LogSoftmax" - OPSET_TANH = "Tanh" - OPSET_GELU = "Gelu" - OPSET_HARDSIGMOID = "HardSigmoid" - OPSET_HARDSWISH = "HardSwish" - OPSET_FLATTEN = "Flatten" - OPSET_GET_ITEM = "GetItem" - OPSET_RESHAPE = "Reshape" - OPSET_UNSQUEEZE = "Unsqueeze" - OPSET_SQUEEZE = "Squeeze" - OPSET_PERMUTE = "Permute" - OPSET_TRANSPOSE = "Transpose" - OPSET_DROPOUT = "Dropout" - OPSET_SPLIT_CHUNK = "SplitChunk" - OPSET_MAXPOOL = "MaxPool" - OPSET_AVGPOOL = "AvgPool" - OPSET_SIZE = "Size" - OPSET_SHAPE = "Shape" - OPSET_EQUAL = "Equal" - OPSET_ARGMAX = "ArgMax" - OPSET_TOPK = "TopK" - OPSET_FAKE_QUANT = "FakeQuant" - OPSET_COMBINED_NON_MAX_SUPPRESSION = "CombinedNonMaxSuppression" - OPSET_ZERO_PADDING2d = "ZeroPadding2D" - OPSET_CAST = "Cast" - OPSET_RESIZE = "Resize" - OPSET_PAD = "Pad" - OPSET_FOLD = "Fold" - OPSET_STRIDED_SLICE = "StridedSlice" - OPSET_SSD_POST_PROCESS = "SSDPostProcess" + CONV = "Conv" + DEPTHWISE_CONV = "DepthwiseConv2D" + CONV_TRANSPOSE = "ConvTranspose" + FULLY_CONNECTED = "FullyConnected" + CONCATENATE = "Concatenate" + STACK = "Stack" + UNSTACK = "Unstack" + GATHER = "Gather" + EXPAND = "Expend" + BATCH_NORM = "BatchNorm" + L2NORM = "L2Norm" + RELU = "ReLU" + RELU6 = "ReLU6" + LEAKY_RELU = "LEAKYReLU" + ELU = "Elu" + HARD_TANH = "HardTanh" + ADD = "Add" + SUB = "Sub" + MUL = "Mul" + DIV = "Div" + MIN = "Min" + MAX = "Max" + PRELU = "PReLU" + ADD_BIAS = "AddBias" + SWISH = "Swish" + SIGMOID = "Sigmoid" + SOFTMAX = "Softmax" + LOG_SOFTMAX = "LogSoftmax" + TANH = "Tanh" + GELU = "Gelu" + HARDSIGMOID = "HardSigmoid" + HARDSWISH = "HardSwish" + FLATTEN = "Flatten" + GET_ITEM = "GetItem" + RESHAPE = "Reshape" + UNSQUEEZE = "Unsqueeze" + SQUEEZE = "Squeeze" + PERMUTE = "Permute" + TRANSPOSE = "Transpose" + DROPOUT = "Dropout" + SPLIT_CHUNK = "SplitChunk" + MAXPOOL = "MaxPool" + AVGPOOL = "AvgPool" + SIZE = "Size" + SHAPE = "Shape" + EQUAL = "Equal" + ARGMAX = "ArgMax" + TOPK = "TopK" + FAKE_QUANT = "FakeQuant" + COMBINED_NON_MAX_SUPPRESSION = "CombinedNonMaxSuppression" + ZERO_PADDING2D = "ZeroPadding2D" + CAST = "Cast" + RESIZE = "Resize" + PAD = "Pad" + FOLD = "Fold" + STRIDED_SLICE = "StridedSlice" + SSD_POST_PROCESS = "SSDPostProcess" @classmethod def get_values(cls): 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 15f684b88..a6d02effb 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,4 +1,4 @@ -from typing import Dict, Tuple, List, Any, Optional +from typing import Dict, NamedTuple, List, Any, Optional from model_compression_toolkit import DefaultDict from model_compression_toolkit.logger import Logger @@ -8,6 +8,20 @@ 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]] + + class AttachTpcToFramework: def __init__(self): @@ -19,7 +33,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, Tuple[List[Any], Optional[Dict[str, DefaultDict]]]]] = None + custom_opset2layer: Optional[Dict[str, CustomOpsetLayers]] = None ) -> TargetPlatformCapabilities: """ Attaching a TargetPlatformModel which includes a platform capabilities description to specific diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2keras.py b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2keras.py index f8373ae23..2f1157868 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2keras.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2keras.py @@ -44,85 +44,85 @@ def __init__(self): super().__init__() self._opset2layer = { - OperatorSetNames.OPSET_CONV: [Conv2D, tf.nn.conv2d], - OperatorSetNames.OPSET_DEPTHWISE_CONV: [DepthwiseConv2D, tf.nn.depthwise_conv2d], - OperatorSetNames.OPSET_CONV_TRANSPOSE: [Conv2DTranspose, tf.nn.conv2d_transpose], - OperatorSetNames.OPSET_FULLY_CONNECTED: [Dense], - OperatorSetNames.OPSET_CONCATENATE: [tf.concat, Concatenate], - OperatorSetNames.OPSET_STACK: [tf.stack], - OperatorSetNames.OPSET_UNSTACK: [tf.unstack], - OperatorSetNames.OPSET_GATHER: [tf.gather, tf.compat.v1.gather], - OperatorSetNames.OPSET_EXPAND: [], - OperatorSetNames.OPSET_BATCH_NORM: [BatchNormalization, tf.nn.batch_normalization], - OperatorSetNames.OPSET_RELU: [tf.nn.relu, ReLU, LayerFilterParams(Activation, activation="relu")], - OperatorSetNames.OPSET_RELU6: [tf.nn.relu6], - OperatorSetNames.OPSET_LEAKY_RELU: [tf.nn.leaky_relu, LeakyReLU, LayerFilterParams(Activation, activation="leaky_relu")], - OperatorSetNames.OPSET_HARD_TANH: [LayerFilterParams(Activation, activation="hard_tanh")], - OperatorSetNames.OPSET_ADD: [tf.add, Add], - OperatorSetNames.OPSET_SUB: [tf.subtract, Subtract], - OperatorSetNames.OPSET_MUL: [tf.math.multiply, Multiply], - OperatorSetNames.OPSET_DIV: [tf.math.divide, tf.math.truediv], - OperatorSetNames.OPSET_MIN: [tf.math.minimum, Minimum], - OperatorSetNames.OPSET_MAX: [tf.math.maximum, Maximum], - OperatorSetNames.OPSET_PRELU: [PReLU], - OperatorSetNames.OPSET_SWISH: [tf.nn.swish, LayerFilterParams(Activation, activation="swish")], - OperatorSetNames.OPSET_HARDSWISH: [LayerFilterParams(Activation, activation="hard_swish")], - OperatorSetNames.OPSET_SIGMOID: [tf.nn.sigmoid, LayerFilterParams(Activation, activation="sigmoid")], - OperatorSetNames.OPSET_TANH: [tf.nn.tanh, LayerFilterParams(Activation, activation="tanh")], - OperatorSetNames.OPSET_GELU: [tf.nn.gelu, LayerFilterParams(Activation, activation="gelu")], - OperatorSetNames.OPSET_HARDSIGMOID: [tf.keras.activations.hard_sigmoid, - LayerFilterParams(Activation, activation="hard_sigmoid")], - OperatorSetNames.OPSET_FLATTEN: [Flatten], - OperatorSetNames.OPSET_GET_ITEM: [tf.__operators__.getitem], - OperatorSetNames.OPSET_RESHAPE: [Reshape, tf.reshape], - OperatorSetNames.OPSET_PERMUTE: [Permute], - OperatorSetNames.OPSET_TRANSPOSE: [tf.transpose], - OperatorSetNames.OPSET_UNSQUEEZE: [tf.expand_dims], - OperatorSetNames.OPSET_SQUEEZE: [tf.squeeze], - OperatorSetNames.OPSET_DROPOUT: [Dropout], - OperatorSetNames.OPSET_SPLIT_CHUNK: [tf.split], - OperatorSetNames.OPSET_MAXPOOL: [MaxPooling2D, tf.nn.avg_pool2d], - OperatorSetNames.OPSET_AVGPOOL: [AveragePooling2D], - OperatorSetNames.OPSET_SIZE: [tf.size], - OperatorSetNames.OPSET_RESIZE: [tf.image.resize], - OperatorSetNames.OPSET_PAD: [tf.pad, Cropping2D], - OperatorSetNames.OPSET_FOLD: [tf.space_to_batch_nd], - OperatorSetNames.OPSET_SHAPE: [tf.shape, tf.compat.v1.shape], - OperatorSetNames.OPSET_EQUAL: [tf.math.equal], - OperatorSetNames.OPSET_ARGMAX: [tf.math.argmax], - OperatorSetNames.OPSET_TOPK: [tf.nn.top_k], - OperatorSetNames.OPSET_FAKE_QUANT: [tf.quantization.fake_quant_with_min_max_vars], - OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION: [tf.image.combined_non_max_suppression], - OperatorSetNames.OPSET_ZERO_PADDING2d: [ZeroPadding2D], - OperatorSetNames.OPSET_CAST: [tf.cast], - OperatorSetNames.OPSET_STRIDED_SLICE: [tf.strided_slice], - OperatorSetNames.OPSET_ELU: [tf.nn.elu, LayerFilterParams(Activation, activation="elu")], - OperatorSetNames.OPSET_SOFTMAX: [tf.nn.softmax, Softmax, - LayerFilterParams(Activation, activation="softmax")], - OperatorSetNames.OPSET_LOG_SOFTMAX: [tf.nn.log_softmax], - OperatorSetNames.OPSET_ADD_BIAS: [tf.nn.bias_add], - OperatorSetNames.OPSET_L2NORM: [tf.math.l2_normalize], + OperatorSetNames.CONV: [Conv2D, tf.nn.conv2d], + OperatorSetNames.DEPTHWISE_CONV: [DepthwiseConv2D, tf.nn.depthwise_conv2d], + OperatorSetNames.CONV_TRANSPOSE: [Conv2DTranspose, tf.nn.conv2d_transpose], + OperatorSetNames.FULLY_CONNECTED: [Dense], + OperatorSetNames.CONCATENATE: [tf.concat, Concatenate], + OperatorSetNames.STACK: [tf.stack], + OperatorSetNames.UNSTACK: [tf.unstack], + OperatorSetNames.GATHER: [tf.gather, tf.compat.v1.gather], + OperatorSetNames.EXPAND: [], + OperatorSetNames.BATCH_NORM: [BatchNormalization, tf.nn.batch_normalization], + OperatorSetNames.RELU: [tf.nn.relu, ReLU, LayerFilterParams(Activation, activation="relu")], + OperatorSetNames.RELU6: [tf.nn.relu6], + OperatorSetNames.LEAKY_RELU: [tf.nn.leaky_relu, LeakyReLU, LayerFilterParams(Activation, activation="leaky_relu")], + OperatorSetNames.HARD_TANH: [LayerFilterParams(Activation, activation="hard_tanh")], + OperatorSetNames.ADD: [tf.add, Add], + OperatorSetNames.SUB: [tf.subtract, Subtract], + OperatorSetNames.MUL: [tf.math.multiply, Multiply], + OperatorSetNames.DIV: [tf.math.divide, tf.math.truediv], + OperatorSetNames.MIN: [tf.math.minimum, Minimum], + OperatorSetNames.MAX: [tf.math.maximum, Maximum], + OperatorSetNames.PRELU: [PReLU], + OperatorSetNames.SWISH: [tf.nn.swish, LayerFilterParams(Activation, activation="swish")], + OperatorSetNames.HARDSWISH: [LayerFilterParams(Activation, activation="hard_swish")], + OperatorSetNames.SIGMOID: [tf.nn.sigmoid, LayerFilterParams(Activation, activation="sigmoid")], + OperatorSetNames.TANH: [tf.nn.tanh, LayerFilterParams(Activation, activation="tanh")], + OperatorSetNames.GELU: [tf.nn.gelu, LayerFilterParams(Activation, activation="gelu")], + OperatorSetNames.HARDSIGMOID: [tf.keras.activations.hard_sigmoid, + LayerFilterParams(Activation, activation="hard_sigmoid")], + OperatorSetNames.FLATTEN: [Flatten], + OperatorSetNames.GET_ITEM: [tf.__operators__.getitem], + OperatorSetNames.RESHAPE: [Reshape, tf.reshape], + OperatorSetNames.PERMUTE: [Permute], + OperatorSetNames.TRANSPOSE: [tf.transpose], + OperatorSetNames.UNSQUEEZE: [tf.expand_dims], + OperatorSetNames.SQUEEZE: [tf.squeeze], + OperatorSetNames.DROPOUT: [Dropout], + OperatorSetNames.SPLIT_CHUNK: [tf.split], + OperatorSetNames.MAXPOOL: [MaxPooling2D, tf.nn.avg_pool2d], + OperatorSetNames.AVGPOOL: [AveragePooling2D], + OperatorSetNames.SIZE: [tf.size], + OperatorSetNames.RESIZE: [tf.image.resize], + OperatorSetNames.PAD: [tf.pad, Cropping2D], + OperatorSetNames.FOLD: [tf.space_to_batch_nd], + OperatorSetNames.SHAPE: [tf.shape, tf.compat.v1.shape], + OperatorSetNames.EQUAL: [tf.math.equal], + OperatorSetNames.ARGMAX: [tf.math.argmax], + OperatorSetNames.TOPK: [tf.nn.top_k], + OperatorSetNames.FAKE_QUANT: [tf.quantization.fake_quant_with_min_max_vars], + OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION: [tf.image.combined_non_max_suppression], + OperatorSetNames.ZERO_PADDING2D: [ZeroPadding2D], + OperatorSetNames.CAST: [tf.cast], + OperatorSetNames.STRIDED_SLICE: [tf.strided_slice], + OperatorSetNames.ELU: [tf.nn.elu, LayerFilterParams(Activation, activation="elu")], + OperatorSetNames.SOFTMAX: [tf.nn.softmax, Softmax, + LayerFilterParams(Activation, activation="softmax")], + OperatorSetNames.LOG_SOFTMAX: [tf.nn.log_softmax], + OperatorSetNames.ADD_BIAS: [tf.nn.bias_add], + OperatorSetNames.L2NORM: [tf.math.l2_normalize], } if FOUND_SONY_CUSTOM_LAYERS: - self._opset2layer[OperatorSetNames.OPSET_SSD_POST_PROCESS] = [SSDPostProcess] + self._opset2layer[OperatorSetNames.SSD_POST_PROCESS] = [SSDPostProcess] else: # If Custom layers is not installed then we don't want the user to fail, but just ignore custom layers # in the initialized framework TPC - self._opset2layer[OperatorSetNames.OPSET_SSD_POST_PROCESS] = [] + self._opset2layer[OperatorSetNames.SSD_POST_PROCESS] = [] self._opset2attr_mapping = { - OperatorSetNames.OPSET_CONV: { + OperatorSetNames.CONV: { KERNEL_ATTR: DefaultDict(default_value=KERAS_KERNEL), BIAS_ATTR: DefaultDict(default_value=BIAS)}, - OperatorSetNames.OPSET_CONV_TRANSPOSE: { + OperatorSetNames.CONV_TRANSPOSE: { KERNEL_ATTR: DefaultDict(default_value=KERAS_KERNEL), BIAS_ATTR: DefaultDict(default_value=BIAS)}, - OperatorSetNames.OPSET_DEPTHWISE_CONV: { + OperatorSetNames.DEPTHWISE_CONV: { KERNEL_ATTR: DefaultDict({ DepthwiseConv2D: KERAS_DEPTHWISE_KERNEL, tf.nn.depthwise_conv2d: KERAS_DEPTHWISE_KERNEL}, default_value=KERAS_KERNEL), BIAS_ATTR: DefaultDict(default_value=BIAS)}, - OperatorSetNames.OPSET_FULLY_CONNECTED: { + OperatorSetNames.FULLY_CONNECTED: { KERNEL_ATTR: DefaultDict(default_value=KERAS_KERNEL), BIAS_ATTR: DefaultDict(default_value=BIAS)}} diff --git a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2pytorch.py b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2pytorch.py index 7c09fd745..fe94ea2a4 100644 --- a/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2pytorch.py +++ b/model_compression_toolkit/target_platform_capabilities/target_platform/targetplatform2framework/attach2pytorch.py @@ -38,69 +38,69 @@ def __init__(self): super().__init__() self._opset2layer = { - OperatorSetNames.OPSET_CONV: [Conv2d], - OperatorSetNames.OPSET_DEPTHWISE_CONV: [], # no specific operator for depthwise conv in pytorch - OperatorSetNames.OPSET_CONV_TRANSPOSE: [ConvTranspose2d], - OperatorSetNames.OPSET_FULLY_CONNECTED: [Linear], - OperatorSetNames.OPSET_CONCATENATE: [torch.cat, torch.concat, torch.concatenate], - OperatorSetNames.OPSET_STACK: [torch.stack], - OperatorSetNames.OPSET_UNSTACK: [unbind], - OperatorSetNames.OPSET_GATHER: [gather], - OperatorSetNames.OPSET_EXPAND: [torch.Tensor.expand], - OperatorSetNames.OPSET_BATCH_NORM: [BatchNorm2d], - OperatorSetNames.OPSET_RELU: [torch.relu, ReLU, relu], - OperatorSetNames.OPSET_RELU6: [ReLU6, relu6], - OperatorSetNames.OPSET_LEAKY_RELU: [LeakyReLU, leaky_relu], - OperatorSetNames.OPSET_HARD_TANH: [LayerFilterParams(Hardtanh, min_val=0), - LayerFilterParams(hardtanh, min_val=0)], - OperatorSetNames.OPSET_ADD: [operator.add, add], - OperatorSetNames.OPSET_SUB: [operator.sub, sub, subtract], - OperatorSetNames.OPSET_MUL: [operator.mul, mul, multiply], - OperatorSetNames.OPSET_DIV: [operator.truediv, div, divide], - OperatorSetNames.OPSET_ADD_BIAS: [], # no specific operator for bias_add in pytorch - OperatorSetNames.OPSET_MIN: [minimum], - OperatorSetNames.OPSET_MAX: [maximum], - OperatorSetNames.OPSET_PRELU: [PReLU, prelu], - OperatorSetNames.OPSET_SWISH: [SiLU, silu], - OperatorSetNames.OPSET_SIGMOID: [Sigmoid, sigmoid, F.sigmoid], - OperatorSetNames.OPSET_TANH: [Tanh, tanh, F.tanh], - OperatorSetNames.OPSET_GELU: [GELU, gelu], - OperatorSetNames.OPSET_HARDSIGMOID: [Hardsigmoid, hardsigmoid], - OperatorSetNames.OPSET_HARDSWISH: [Hardswish, hardswish], - OperatorSetNames.OPSET_FLATTEN: [Flatten, flatten], - OperatorSetNames.OPSET_GET_ITEM: [operator.getitem], - OperatorSetNames.OPSET_RESHAPE: [reshape], - OperatorSetNames.OPSET_UNSQUEEZE: [unsqueeze], - OperatorSetNames.OPSET_SQUEEZE: [squeeze], - OperatorSetNames.OPSET_PERMUTE: [permute], - OperatorSetNames.OPSET_TRANSPOSE: [transpose], - OperatorSetNames.OPSET_DROPOUT: [Dropout, dropout], - OperatorSetNames.OPSET_SPLIT_CHUNK: [split, chunk], - OperatorSetNames.OPSET_MAXPOOL: [MaxPool2d, F.max_pool2d], - OperatorSetNames.OPSET_AVGPOOL: [AvgPool2d, F.avg_pool2d], - OperatorSetNames.OPSET_SIZE: [torch.Tensor.size], - OperatorSetNames.OPSET_RESIZE: [torch.Tensor.resize], - OperatorSetNames.OPSET_PAD: [F.pad], - OperatorSetNames.OPSET_FOLD: [fold], - OperatorSetNames.OPSET_SHAPE: [torch.Tensor.shape], - OperatorSetNames.OPSET_EQUAL: [equal], - OperatorSetNames.OPSET_ARGMAX: [argmax], - OperatorSetNames.OPSET_TOPK: [topk], - OperatorSetNames.OPSET_FAKE_QUANT: [fake_quantize_per_channel_affine], - OperatorSetNames.OPSET_ZERO_PADDING2d: [ZeroPad2d], - OperatorSetNames.OPSET_CAST: [torch.Tensor.type], - OperatorSetNames.OPSET_STRIDED_SLICE: [], # no such operator in pytorch, the equivalent is get_item which has a separate operator set - OperatorSetNames.OPSET_ELU: [ELU, F.elu], - OperatorSetNames.OPSET_SOFTMAX: [Softmax, softmax, F.softmax], - OperatorSetNames.OPSET_LOG_SOFTMAX: [LogSoftmax], - OperatorSetNames.OPSET_L2NORM: [LayerFilterParams(torch.nn.functional.normalize, - Eq('p', 2) | Eq('p', None))], - OperatorSetNames.OPSET_SSD_POST_PROCESS: [], # no such operator in pytorch - OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION: [] # no such operator in pytorch + OperatorSetNames.CONV: [Conv2d], + OperatorSetNames.DEPTHWISE_CONV: [], # no specific operator for depthwise conv in pytorch + OperatorSetNames.CONV_TRANSPOSE: [ConvTranspose2d], + OperatorSetNames.FULLY_CONNECTED: [Linear], + OperatorSetNames.CONCATENATE: [torch.cat, torch.concat, torch.concatenate], + OperatorSetNames.STACK: [torch.stack], + OperatorSetNames.UNSTACK: [unbind], + OperatorSetNames.GATHER: [gather], + OperatorSetNames.EXPAND: [torch.Tensor.expand], + OperatorSetNames.BATCH_NORM: [BatchNorm2d], + OperatorSetNames.RELU: [torch.relu, ReLU, relu], + OperatorSetNames.RELU6: [ReLU6, relu6], + OperatorSetNames.LEAKY_RELU: [LeakyReLU, leaky_relu], + OperatorSetNames.HARD_TANH: [LayerFilterParams(Hardtanh, min_val=0), + LayerFilterParams(hardtanh, min_val=0)], + OperatorSetNames.ADD: [operator.add, add], + OperatorSetNames.SUB: [operator.sub, sub, subtract], + OperatorSetNames.MUL: [operator.mul, mul, multiply], + OperatorSetNames.DIV: [operator.truediv, div, divide], + OperatorSetNames.ADD_BIAS: [], # no specific operator for bias_add in pytorch + OperatorSetNames.MIN: [minimum], + OperatorSetNames.MAX: [maximum], + OperatorSetNames.PRELU: [PReLU, prelu], + OperatorSetNames.SWISH: [SiLU, silu], + OperatorSetNames.SIGMOID: [Sigmoid, sigmoid, F.sigmoid], + OperatorSetNames.TANH: [Tanh, tanh, F.tanh], + OperatorSetNames.GELU: [GELU, gelu], + OperatorSetNames.HARDSIGMOID: [Hardsigmoid, hardsigmoid], + OperatorSetNames.HARDSWISH: [Hardswish, hardswish], + OperatorSetNames.FLATTEN: [Flatten, flatten], + OperatorSetNames.GET_ITEM: [operator.getitem], + OperatorSetNames.RESHAPE: [reshape], + OperatorSetNames.UNSQUEEZE: [unsqueeze], + OperatorSetNames.SQUEEZE: [squeeze], + OperatorSetNames.PERMUTE: [permute], + OperatorSetNames.TRANSPOSE: [transpose], + OperatorSetNames.DROPOUT: [Dropout, dropout], + OperatorSetNames.SPLIT_CHUNK: [split, chunk], + OperatorSetNames.MAXPOOL: [MaxPool2d, F.max_pool2d], + OperatorSetNames.AVGPOOL: [AvgPool2d, F.avg_pool2d], + OperatorSetNames.SIZE: [torch.Tensor.size], + OperatorSetNames.RESIZE: [torch.Tensor.resize], + OperatorSetNames.PAD: [F.pad], + OperatorSetNames.FOLD: [fold], + OperatorSetNames.SHAPE: [torch.Tensor.shape], + OperatorSetNames.EQUAL: [equal], + OperatorSetNames.ARGMAX: [argmax], + OperatorSetNames.TOPK: [topk], + OperatorSetNames.FAKE_QUANT: [fake_quantize_per_channel_affine], + OperatorSetNames.ZERO_PADDING2D: [ZeroPad2d], + OperatorSetNames.CAST: [torch.Tensor.type], + OperatorSetNames.STRIDED_SLICE: [], # no such operator in pytorch, the equivalent is get_item which has a separate operator set + OperatorSetNames.ELU: [ELU, F.elu], + OperatorSetNames.SOFTMAX: [Softmax, softmax, F.softmax], + OperatorSetNames.LOG_SOFTMAX: [LogSoftmax], + OperatorSetNames.L2NORM: [LayerFilterParams(torch.nn.functional.normalize, + Eq('p', 2) | Eq('p', None))], + OperatorSetNames.SSD_POST_PROCESS: [], # no such operator in pytorch + OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION: [] # no such operator in pytorch } pytorch_linear_attr_mapping = {KERNEL_ATTR: DefaultDict(default_value=PYTORCH_KERNEL), BIAS_ATTR: DefaultDict(default_value=BIAS)} - self._opset2attr_mapping = {OperatorSetNames.OPSET_CONV: pytorch_linear_attr_mapping, - OperatorSetNames.OPSET_CONV_TRANSPOSE: pytorch_linear_attr_mapping, - OperatorSetNames.OPSET_FULLY_CONNECTED: pytorch_linear_attr_mapping} + self._opset2attr_mapping = {OperatorSetNames.CONV: pytorch_linear_attr_mapping, + OperatorSetNames.CONV_TRANSPOSE: pytorch_linear_attr_mapping, + OperatorSetNames.FULLY_CONNECTED: pytorch_linear_attr_mapping} 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 526be0916..ea09059e2 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 @@ -139,7 +139,7 @@ def validate_op_sets(self): f'is of type {type(ops2layers)}' # Assert that opset has a unique name. - assert not (ops2layers.name in existing_opset_names), f'OperationsSetToLayers names should be unique, but {ops2layers.name} appears to violate it.' + assert ops2layers.name not in existing_opset_names, f'OperationsSetToLayers names should be unique, but {ops2layers.name} appears to violate it.' existing_opset_names.append(ops2layers.name) # Assert that a layer does not appear in more than a single OperatorsSet in the TargetPlatformModel. diff --git a/model_compression_toolkit/target_platform_capabilities/tpc_models/get_target_platform_capabilities.py b/model_compression_toolkit/target_platform_capabilities/tpc_models/get_target_platform_capabilities.py index 4a9a8a9b7..c0170f954 100644 --- a/model_compression_toolkit/target_platform_capabilities/tpc_models/get_target_platform_capabilities.py +++ b/model_compression_toolkit/target_platform_capabilities/tpc_models/get_target_platform_capabilities.py @@ -32,15 +32,15 @@ def get_target_platform_capabilities(fw_name: str, existing TPC API. Args: - fw_name: Framework name of the TargetPlatformCapabilities (not used in this function). - target_platform_name: Target platform model name the model will use for inference (not used in this function). - target_platform_version: Target platform capabilities version (not used in this function). + fw_name: Framework name of the TargetPlatformCapabilities. + target_platform_name: Target platform model name the model will use for inference. + target_platform_version: Target platform capabilities version. Returns: A default TargetPlatformModel object. """ - assert fw_name == TENSORFLOW or fw_name == PYTORCH, f"Unsupported framework {fw_name}." + assert fw_name in [TENSORFLOW, PYTORCH], f"Unsupported framework {fw_name}." if target_platform_name == DEFAULT_TP_MODEL: return get_tp_model_imx500_v1() 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 e99dbd5d8..238e5dd93 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 @@ -170,51 +170,51 @@ def generate_tp_model(default_config: OpQuantizationConfig, no_quantization_config = (default_configuration_options.clone_and_edit(enable_activation_quantization=False) .clone_and_edit_weight_attribute(enable_weights_quantization=False)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration # options (useful for creating fusing patterns, for example): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend([conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, hard_swish, sigmoid, tanh, hard_tanh]) 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 81b9750b5..6ac1bc040 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 @@ -148,15 +148,15 @@ def generate_tp_model(default_config: OpQuantizationConfig, operator_set = [] fusing_patterns = [] - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV) - conv_depthwise = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE) - batchnorm = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM) - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) - linear = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED) + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV) + conv_depthwise = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV) + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE) + batchnorm = schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) + linear = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED) operator_set.extend([conv, conv_depthwise, conv_transpose, batchnorm, relu, relu6, hard_tanh, linear]) 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 76f739c90..965695dc3 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 @@ -146,52 +146,52 @@ def generate_tp_model(default_config: OpQuantizationConfig, quant_preserving = default_configuration_options.clone_and_edit(quantization_preserving=True) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_AVGPOOL, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STRIDED_SLICE, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONCATENATE, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MIN, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAX, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESIZE, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=quant_preserving)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FOLD, qc_options=quant_preserving)) - - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_L2NORM, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.AVGPOOL, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STRIDED_SLICE, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CONCATENATE, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MUL, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MIN, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAX, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESIZE, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=quant_preserving)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FOLD, qc_options=quant_preserving)) + + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.L2NORM, qc_options=default_configuration_options.clone_and_edit( fixed_zero_point=0, fixed_scale=1 / 128))) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LOG_SOFTMAX, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.LOG_SOFTMAX, qc_options=default_configuration_options.clone_and_edit( fixed_zero_point=127, fixed_scale=16 / 256))) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SOFTMAX, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SOFTMAX, qc_options=default_configuration_options.clone_and_edit( fixed_zero_point=-128, fixed_scale=1 / 256))) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID, + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID, qc_options=default_configuration_options.clone_and_edit_weight_attribute( weights_per_channel_threshold=False)) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH, + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH, qc_options=default_configuration_options.clone_and_edit( fixed_zero_point=-128, fixed_scale=1 / 256)) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=default_configuration_options.clone_and_edit_weight_attribute( weights_per_channel_threshold=False)) - squeeze = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, + squeeze = schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=default_configuration_options.clone_and_edit( quantization_preserving=True)) - conv2d = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV) - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - elu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ELU) - batch_norm = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - bias_add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD_BIAS) + conv2d = schema.OperatorsSet(name=schema.OperatorSetNames.CONV) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + elu = schema.OperatorsSet(name=schema.OperatorSetNames.ELU) + batch_norm = schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + bias_add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD_BIAS) kernel = schema.OperatorSetConcat(operators_set=[conv2d, fc]) activations_to_fuse = schema.OperatorSetConcat(operators_set=[relu, elu]) diff --git a/model_compression_toolkit/xquant/keras/keras_report_utils.py b/model_compression_toolkit/xquant/keras/keras_report_utils.py index 91576121d..f62401d7e 100644 --- a/model_compression_toolkit/xquant/keras/keras_report_utils.py +++ b/model_compression_toolkit/xquant/keras/keras_report_utils.py @@ -43,7 +43,7 @@ def __init__(self, report_dir: str): fw_info = DEFAULT_KERAS_INFO fw_impl = KerasImplementation() - # Set the default Target Platform Capabilities (TPC) for PyTorch. + # Set the default Target Platform Capabilities (TPC) for Keras. default_tpc = get_target_platform_capabilities(TENSORFLOW, DEFAULT_TP_MODEL) attach2pytorch = AttachTpcToKeras() target_platform_capabilities = attach2pytorch.attach(default_tpc) diff --git a/tests/common_tests/helpers/tpcs_for_tests/__init__.py b/tests/common_tests/helpers/tpcs_for_tests/__init__.py index e69de29bb..5397dea24 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/__init__.py +++ b/tests/common_tests/helpers/tpcs_for_tests/__init__.py @@ -0,0 +1,14 @@ +# Copyright 2025 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. +# ============================================================================== diff --git a/tests/common_tests/helpers/tpcs_for_tests/v1/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v1/tp_model.py index 457298d8c..fb9b3ff7d 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v1/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v1/tp_model.py @@ -170,52 +170,52 @@ def generate_tp_model(default_config: OpQuantizationConfig, no_quantization_config = (default_configuration_options.clone_and_edit(enable_activation_quantization=False) .clone_and_edit_weight_attribute(enable_weights_quantization=False)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration # options (useful for creating fusing patterns, for example): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend([conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, hard_swish, sigmoid, tanh, hard_tanh]) diff --git a/tests/common_tests/helpers/tpcs_for_tests/v1_lut/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v1_lut/tp_model.py index e8d47895d..14885e841 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v1_lut/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v1_lut/tp_model.py @@ -171,79 +171,79 @@ def generate_tp_model(default_config: OpQuantizationConfig, .clone_and_edit_weight_attribute(enable_weights_quantization=False)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, + schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration # options (useful for creating fusing patterns, for example): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, diff --git a/tests/common_tests/helpers/tpcs_for_tests/v1_pot/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v1_pot/tp_model.py index 8f05e43b0..c463f0d0f 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v1_pot/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v1_pot/tp_model.py @@ -167,79 +167,79 @@ def generate_tp_model(default_config: OpQuantizationConfig, .clone_and_edit_weight_attribute(enable_weights_quantization=False)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, + schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration # options (useful for creating fusing patterns, for example): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, diff --git a/tests/common_tests/helpers/tpcs_for_tests/v2/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v2/tp_model.py index e1167ca09..16c6c2381 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v2/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v2/tp_model.py @@ -175,56 +175,56 @@ def generate_tp_model(default_config: OpQuantizationConfig, no_quantization_config = (default_configuration_options.clone_and_edit(enable_activation_quantization=False) .clone_and_edit_weight_attribute(enable_weights_quantization=False)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration # options (useful for creating fusing patterns, for example): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, hard_swish, sigmoid, diff --git a/tests/common_tests/helpers/tpcs_for_tests/v2_lut/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v2_lut/tp_model.py index 18a2b57cf..4aa691d46 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v2_lut/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v2_lut/tp_model.py @@ -173,79 +173,79 @@ def generate_tp_model(default_config: OpQuantizationConfig, .clone_and_edit_weight_attribute(enable_weights_quantization=False)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, + schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration # options (useful for creating fusing patterns, for example): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, diff --git a/tests/common_tests/helpers/tpcs_for_tests/v3/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v3/tp_model.py index 0ed195a71..5f2932d98 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v3/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v3/tp_model.py @@ -198,63 +198,63 @@ def generate_tp_model(default_config: OpQuantizationConfig, enable_activation_quantization=False, supported_input_activation_n_bits=(8, 16)).clone_and_edit_weight_attribute(enable_weights_quantization=False) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STRIDED_SLICE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS,qc_options=no_quantization_config)) - - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STRIDED_SLICE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) + + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=const_configuration_options_inout16)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONCATENATE, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CONCATENATE, qc_options=const_configuration_options_inout16)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration options (useful for creating fusing patterns): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD, + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD, qc_options=const_configuration_options_inout16) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB, + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB, qc_options=const_configuration_options_inout16) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL, + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL, qc_options=const_configuration_options_inout16) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV, qc_options=const_configuration_options) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV, qc_options=const_configuration_options) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, hard_swish, sigmoid, diff --git a/tests/common_tests/helpers/tpcs_for_tests/v3_lut/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v3_lut/tp_model.py index 1aec545a9..c238f6002 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v3_lut/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v3_lut/tp_model.py @@ -197,86 +197,86 @@ def generate_tp_model(default_config: OpQuantizationConfig, supported_input_activation_n_bits=(8, 16)).clone_and_edit_weight_attribute(enable_weights_quantization=False) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=no_quantization_config)) + schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION, + schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) operator_set.append( - schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STRIDED_SLICE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, + schema.OperatorsSet(name=schema.OperatorSetNames.STRIDED_SLICE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=const_configuration_options_inout16)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONCATENATE, + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CONCATENATE, qc_options=const_configuration_options_inout16)) # Define operator sets that use mixed_precision_configuration_options: - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) # Define operations sets without quantization configuration options (useful for creating fusing patterns): - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD, + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD, qc_options=const_configuration_options_inout16) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB, + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB, qc_options=const_configuration_options_inout16) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL, + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL, qc_options=const_configuration_options_inout16) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV, qc_options=const_configuration_options) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) - hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV, qc_options=const_configuration_options) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) + hard_swish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, diff --git a/tests/common_tests/helpers/tpcs_for_tests/v4/tp_model.py b/tests/common_tests/helpers/tpcs_for_tests/v4/tp_model.py index 7ed46cecc..ec5dc46f3 100644 --- a/tests/common_tests/helpers/tpcs_for_tests/v4/tp_model.py +++ b/tests/common_tests/helpers/tpcs_for_tests/v4/tp_model.py @@ -223,70 +223,70 @@ def generate_tp_model(default_config: OpQuantizationConfig, no_quantization_config = (default_configuration_options.clone_and_edit(enable_activation_quantization=False) .clone_and_edit_weight_attribute(enable_weights_quantization=False)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIZE, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EQUAL, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ARGMAX, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TOPK, qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_COMBINED_NON_MAX_SUPPRESSION,qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FAKE_QUANT,qc_options=no_quantization_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SSD_POST_PROCESS, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SIZE, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.EQUAL, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ARGMAX, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TOPK, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.COMBINED_NON_MAX_SUPPRESSION, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FAKE_QUANT, qc_options=no_quantization_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SSD_POST_PROCESS, qc_options=no_quantization_config)) quant_preserving_config = (default_configuration_options.clone_and_edit(enable_activation_quantization=False, quantization_preserving=True) .clone_and_edit_weight_attribute(enable_weights_quantization=False)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSTACK, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DROPOUT, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SPLIT_CHUNK, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GET_ITEM, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAXPOOL, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PAD, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ZERO_PADDING2d, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CAST, qc_options=quant_preserving_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STRIDED_SLICE, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSTACK, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.DROPOUT, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SPLIT_CHUNK, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GET_ITEM, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAXPOOL, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PAD, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.ZERO_PADDING2D, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CAST, qc_options=quant_preserving_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STRIDED_SLICE, qc_options=quant_preserving_config)) dim_manipulation_config = (default_configuration_options.clone_and_edit(enable_activation_quantization=False, quantization_preserving=True, supported_input_activation_n_bits=(8, 16)) .clone_and_edit_weight_attribute(enable_weights_quantization=False)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FLATTEN, qc_options=dim_manipulation_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RESHAPE, qc_options=dim_manipulation_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_UNSQUEEZE, qc_options=dim_manipulation_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SQUEEZE, qc_options=dim_manipulation_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PERMUTE, qc_options=dim_manipulation_config)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TRANSPOSE, qc_options=dim_manipulation_config)) - - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GATHER, qc_options=qpreserving_const_config_options)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_EXPAND, qc_options=qpreserving_const_config_options)) - - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_STACK, qc_options=const_configuration_options_inout16_per_tensor)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONCATENATE, qc_options=const_configuration_options_inout16_per_tensor)) - - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_BATCH_NORM, qc_options=default_config_options_16bit)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MIN, qc_options=default_config_options_16bit)) - operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MAX, qc_options=default_config_options_16bit)) - - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, qc_options=mixed_precision_configuration_options) - conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) - depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) - - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU, qc_options=default_config_options_16bit) - relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU6, qc_options=default_config_options_16bit) - leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_LEAKY_RELU, qc_options=default_config_options_16bit) - prelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_PRELU, qc_options=default_config_options_16bit) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD, qc_options=const_configuration_options_inout16) - sub = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SUB, qc_options=const_configuration_options_inout16) - mul = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_MUL, qc_options=const_configuration_options_inout16) - div = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_DIV, qc_options=const_configuration_options) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH, qc_options=default_config_options_16bit) - hardswish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSWISH, qc_options=default_config_options_16bit) - sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SIGMOID, qc_options=default_config_options_16bit) - hardsigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARDSIGMOID, qc_options=default_config_options_16bit) - gelu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_GELU, qc_options=default_config_options_16bit) - tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_TANH, qc_options=default_config_options_16bit) - hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_HARD_TANH, qc_options=default_config_options_16bit) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.FLATTEN, qc_options=dim_manipulation_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.RESHAPE, qc_options=dim_manipulation_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.UNSQUEEZE, qc_options=dim_manipulation_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.SQUEEZE, qc_options=dim_manipulation_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.PERMUTE, qc_options=dim_manipulation_config)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.TRANSPOSE, qc_options=dim_manipulation_config)) + + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.GATHER, qc_options=qpreserving_const_config_options)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.EXPAND, qc_options=qpreserving_const_config_options)) + + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.STACK, qc_options=const_configuration_options_inout16_per_tensor)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.CONCATENATE, qc_options=const_configuration_options_inout16_per_tensor)) + + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.BATCH_NORM, qc_options=default_config_options_16bit)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MIN, qc_options=default_config_options_16bit)) + operator_set.append(schema.OperatorsSet(name=schema.OperatorSetNames.MAX, qc_options=default_config_options_16bit)) + + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) + conv_transpose = schema.OperatorsSet(name=schema.OperatorSetNames.CONV_TRANSPOSE, qc_options=mixed_precision_configuration_options) + depthwise_conv = schema.OperatorsSet(name=schema.OperatorSetNames.DEPTHWISE_CONV, qc_options=mixed_precision_configuration_options) + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) + + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU, qc_options=default_config_options_16bit) + relu6 = schema.OperatorsSet(name=schema.OperatorSetNames.RELU6, qc_options=default_config_options_16bit) + leaky_relu = schema.OperatorsSet(name=schema.OperatorSetNames.LEAKY_RELU, qc_options=default_config_options_16bit) + prelu = schema.OperatorsSet(name=schema.OperatorSetNames.PRELU, qc_options=default_config_options_16bit) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD, qc_options=const_configuration_options_inout16) + sub = schema.OperatorsSet(name=schema.OperatorSetNames.SUB, qc_options=const_configuration_options_inout16) + mul = schema.OperatorsSet(name=schema.OperatorSetNames.MUL, qc_options=const_configuration_options_inout16) + div = schema.OperatorsSet(name=schema.OperatorSetNames.DIV, qc_options=const_configuration_options) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH, qc_options=default_config_options_16bit) + hardswish = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSWISH, qc_options=default_config_options_16bit) + sigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.SIGMOID, qc_options=default_config_options_16bit) + hardsigmoid = schema.OperatorsSet(name=schema.OperatorSetNames.HARDSIGMOID, qc_options=default_config_options_16bit) + gelu = schema.OperatorsSet(name=schema.OperatorSetNames.GELU, qc_options=default_config_options_16bit) + tanh = schema.OperatorsSet(name=schema.OperatorSetNames.TANH, qc_options=default_config_options_16bit) + hard_tanh = schema.OperatorsSet(name=schema.OperatorSetNames.HARD_TANH, qc_options=default_config_options_16bit) operator_set.extend( [conv, conv_transpose, depthwise_conv, fc, relu, relu6, leaky_relu, add, sub, mul, div, prelu, swish, hardswish, sigmoid, diff --git a/tests/keras_tests/feature_networks_tests/feature_networks/activation_16bit_test.py b/tests/keras_tests/feature_networks_tests/feature_networks/activation_16bit_test.py index 56d845729..1e9a44c8c 100644 --- a/tests/keras_tests/feature_networks_tests/feature_networks/activation_16bit_test.py +++ b/tests/keras_tests/feature_networks_tests/feature_networks/activation_16bit_test.py @@ -41,7 +41,7 @@ class Activation16BitTest(BaseKerasFeatureNetworkTest): def get_tpc(self): tpc = get_tp_model() base_cfg_16 = [c for c in get_config_options_by_operators_set(tpc, - OperatorSetNames.OPSET_MUL).quantization_configurations + OperatorSetNames.MUL).quantization_configurations if c.activation_n_bits == 16][0].clone_and_edit() qco_16 = QuantizationConfigOptions(base_config=base_cfg_16, quantization_configurations=(tpc.default_qco.base_config, @@ -51,7 +51,7 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, + OperatorSetNames.MUL: qco_16, }) return tpc @@ -85,7 +85,7 @@ class Activation16BitMixedPrecisionTest(Activation16BitTest): def get_tpc(self): tpc = get_tp_model() - mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.OPSET_MUL) + mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.MUL) base_cfg_16 = [l for l in mul_qco.quantization_configurations if l.activation_n_bits == 16][0] quantization_configurations = list(mul_qco.quantization_configurations) quantization_configurations.extend([ @@ -100,7 +100,7 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, + OperatorSetNames.MUL: qco_16, }) return tpc 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 90f8eaa56..128fa0a9d 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 @@ -54,12 +54,12 @@ def create_const_quant_tpc(qmethod): const_merge_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple([const_merge_config])) operator_sets_dict = {} - operator_sets_dict[schema.OperatorSetNames.OPSET_ADD] = const_configuration_options - operator_sets_dict[schema.OperatorSetNames.OPSET_SUB] = const_configuration_options - operator_sets_dict[schema.OperatorSetNames.OPSET_MUL] = const_configuration_options - operator_sets_dict[schema.OperatorSetNames.OPSET_DIV] = const_configuration_options - operator_sets_dict[schema.OperatorSetNames.OPSET_STACK] = const_merge_configuration_options - operator_sets_dict[schema.OperatorSetNames.OPSET_CONCATENATE] = const_merge_configuration_options + operator_sets_dict[schema.OperatorSetNames.ADD] = const_configuration_options + operator_sets_dict[schema.OperatorSetNames.SUB] = const_configuration_options + operator_sets_dict[schema.OperatorSetNames.MUL] = const_configuration_options + operator_sets_dict[schema.OperatorSetNames.DIV] = const_configuration_options + operator_sets_dict[schema.OperatorSetNames.STACK] = const_merge_configuration_options + operator_sets_dict[schema.OperatorSetNames.CONCATENATE] = const_merge_configuration_options tp_model = generate_custom_test_tp_model(name=name, base_cfg=base_cfg, 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 e33255f72..f6ea7edf6 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 @@ -137,7 +137,7 @@ class Manual16BitWidthSelectionTest(ManualBitWidthSelectionTest): def get_tpc(self): tpc = get_tp_model() base_cfg_16 = [c for c in get_config_options_by_operators_set(tpc, - OperatorSetNames.OPSET_MUL).quantization_configurations + OperatorSetNames.MUL).quantization_configurations if c.activation_n_bits == 16][0].clone_and_edit() qco_16 = QuantizationConfigOptions(base_config=base_cfg_16, quantization_configurations=(tpc.default_qco.base_config, @@ -147,9 +147,9 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, - OperatorSetNames.OPSET_GELU: qco_16, - OperatorSetNames.OPSET_TANH: qco_16, + OperatorSetNames.MUL: qco_16, + OperatorSetNames.GELU: qco_16, + OperatorSetNames.TANH: qco_16, }) return tpc @@ -175,7 +175,7 @@ class Manual16BitWidthSelectionMixedPrecisionTest(Manual16BitWidthSelectionTest) def get_tpc(self): tpc = get_tp_model() - mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.OPSET_MUL) + mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.MUL) base_cfg_16 = [l for l in mul_qco.quantization_configurations if l.activation_n_bits == 16][0] quantization_configurations = list(mul_qco.quantization_configurations) quantization_configurations.extend([ @@ -190,7 +190,7 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, + OperatorSetNames.MUL: qco_16, }) return tpc 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 b02e0ce89..669111b09 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 @@ -613,7 +613,7 @@ def get_tpc(self): default_config=default_config, mp_bitwidth_candidates_list=mixed_precision_candidates_list, name="mixed_precision_activation_test", - custom_opsets={schema.OperatorSetNames.OPSET_SIGMOID: + custom_opsets={schema.OperatorSetNames.SIGMOID: mixed_precision_candidates_list}) def create_networks(self): diff --git a/tests/keras_tests/function_tests/test_quant_config_filtering.py b/tests/keras_tests/function_tests/test_quant_config_filtering.py index 4b7dc155c..281009a4c 100644 --- a/tests/keras_tests/function_tests/test_quant_config_filtering.py +++ b/tests/keras_tests/function_tests/test_quant_config_filtering.py @@ -42,7 +42,7 @@ class TestKerasQuantConfigFiltering(unittest.TestCase): def get_tpc_default_16bit(): tpc = get_tp_model() base_cfg_16 = [c for c in get_config_options_by_operators_set(tpc, - OperatorSetNames.OPSET_MUL).quantization_configurations + OperatorSetNames.MUL).quantization_configurations if c.activation_n_bits == 16][0].clone_and_edit() qco_16 = QuantizationConfigOptions(base_config=base_cfg_16, quantization_configurations=(tpc.default_qco.base_config, @@ -52,9 +52,9 @@ def get_tpc_default_16bit(): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, - OperatorSetNames.OPSET_GELU: qco_16, - OperatorSetNames.OPSET_TANH: qco_16, + OperatorSetNames.MUL: qco_16, + OperatorSetNames.GELU: qco_16, + OperatorSetNames.TANH: qco_16, }) return tpc diff --git a/tests/pytorch_tests/function_tests/layer_fusing_test.py b/tests/pytorch_tests/function_tests/layer_fusing_test.py index c36413779..b8d637660 100644 --- a/tests/pytorch_tests/function_tests/layer_fusing_test.py +++ b/tests/pytorch_tests/function_tests/layer_fusing_test.py @@ -241,11 +241,11 @@ def get_tpc(self): mixed_precision_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple(mixed_precision_cfg_list), base_config=base_config) default_configuration_options = schema.QuantizationConfigOptions(quantization_configurations=tuple([default_config])) - conv = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_CONV, qc_options=mixed_precision_configuration_options) - fc = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) - relu = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_RELU) - add = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_ADD) - swish = schema.OperatorsSet(name=schema.OperatorSetNames.OPSET_SWISH) + conv = schema.OperatorsSet(name=schema.OperatorSetNames.CONV, qc_options=mixed_precision_configuration_options) + fc = schema.OperatorsSet(name=schema.OperatorSetNames.FULLY_CONNECTED, qc_options=mixed_precision_configuration_options) + relu = schema.OperatorsSet(name=schema.OperatorSetNames.RELU) + add = schema.OperatorsSet(name=schema.OperatorSetNames.ADD) + swish = schema.OperatorsSet(name=schema.OperatorSetNames.SWISH) operator_set = [conv, fc, relu, add, swish] activations_to_fuse = schema.OperatorSetConcat(operators_set=[relu, swish]) # Define fusions diff --git a/tests/pytorch_tests/function_tests/test_quant_config_filtering.py b/tests/pytorch_tests/function_tests/test_quant_config_filtering.py index b7d81230a..870b4818e 100644 --- a/tests/pytorch_tests/function_tests/test_quant_config_filtering.py +++ b/tests/pytorch_tests/function_tests/test_quant_config_filtering.py @@ -36,7 +36,7 @@ class TestTorchQuantConfigFiltering(unittest.TestCase): def get_tpc_default_16bit(): tpc = get_tp_model() base_cfg_16 = [c for c in get_config_options_by_operators_set(tpc, - OperatorSetNames.OPSET_MUL).quantization_configurations + OperatorSetNames.MUL).quantization_configurations if c.activation_n_bits == 16][0].clone_and_edit() qco_16 = QuantizationConfigOptions(base_config=base_cfg_16, quantization_configurations=(tpc.default_qco.base_config, @@ -46,9 +46,9 @@ def get_tpc_default_16bit(): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, - OperatorSetNames.OPSET_GELU: qco_16, - OperatorSetNames.OPSET_TANH: qco_16, + OperatorSetNames.MUL: qco_16, + OperatorSetNames.GELU: qco_16, + OperatorSetNames.TANH: qco_16, }) return tpc diff --git a/tests/pytorch_tests/model_tests/feature_models/activation_16bit_test.py b/tests/pytorch_tests/model_tests/feature_models/activation_16bit_test.py index 2c7b97db0..5484b8316 100644 --- a/tests/pytorch_tests/model_tests/feature_models/activation_16bit_test.py +++ b/tests/pytorch_tests/model_tests/feature_models/activation_16bit_test.py @@ -92,7 +92,7 @@ class Activation16BitTest(BasePytorchFeatureNetworkTest): def get_tpc(self): tpc = get_tp_model() - base_cfg_16 = [c for c in get_config_options_by_operators_set(tpc, OperatorSetNames.OPSET_MUL).quantization_configurations + base_cfg_16 = [c for c in get_config_options_by_operators_set(tpc, OperatorSetNames.MUL).quantization_configurations if c.activation_n_bits == 16][0].clone_and_edit() qco_16 = QuantizationConfigOptions(base_config=base_cfg_16, quantization_configurations=(tpc.default_qco.base_config, @@ -102,9 +102,9 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, - OperatorSetNames.OPSET_GELU: qco_16, - OperatorSetNames.OPSET_TANH: qco_16, + OperatorSetNames.MUL: qco_16, + OperatorSetNames.GELU: qco_16, + OperatorSetNames.TANH: qco_16, }) return tpc @@ -137,7 +137,7 @@ class Activation16BitMixedPrecisionTest(Activation16BitTest): def get_tpc(self): tpc = get_tp_model() - mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.OPSET_MUL) + mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.MUL) base_cfg_16 = [l for l in mul_qco.quantization_configurations if l.activation_n_bits == 16][0] quantization_configurations = list(mul_qco.quantization_configurations) quantization_configurations.extend([ @@ -152,7 +152,7 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, + OperatorSetNames.MUL: qco_16, }) return tpc 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 e3b630a1c..7b29b242a 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 @@ -201,7 +201,7 @@ class Manual16BitTest(ManualBitWidthByLayerNameTest): def get_tpc(self): tpc = get_tp_model() - mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.OPSET_MUL) + mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.MUL) base_cfg_16 = [l for l in mul_qco.quantization_configurations if l.activation_n_bits == 16][0] quantization_configurations = list(mul_qco.quantization_configurations) @@ -213,7 +213,7 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, + OperatorSetNames.MUL: qco_16, }) return {'manual_bit_selection': tpc} @@ -227,7 +227,7 @@ class Manual16BitTestMixedPrecisionTest(ManualBitWidthByLayerNameTest): def get_tpc(self): tpc = get_tp_model() - mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.OPSET_MUL) + mul_qco = get_config_options_by_operators_set(tpc, OperatorSetNames.MUL) base_cfg_16 = [l for l in mul_qco.quantization_configurations if l.activation_n_bits == 16][0] quantization_configurations = list(mul_qco.quantization_configurations) quantization_configurations.extend([ @@ -242,7 +242,7 @@ def get_tpc(self): base_cfg=tpc.default_qco.base_config, base_tp_model=tpc, operator_sets_dict={ - OperatorSetNames.OPSET_MUL: qco_16, + OperatorSetNames.MUL: qco_16, }) return {'manual_bit_selection': tpc}