[POT] Update GNA3-3.5 configs & passes (#14429)

* Update gna3.json

* Update GNA-related transformations

* Added all GNA devices into one list

Co-authored-by: Alexander Kozlov <alexander.kozlov@intel.com>
This commit is contained in:
Nikita Malinin 2022-12-06 17:25:29 +01:00 committed by GitHub
parent f5e6816633
commit 4171f258b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 7 deletions

View File

@ -13,6 +13,7 @@ from ...algorithm_selector import COMPRESSION_ALGORITHMS
from ....samplers.creator import create_sampler from ....samplers.creator import create_sampler
from ....statistics.collector import StatisticsCollector from ....statistics.collector import StatisticsCollector
from ....utils.logger import get_logger from ....utils.logger import get_logger
from ....configs.config import GNA_DEVICES
# pylint: disable=W0611 # pylint: disable=W0611
try: try:
@ -40,7 +41,7 @@ class DefaultQuantization(Algorithm):
use_fast_bias = self._config.get('use_fast_bias', True) use_fast_bias = self._config.get('use_fast_bias', True)
self._enable_tuning = self._config.get('use_layerwise_tuning', False) self._enable_tuning = self._config.get('use_layerwise_tuning', False)
bias_algo = FastBiasCorrection(config, engine) if use_fast_bias else BiasCorrection(config, engine) 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), self.algorithms = [ActivationChannelAlignment(config, engine),
MinMaxQuantization(config, engine), MinMaxQuantization(config, engine),
bias_algo] bias_algo]

View File

@ -19,6 +19,8 @@ MO_PATH = Path(openvino.tools.mo.__file__).parent.parent
DEFAULT_TARGET_DEVICE = 'ANY' DEFAULT_TARGET_DEVICE = 'ANY'
DEFAULT_PRESET = 'performance' DEFAULT_PRESET = 'performance'
GNA_DEVICES = ['GNA', 'GNA3', 'GNA3.5']
# pylint: disable=W0212 # pylint: disable=W0212
class Config(Dict): class Config(Dict):
@ -347,6 +349,8 @@ class Config(Dict):
presets_aliases_by_device = { presets_aliases_by_device = {
'VPU': {'accuracy': 'accuracy'}, 'VPU': {'accuracy': 'accuracy'},
'GNA': {'accuracy': 'accuracy', 'mixed': 'accuracy'}, 'GNA': {'accuracy': 'accuracy', 'mixed': 'accuracy'},
'GNA3': {'accuracy': 'accuracy', 'mixed': 'accuracy'},
'GNA3.5': {'accuracy': 'accuracy', 'mixed': 'accuracy'},
'CPU': {'accuracy': 'mixed'}, 'CPU': {'accuracy': 'mixed'},
'ANY': {'accuracy': 'mixed'}, 'ANY': {'accuracy': 'mixed'},
'GPU': {'accuracy': 'mixed'}, 'GPU': {'accuracy': 'mixed'},

View File

@ -24,13 +24,20 @@
"level_low": -127, "level_low": -127,
"level_high": 127 "level_high": 127
}, },
"q8_w": { "q8_w_ch": {
"bits": 8, "bits": 8,
"mode": "symmetric", "mode": "symmetric",
"granularity": "perchannel", "granularity": "perchannel",
"level_low": -127, "level_low": -127,
"level_high": 127 "level_high": 127
}, },
"q8_w": {
"bits": 8,
"mode": "symmetric",
"granularity": "pertensor",
"level_low": -127,
"level_high": 127
},
"q16_w": { "q16_w": {
"bits": 16, "bits": 16,
"mode": "symmetric", "mode": "symmetric",
@ -58,7 +65,7 @@
{ {
"type": "Convolution", "type": "Convolution",
"quantization": { "quantization": {
"activations": ["q8_a", "q16_a"], "activations": ["q16_a"],
"weights": ["q8_w", "q16_w"], "weights": ["q8_w", "q16_w"],
"outputs": "q32_o" "outputs": "q32_o"
} }
@ -67,7 +74,7 @@
"type": "MatMul", "type": "MatMul",
"quantization": { "quantization": {
"activations": "q16_a", "activations": "q16_a",
"weights": ["q8_w", "q16_w"], "weights": ["q8_w_ch", "q16_w"],
"outputs": "q32_o" "outputs": "q32_o"
} }
}, },
@ -91,7 +98,7 @@
"type": "Multiply", "type": "Multiply",
"quantization": { "quantization": {
"activations": "q16_a", "activations": "q16_a",
"weights": ["q8_w", "q16_w"], "weights": ["q8_w_ch", "q16_w"],
"outputs": "q32_o" "outputs": "q32_o"
} }
}, },

View File

@ -14,6 +14,7 @@ from openvino.offline_transformations import apply_pot_transformations # pylint:
from ..graph.passes import ModelPreprocessor, remove_converts, add_removed_converts from ..graph.passes import ModelPreprocessor, remove_converts, add_removed_converts
from ..utils.logger import stdout_redirect from ..utils.logger import stdout_redirect
from ..configs.config import GNA_DEVICES
init_logger('ERROR', False) init_logger('ERROR', False)
core = Core() core = Core()
@ -24,13 +25,12 @@ def load_graph(model_config, target_device='ANY'):
""" Loads model from specified path """ Loads model from specified path
:return NetworkX model :return NetworkX model
""" """
special_transform_devices = ['GNA', 'GNA3.5']
serialized_bin_path = os.path.join(tempfile.gettempdir(), 'serialized_ir.bin') serialized_bin_path = os.path.join(tempfile.gettempdir(), 'serialized_ir.bin')
serialized_xml_path = os.path.join(tempfile.gettempdir(), 'serialized_ir.xml') serialized_xml_path = os.path.join(tempfile.gettempdir(), 'serialized_ir.xml')
bin_path = model_config.weights bin_path = model_config.weights
xml_path = model_config.model 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) model = core.read_model(model=xml_path, weights=bin_path)
apply_pot_transformations(model, target_device.encode('utf-8')) apply_pot_transformations(model, target_device.encode('utf-8'))
bin_path = serialized_bin_path bin_path = serialized_bin_path

View File

@ -21,6 +21,7 @@ HARDWARE_AWARE_IGNORED_PATTERNS = {
'VPU': get_vpu_ignored_patterns(), 'VPU': get_vpu_ignored_patterns(),
'GNA': get_gna_ignored_patterns(), 'GNA': get_gna_ignored_patterns(),
'GNA3': get_gna3_ignored_patterns(), 'GNA3': get_gna3_ignored_patterns(),
'GNA3.5': get_gna3_ignored_patterns(),
'CPU_SPR': get_cpu_ignored_patterns() 'CPU_SPR': get_cpu_ignored_patterns()
} }