From 4a3626997df628b17148f3e5ee6f32b0525562dd Mon Sep 17 00:00:00 2001 From: Edward Shogulin Date: Tue, 17 Aug 2021 07:04:51 +0100 Subject: [PATCH] [LPT] optimizeMultiplierAfter refactorinig & Reshape fix (#7036) * [LPT] ReshapeTransformation: 2D->2D fix * [LPT] optimizeMultiplierAfter refactorinig & Reshape fix Co-authored-by: Vladislav Golubev --- .../src/network_helper.cpp | 11 ++++- .../src/reshape.cpp | 37 ++++++++++------ ...quantization_parameters_transformation.cpp | 2 +- .../avg_pool_with_child_transformation.cpp | 2 +- .../concat_with_neighbors_transformation.cpp | 4 +- ...nvolution_backprop_data_transformation.cpp | 20 ++++----- .../convolution_qdq_transformation.cpp | 8 ++-- .../convolution_transformation.cpp | 14 +++--- .../convolution_with_incorrect_weights.cpp | 2 +- ...d_two_output_branches_with_convolution.cpp | 8 ++-- ...ize_with_dq_not_optimal_transformation.cpp | 2 +- .../group_convolution_transformation.cpp | 20 ++++----- .../reshape_transformation.cpp | 44 +++++++++++++++++++ ..._quantize_precision_selection_function.cpp | 2 +- 14 files changed, 118 insertions(+), 58 deletions(-) diff --git a/inference-engine/src/low_precision_transformations/src/network_helper.cpp b/inference-engine/src/low_precision_transformations/src/network_helper.cpp index 47b624236b0..9a1faa02b8d 100644 --- a/inference-engine/src/low_precision_transformations/src/network_helper.cpp +++ b/inference-engine/src/low_precision_transformations/src/network_helper.cpp @@ -463,7 +463,14 @@ std::shared_ptr NetworkHelper::optimizeMultipliesAfter } auto newInput = multiply->input_value(1 - constant1->output(0).get_target_inputs().begin()->get_index()); - auto newConst = fold(constant1, constant2); + auto multiplyResult = fold(constant1, constant2); + { + // optimize constant shape: used in rfcn-resnet101-coco + const auto multiplyResultConstant = as_type_ptr(multiplyResult); + if ((multiplyResultConstant != nullptr) && NetworkHelper::isScalarLike(multiplyResultConstant)) { + multiplyResult = NetworkHelper::toScalar(multiplyResultConstant); + } + } auto inputPrecision0 = nextMultiply->get_origin_input_type(0); auto inputPrecision1 = nextMultiply->get_origin_input_type(1); auto outputPrecision = nextMultiply->get_overridden_output_type(0); @@ -472,7 +479,7 @@ std::shared_ptr NetworkHelper::optimizeMultipliesAfter std::vector{ inputPrecision0, inputPrecision1 }, std::vector{ outputPrecision }, ngraph::op::TemporaryReplaceOutputType(newInput, inputPrecision0).get(), - ngraph::op::TemporaryReplaceOutputType(newConst, inputPrecision1).get()); + ngraph::op::TemporaryReplaceOutputType(multiplyResult, inputPrecision1).get()); copy_runtime_info(multiply, newMultiply); replace_node(nextMultiply, newMultiply); return newMultiply; diff --git a/inference-engine/src/low_precision_transformations/src/reshape.cpp b/inference-engine/src/low_precision_transformations/src/reshape.cpp index b94e62320e4..e8263bd7528 100644 --- a/inference-engine/src/low_precision_transformations/src/reshape.cpp +++ b/inference-engine/src/low_precision_transformations/src/reshape.cpp @@ -47,7 +47,7 @@ void reshapeDequantizationConstant(const std::shared_ptr& resha auto replaceConstant = [](const std::shared_ptr& reshape, const std::shared_ptr& originalConstant) { // reshape for element-wise constant is not required auto constantShape = originalConstant->get_shape(); - if (shape_size(constantShape) == 1ul) { + if (NetworkHelper::isScalarLike(originalConstant)) { if (!constantShape.empty()) { const auto newConstant = NetworkHelper::toScalar(originalConstant); replace_node(originalConstant, newConstant); @@ -75,19 +75,28 @@ void reshapeDequantizationConstant(const std::shared_ptr& resha return; } - Shape newOperationConstantBroadcastedShape = originalConstant->output(0).get_shape(); - // add dimensions to broadcast values - if (newOperationConstantBroadcastedShape.size() == 2ul) { - newOperationConstantBroadcastedShape.push_back(dimensionsToBroadcast); - } else { - newOperationConstantBroadcastedShape[2] = dimensionsToBroadcast; - } - const std::shared_ptr broadcastedConstant = fold( - originalConstant, - std::make_shared( + auto getBCastedConst = [](const std::shared_ptr& constant, size_t dimensionsToBroadcast) -> std::shared_ptr { + if (dimensionsToBroadcast == 1ul) { + return constant; + } + + Shape newOperationConstantBroadcastedShape = constant->get_shape(); + // add dimensions to broadcast values + if (newOperationConstantBroadcastedShape.size() == 2ul) { + newOperationConstantBroadcastedShape.push_back(dimensionsToBroadcast); + } else { + newOperationConstantBroadcastedShape[2] = dimensionsToBroadcast; + } + + const auto targetShapeConstant = opset1::Constant::create( element::i32, - Shape({ newOperationConstantBroadcastedShape.size() }), - newOperationConstantBroadcastedShape)); + Shape{ newOperationConstantBroadcastedShape.size() }, + newOperationConstantBroadcastedShape); + + return fold(constant, targetShapeConstant); + }; + + const std::shared_ptr broadcastedConstant = getBCastedConst(originalConstant, dimensionsToBroadcast); std::vector newReshapeConstValues(reshapeOutputRank.get_length(), 1ul); newReshapeConstValues[1] = reshapeOutputPShape[1].get_length(); @@ -190,7 +199,7 @@ bool ReshapeTransformation::canBeTransformed(const TransformationContext& contex subtractShapeWithBatch.insert(subtractShapeWithBatch.begin(), 1ul); } - const Shape multiplyShape = dequantization.multiply == nullptr ? Shape{} : dequantization.multiply->input(1).get_shape(); + const Shape multiplyShape = dequantization.multiply == nullptr ? Shape{} : dequantization.multiplyConstant->get_shape(); Shape multiplyShapeWithBatch = multiplyShape; if ((dequantization.multiply != nullptr) && (multiplyShapeWithBatch.size() > 1ul) && diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/align_concat_quantization_parameters_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/align_concat_quantization_parameters_transformation.cpp index 5264e458669..30a6d84eb68 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/align_concat_quantization_parameters_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/align_concat_quantization_parameters_transformation.cpp @@ -162,7 +162,7 @@ const std::vector tes ngraph::element::f32, {{}, {std::vector(6, 128.f), element::f32, {1, 6, 1, 1}}, {}}, ngraph::element::f32, - {{}, {}, {std::vector(9, 0.0001f), element::f32, {1, 9, 1, 1}}} + {{}, {}, {{0.0001f}, element::f32, {}}} } } }; diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_with_child_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_with_child_transformation.cpp index aa2c591eeb3..0de23c8081c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_with_child_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_with_child_transformation.cpp @@ -137,7 +137,7 @@ const std::vector testValues = { {}, ngraph::element::u8, {}, - {{}, {}, {std::vector{0.0002f}, element::f32, {1, 6, 1, 1}}} + {{}, {}, {std::vector{0.0002f}, element::f32, {}}} } }, // U8 per tensor quantization diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp index 1dacc2f7eb7..3ecbcd116bb 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_neighbors_transformation.cpp @@ -343,11 +343,11 @@ const std::vector testValues = { { {}, {{ 128.f, 128.f, 128.f, 128.f, 128.f, 128.f }, ngraph::element::f32, { 1, 6, 1, 1 }, false}, - {{0.1f}, ngraph::element::f32, { 1, 1, 1, 1 } } }, + {{0.1f}, ngraph::element::f32, {} } }, { {}, {{128.f, 128.f, 128.f}, ngraph::element::f32, { 1, 3, 1, 1 }, false}, - {{0.1f}, ngraph::element::f32, { 1, 1, 1, 1 } } } + {{0.1f}, ngraph::element::f32, {} } } }, "convolution", "convolution" diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp index 50802fbba21..dc81761eb5b 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_backprop_data_transformation.cpp @@ -223,7 +223,7 @@ const std::vector testValues = ngraph::element::u8, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -243,7 +243,7 @@ const std::vector testValues = ngraph::element::u8, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -263,7 +263,7 @@ const std::vector testValues = ngraph::element::u8, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -283,7 +283,7 @@ const std::vector testValues = ngraph::element::u8, {{}, { { 128.f }, ngraph::element::f32, {}, false }, {}}, {{}, { { 2.f }, ngraph::element::f32, {1, 2, 1, 1}, true, 1ul, element::i8, false, { "DISABLED_CONSTANT_FOLDING" } }, {}}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }), true } @@ -303,7 +303,7 @@ const std::vector testValues = ngraph::element::u8, {}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -323,7 +323,7 @@ const std::vector testValues = ngraph::element::u8, {}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -343,7 +343,7 @@ const std::vector testValues = ngraph::element::u8, {}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, {1}}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }), true } @@ -363,7 +363,7 @@ const std::vector testValues = ngraph::element::u8, {}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -403,7 +403,7 @@ const std::vector testValues = ngraph::element::u8, {}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 2, 1, 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), true } @@ -423,7 +423,7 @@ const std::vector testValues = ngraph::element::u8, {}, {}, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 2, 1, 1 }}}, + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}}, op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ 2.f }), true } diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp index 32300353277..98ef612c595 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_qdq_transformation.cpp @@ -178,7 +178,7 @@ const std::vector testValues = { { std::vector{ 100.f }, ngraph::element::i8}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0006f }, ngraph::element::f32, {1, 1, 1, 1}}} + {{}, {}, {{ 0.0006f }, ngraph::element::f32, {}}} } }, @@ -230,7 +230,7 @@ const std::vector testValues = { { std::vector{ -125.f }, ngraph::element::i8}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, @@ -353,7 +353,7 @@ const std::vector testValues = { { std::vector{ 2.f }, ngraph::element::i8}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0006f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0006f }, ngraph::element::f32, {}}} } }, @@ -421,7 +421,7 @@ const std::vector testValues = { { std::vector{ 2.f }, ngraph::element::i8}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0006f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0006f }, ngraph::element::f32, {}}} } }, // incorrect zero point on activations [not transformed] diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp index d8f35b7bca5..394ea243b3c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_transformation.cpp @@ -153,7 +153,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // with zero point @@ -193,7 +193,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // without zero point @@ -213,7 +213,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // without zero point @@ -233,7 +233,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // without zero point, not update precisions @@ -253,7 +253,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::f32, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // with zero point, per-channel quantization with the same values @@ -273,7 +273,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // with zero point, per-channel quantization with different values @@ -389,7 +389,7 @@ const std::vector testValues = { op::Constant::create(ngraph::element::i8, ngraph::Shape{}, std::vector{ -125.f }), {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 1, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // incorrect zero point on activations [not transformed] diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp index 3a28bbe934e..dd13a0fe87a 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/convolution_with_incorrect_weights.cpp @@ -131,7 +131,7 @@ const std::vector testValues = { {}, ngraph::element::i8, {-126.f}, - {{}, {}, {{ 0.1f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 0.1f }, ngraph::element::f32, {}}}, }, }, }; diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index 7ff62291259..0990ea02099 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -130,9 +130,9 @@ const std::vector fak {{}, {}, {}}, ngraph::element::f32, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, - {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 1.f }, ngraph::element::f32, {}}}, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, - {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 1.f }, ngraph::element::f32, {}}}, } }, // TODO: LPT: issue #58685 @@ -169,9 +169,9 @@ const std::vector fak {{}, {}, {}}, ngraph::element::f32, { }, - {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 1.f }, ngraph::element::f32, {}}}, { }, - {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1, 1 }}}, + {{}, {}, {{ 1.f }, ngraph::element::f32, {}}}, } } }; diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp index 9266a6d8e62..34d55ee701d 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_with_dq_not_optimal_transformation.cpp @@ -204,7 +204,7 @@ const std::vector fakeQuanti { { }, { }, - { {0.0003f}, ngraph::element::f32, {1, 1, 1, 1}} + { {0.0003f}, ngraph::element::f32, {}} } }, } diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp index 469a5b06d56..1426ed6fe63 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/group_convolution_transformation.cpp @@ -163,7 +163,7 @@ const std::vector testValuesGroupConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) } }, @@ -188,7 +188,7 @@ const std::vector testValuesGroupConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) } }, @@ -213,7 +213,7 @@ const std::vector testValuesGroupConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) } }, @@ -262,7 +262,7 @@ const std::vector testValuesGroupConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} // 0.0002 = 0.02 (on data) * 0.01 (on weights) } }, // group convolution, per-channel quantization with different values, without zero point @@ -335,7 +335,7 @@ const std::vector testValuesGroupConv = { { {}, {}, - {{ 0.0002f }, ngraph::element::f32, {1, 24, 1, 1}} + {{ 0.0002f }, ngraph::element::f32, {}} }, } }, @@ -384,7 +384,7 @@ const std::vector testValuesGroupConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 24, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // per-channel quantization with different values, without zero point @@ -535,7 +535,7 @@ const std::vector testValuesForDepthWiseConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 6, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // depth-wise convolution, tensor quantization, with zero point @@ -559,7 +559,7 @@ const std::vector testValuesForDepthWiseConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 6, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // depth-wise convolution, per-channel quantization with different values, without zero point @@ -629,7 +629,7 @@ const std::vector testValuesForDepthWiseConv = { { {}, {}, - {{ 0.0002f }, ngraph::element::f32, {1, 6, 1, 1}} + {{ 0.0002f }, ngraph::element::f32, {}} }, } }, @@ -678,7 +678,7 @@ const std::vector testValuesForDepthWiseConv = { {}, {}, ngraph::element::f32, - {{}, {}, {{ 0.0002f }, ngraph::element::f32, { 1, 6, 1, 1 }}} + {{}, {}, {{ 0.0002f }, ngraph::element::f32, {}}} } }, // without dequantization operations diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp index 377c8ca043b..6a67202125c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/reshape_transformation.cpp @@ -332,6 +332,26 @@ const std::vector testValues = { } } }, + // U8: no subtract 4D -> 3D: rfcn-resnet101-coco + { + { 100, 4, 1, 1 }, + { -1, 1, 400}, + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + { + {ngraph::element::f32}, {}, {{0.1f, 0.1f, 0.1f, 0.1f}, ngraph::element::f32, {1, 4, 1, 1}} + } + }, + { + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, + { + {ngraph::element::f32}, {}, {{0.1f}, ngraph::element::f32, {}} + } + } + }, // U8: no subtract 4D -> 6D: channels are not affected: no subtract { { 1, 3, 4, 5 }, @@ -887,6 +907,30 @@ const std::vector testValues = { {{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3, 1}} } } + }, + // U8: without subtract 2D -> 2D + { + { 1, 3 }, + { 1, -1 }, + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + { + {ngraph::element::f32}, + {}, + {{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3}} + } + }, + { + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, + { + {ngraph::element::f32}, + {}, + {{0.1f, 0.01f, 0.1f}, ngraph::element::f32, {1, 3}} + } + } } }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp index cb645f11401..6d180e4b35f 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_precision_selection_function.cpp @@ -149,7 +149,7 @@ std::shared_ptr FakeQuantizePrecisionSelectionFunction::getRef std::shared_ptr branch1Multiply = std::make_shared( convolution, - std::make_shared(precision, Shape({1, 1, 1, 1}), std::vector({ 0.0001f }))); + std::make_shared(precision, Shape({}), std::vector({ 0.0001f }))); // just another branch