diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/default/algorithm.py b/tools/pot/openvino/tools/pot/algorithms/quantization/default/algorithm.py index aca46cd19f4..a269c0984ff 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/default/algorithm.py +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/default/algorithm.py @@ -13,6 +13,7 @@ from ...algorithm_selector import COMPRESSION_ALGORITHMS from ....samplers.creator import create_sampler from ....statistics.collector import StatisticsCollector from ....utils.logger import get_logger +from ....configs.config import GNA_DEVICES # pylint: disable=W0611 try: @@ -40,7 +41,7 @@ class DefaultQuantization(Algorithm): use_fast_bias = self._config.get('use_fast_bias', True) self._enable_tuning = self._config.get('use_layerwise_tuning', False) bias_algo = FastBiasCorrection(config, engine) if use_fast_bias else BiasCorrection(config, engine) - is_overflow_correction_need = self._config.get('target_device') == 'GNA' + is_overflow_correction_need = self._config.get('target_device') in GNA_DEVICES self.algorithms = [ActivationChannelAlignment(config, engine), MinMaxQuantization(config, engine), bias_algo] diff --git a/tools/pot/openvino/tools/pot/configs/config.py b/tools/pot/openvino/tools/pot/configs/config.py index cc157956f3c..9c55cbd8e49 100644 --- a/tools/pot/openvino/tools/pot/configs/config.py +++ b/tools/pot/openvino/tools/pot/configs/config.py @@ -19,6 +19,8 @@ MO_PATH = Path(openvino.tools.mo.__file__).parent.parent DEFAULT_TARGET_DEVICE = 'ANY' DEFAULT_PRESET = 'performance' +GNA_DEVICES = ['GNA', 'GNA3', 'GNA3.5'] + # pylint: disable=W0212 class Config(Dict): @@ -347,6 +349,8 @@ class Config(Dict): presets_aliases_by_device = { 'VPU': {'accuracy': 'accuracy'}, 'GNA': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, + 'GNA3': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, + 'GNA3.5': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, 'CPU': {'accuracy': 'mixed'}, 'ANY': {'accuracy': 'mixed'}, 'GPU': {'accuracy': 'mixed'}, diff --git a/tools/pot/openvino/tools/pot/configs/hardware/gna3.json b/tools/pot/openvino/tools/pot/configs/hardware/gna3.json index 29aea2f1647..d0579528752 100644 --- a/tools/pot/openvino/tools/pot/configs/hardware/gna3.json +++ b/tools/pot/openvino/tools/pot/configs/hardware/gna3.json @@ -24,13 +24,20 @@ "level_low": -127, "level_high": 127 }, - "q8_w": { + "q8_w_ch": { "bits": 8, "mode": "symmetric", "granularity": "perchannel", "level_low": -127, "level_high": 127 }, + "q8_w": { + "bits": 8, + "mode": "symmetric", + "granularity": "pertensor", + "level_low": -127, + "level_high": 127 + }, "q16_w": { "bits": 16, "mode": "symmetric", @@ -58,7 +65,7 @@ { "type": "Convolution", "quantization": { - "activations": ["q8_a", "q16_a"], + "activations": ["q16_a"], "weights": ["q8_w", "q16_w"], "outputs": "q32_o" } @@ -67,7 +74,7 @@ "type": "MatMul", "quantization": { "activations": "q16_a", - "weights": ["q8_w", "q16_w"], + "weights": ["q8_w_ch", "q16_w"], "outputs": "q32_o" } }, @@ -91,7 +98,7 @@ "type": "Multiply", "quantization": { "activations": "q16_a", - "weights": ["q8_w", "q16_w"], + "weights": ["q8_w_ch", "q16_w"], "outputs": "q32_o" } }, diff --git a/tools/pot/openvino/tools/pot/graph/graph_utils.py b/tools/pot/openvino/tools/pot/graph/graph_utils.py index f93cd03f87d..8229850b0f2 100644 --- a/tools/pot/openvino/tools/pot/graph/graph_utils.py +++ b/tools/pot/openvino/tools/pot/graph/graph_utils.py @@ -14,6 +14,7 @@ from openvino.offline_transformations import apply_pot_transformations # pylint: from ..graph.passes import ModelPreprocessor, remove_converts, add_removed_converts from ..utils.logger import stdout_redirect +from ..configs.config import GNA_DEVICES init_logger('ERROR', False) core = Core() @@ -24,13 +25,12 @@ def load_graph(model_config, target_device='ANY'): """ Loads model from specified path :return NetworkX model """ - special_transform_devices = ['GNA', 'GNA3.5'] serialized_bin_path = os.path.join(tempfile.gettempdir(), 'serialized_ir.bin') serialized_xml_path = os.path.join(tempfile.gettempdir(), 'serialized_ir.xml') bin_path = model_config.weights xml_path = model_config.model - if target_device in special_transform_devices: + if target_device in GNA_DEVICES: model = core.read_model(model=xml_path, weights=bin_path) apply_pot_transformations(model, target_device.encode('utf-8')) bin_path = serialized_bin_path diff --git a/tools/pot/openvino/tools/pot/graph/utils.py b/tools/pot/openvino/tools/pot/graph/utils.py index 326e5aa522c..a1dc38b4e9e 100644 --- a/tools/pot/openvino/tools/pot/graph/utils.py +++ b/tools/pot/openvino/tools/pot/graph/utils.py @@ -21,6 +21,7 @@ HARDWARE_AWARE_IGNORED_PATTERNS = { 'VPU': get_vpu_ignored_patterns(), 'GNA': get_gna_ignored_patterns(), 'GNA3': get_gna3_ignored_patterns(), + 'GNA3.5': get_gna3_ignored_patterns(), 'CPU_SPR': get_cpu_ignored_patterns() }