From 390ca9f45f6532bd34b817ccbade883ef5622cfe Mon Sep 17 00:00:00 2001 From: Nikita Malinin Date: Thu, 10 Mar 2022 11:05:32 +0300 Subject: [PATCH] [POT] Update BC with the Parameter nodes connection 22.1 (#10852) * Update BC with the Parameter nodes connection * Update test_sanity with octave --- .../quantization/bias_correction/algorithm.py | 12 ++++++++---- tools/pot/tests/test_sanity.py | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tools/pot/openvino/tools/pot/algorithms/quantization/bias_correction/algorithm.py b/tools/pot/openvino/tools/pot/algorithms/quantization/bias_correction/algorithm.py index 4929d842224..7627c401c87 100644 --- a/tools/pot/openvino/tools/pot/algorithms/quantization/bias_correction/algorithm.py +++ b/tools/pot/openvino/tools/pot/algorithms/quantization/bias_correction/algorithm.py @@ -260,6 +260,7 @@ class BiasCorrection(Algorithm): outputs_shapes = {nu.create_node_name(n): nu.get_output_shape(n, 0).copy() for n in input_nodes} inputs_data = [] param_type = 'Parameter' + nodes_data = [] for input_node in input_nodes: input_node_name = nu.create_node_name(input_node) c_input_shape = outputs_shapes[input_node_name] @@ -271,16 +272,19 @@ class BiasCorrection(Algorithm): parameter_name = input_node_name + '/parameter' param_node = ge.create_node(input_node.graph, parameter_name, param_type, {'shape': c_input_shape, 'data_type': input_node_data_type}) - for _, port in input_node.out_ports().items(): - for in_port in port.get_destinations(): - in_port.disconnect() - in_port.connect(param_node.out_port(0)) + nodes_data.append((input_node, param_node)) inputs_data.append({ 'param_name': parameter_name, 'param_shape': tuple(c_input_shape), 'input_name': input_node_name }) + for input_node, param_node in nodes_data: + for _, port in input_node.out_ports().items(): + for in_port in port.get_destinations(): + in_port.disconnect() + in_port.connect(param_node.out_port(0)) + return inputs_data def _create_results_after_nodes(self, output_nodes): diff --git a/tools/pot/tests/test_sanity.py b/tools/pot/tests/test_sanity.py index 55569c77860..7eca8ad819d 100644 --- a/tools/pot/tests/test_sanity.py +++ b/tools/pot/tests/test_sanity.py @@ -54,7 +54,9 @@ TEST_MODELS = [ ('mtcnn', 'caffe', 'DefaultQuantization', 'performance', 1, {'recall': 0.76, 'map': 0.6844}, {}, 'CPU'), ('mtcnn', 'caffe', 'DefaultQuantization', 'performance', 2, {'recall': 0.76, 'map': 0.6638}, - {'use_fast_bias': False}, 'CPU') + {'use_fast_bias': False}, 'CPU'), + ('octave-resnet-26-0.25', 'mxnet', 'DefaultQuantization', 'performance', 300, + {'accuracy@top1': 0.766, 'accuracy@top5': 0.927}, {'use_fast_bias': False}, 'CPU'), ] CASCADE_MAP = Dict({ 'mtcnn': {