From 5943e1be73bee62dd4c9217ea6100b6146209d6a Mon Sep 17 00:00:00 2001 From: Vladislav Golubev Date: Mon, 28 Dec 2020 12:06:38 +0300 Subject: [PATCH] [LPT] issue #37332: tests unification (#3277) * [LPT] ieFuncTests unification * [LPT] plugin tests unification * [LPT] added removeStandaloneCleanup && removeTransforamtions refactoring --- .../include/low_precision/transformer.hpp | 96 +++++- .../src/concat.cpp | 4 +- .../src/network_helper.cpp | 36 ++- .../src/transformer.cpp | 22 -- .../avg_pool_transformation.cpp | 287 +++++++++++++++--- ...ction_with_intermediate_transformation.cpp | 85 ++++-- .../concat_transformation.cpp | 134 +++++--- ...cat_with_different_precision_on_childs.cpp | 102 ++++--- ...oncat_with_intermediate_transformation.cpp | 109 ++++--- ...ermediate_with_constant_transformation.cpp | 4 +- .../concat_with_neighbors_transformation.cpp | 114 ++++--- ...with_reshape_at_the_end_transformation.cpp | 65 ++-- .../concat_with_split_transformation.cpp | 89 ++++-- .../depth_to_space_transformation.cpp | 56 +++- ...d_two_output_branches_with_convolution.cpp | 109 ++++--- .../fake_quantize_transformation.cpp | 48 ++- .../low_precision_transformations_test.cpp | 33 +- .../max_pool_transformation.cpp | 28 +- .../normalize_l2_transformation.cpp | 225 ++++++++++---- .../split_transformation.cpp | 32 +- .../variadic_split_transformation.cpp | 34 ++- .../add_transformation.cpp | 16 +- .../concat_with_split_transformation.cpp | 3 +- ...d_two_output_branches_with_convolution.cpp | 14 +- ...ize_precision_selection_transformation.cpp | 10 +- .../fake_quantize_transformation.cpp | 14 +- ...uantize_and_scale_shift_transformation.cpp | 8 +- .../gemm_transformation.cpp | 18 +- .../layer_transformation.cpp | 8 +- ..._constant_fake_quantize_transformation.cpp | 10 +- ...ultiply_with_one_parent_transformation.cpp | 8 +- .../prelu_transformation.cpp | 14 +- .../relu_transformation.cpp | 12 +- .../reshape_transformation.cpp | 3 + .../squeeze_transformation.cpp | 18 +- ...ultiply_to_multiply_add_transformation.cpp | 25 +- .../subtract_transformation.cpp | 14 +- .../transpose_after_matmul_transformation.cpp | 14 +- .../unsqueeze_transformation.cpp | 32 +- .../add_transformation.cpp | 18 +- .../concat_with_split_transformation.cpp | 3 +- .../convolution_transformation.cpp | 24 +- ...d_two_output_branches_with_convolution.cpp | 12 +- ...ize_precision_selection_transformation.cpp | 10 +- .../fake_quantize_transformation.cpp | 14 +- .../fully_connected_transformation.cpp | 4 +- ...uantize_and_scale_shift_transformation.cpp | 8 +- .../gemm_transformation.cpp | 10 +- .../layer_transformation.cpp | 7 +- .../mat_mul_transformation.cpp | 2 +- ..._constant_fake_quantize_transformation.cpp | 10 +- .../multiply_transformation.cpp | 2 +- ...ultiply_with_one_parent_transformation.cpp | 6 +- .../prelu_transformation.cpp | 23 +- .../relu_transformation.cpp | 14 +- .../reshape_transformation.cpp | 7 +- .../squeeze_transformation.cpp | 28 +- ...ultiply_to_multiply_add_transformation.cpp | 25 +- .../subtract_transformation.cpp | 8 +- .../transpose_after_matmul_transformation.cpp | 8 +- .../unsqueeze_transformation.cpp | 36 +-- .../add_transformation.hpp | 3 + .../clamp_transformation.hpp | 2 +- .../concat_transformation.hpp | 3 + ...cat_with_different_precision_on_childs.hpp | 3 + ...oncat_with_intermediate_transformation.hpp | 3 + ...at_with_neighbors_graph_transformation.hpp | 3 + .../convolution_transformation.hpp | 2 +- .../convolution_with_incorrect_weights.hpp | 3 + ...e_quantize_and_avg_pool_transformation.hpp | 3 + ...e_quantize_and_max_pool_transformation.hpp | 3 + ...d_two_output_branches_with_convolution.hpp | 15 +- ...ize_precision_selection_transformation.hpp | 7 +- .../fake_quantize_transformation.hpp | 8 +- .../fully_connected_transformation.hpp | 3 + ...uantize_and_scale_shift_transformation.hpp | 7 +- .../fuse_fake_quantize_transformation.hpp | 3 + ...ltiply_to_fake_quantize_transformation.hpp | 3 + ...btract_to_fake_quantize_transformation.hpp | 3 + .../gemm_transformation.hpp | 13 +- .../group_convolution_transformation.hpp | 2 +- .../interpolate_transformation.hpp | 3 + .../mat_mul_transformation.hpp | 3 + .../mat_mul_with_constant_transformation.hpp | 3 + ..._constant_fake_quantize_transformation.hpp | 7 +- .../multiply_transformation.hpp | 3 + ...ultiply_with_one_parent_transformation.hpp | 4 +- .../mvn_transformation.hpp | 3 + .../normalize_transformation.hpp | 3 + .../prelu_transformation.hpp | 11 +- .../relu_transformation.hpp | 11 +- .../reshape_transformation.hpp | 4 + .../split_transformation.hpp | 2 +- .../squeeze_transformation.hpp | 5 +- ...ultiply_to_multiply_add_transformation.hpp | 4 +- .../subtract_transformation.hpp | 11 +- .../transpose_after_matmul_transformation.hpp | 7 +- .../transpose_transformation.hpp | 3 + .../unsqueeze_transformation.hpp | 5 +- .../variadic_split_transformation.hpp | 2 +- .../add_transformation.cpp | 56 ++-- .../clamp_transformation.cpp | 7 +- .../concat_transformation.cpp | 18 ++ ...cat_with_different_precision_on_childs.cpp | 22 ++ ...oncat_with_intermediate_transformation.cpp | 29 ++ ...at_with_neighbors_graph_transformation.cpp | 20 ++ .../convolution_transformation.cpp | 12 +- .../convolution_with_incorrect_weights.cpp | 26 ++ .../depth_to_space_transformation.cpp | 22 ++ ...e_quantize_and_avg_pool_transformation.cpp | 20 ++ ...e_quantize_and_max_pool_transformation.cpp | 20 ++ ...d_two_output_branches_with_convolution.cpp | 56 +++- ...ize_precision_selection_transformation.cpp | 47 ++- .../fake_quantize_transformation.cpp | 39 ++- .../fully_connected_transformation.cpp | 42 ++- ...uantize_and_scale_shift_transformation.cpp | 30 +- .../fuse_fake_quantize_transformation.cpp | 15 + ...ltiply_to_fake_quantize_transformation.cpp | 15 + ...btract_to_fake_quantize_transformation.cpp | 15 + .../gemm_transformation.cpp | 57 ++-- .../group_convolution_transformation.cpp | 6 +- .../interpolate_transformation.cpp | 22 ++ .../mat_mul_transformation.cpp | 17 ++ .../mat_mul_with_constant_transformation.cpp | 16 + ..._constant_fake_quantize_transformation.cpp | 31 +- .../multiply_transformation.cpp | 67 ++-- ...ultiply_with_one_parent_transformation.cpp | 13 +- .../mvn_transformation.cpp | 23 ++ .../normalize_transformation.cpp | 24 ++ .../prelu_transformation.cpp | 38 ++- .../relu_transformation.cpp | 39 ++- .../reshape_transformation.cpp | 22 ++ .../split_transformation.cpp | 14 +- .../squeeze_transformation.cpp | 27 +- ...ultiply_to_multiply_add_transformation.cpp | 6 +- .../subtract_transformation.cpp | 37 +-- .../transpose_after_matmul_transformation.cpp | 50 ++- .../transpose_transformation.cpp | 16 + .../unsqueeze_transformation.cpp | 27 +- .../variadic_split_transformation.cpp | 14 +- .../layer_transformation.hpp | 2 +- .../lpt_ngraph_functions/add_function.hpp | 7 + .../avg_pool_function.hpp | 27 +- .../lpt_ngraph_functions/concat_function.hpp | 31 +- .../depth_to_space_function.hpp | 1 + ...put_branches_with_convolution_function.hpp | 37 +-- .../fake_quantize_function.hpp | 5 +- .../lpt_ngraph_functions/mat_mul_function.hpp | 13 + .../max_pool_function.hpp | 1 + .../multiply_function.hpp | 7 + .../normalize_l2_function.hpp | 44 +-- .../lpt_ngraph_functions/split_function.hpp | 2 + .../subtract_function.hpp | 27 ++ .../transpose_after_mat_mul_function.hpp | 27 ++ .../variadic_split_function.hpp | 2 + .../lpt_ngraph_functions/src/add_function.cpp | 39 +++ .../src/avg_pool_function.cpp | 70 ++--- .../src/concat_function.cpp | 279 +++++++---------- .../src/depth_to_space_function.cpp | 2 + ...put_branches_with_convolution_function.cpp | 56 ++-- .../src/fake_quantize_function.cpp | 55 ++-- .../src/mat_mul_function.cpp | 71 +++++ .../src/max_pool_function.cpp | 8 +- .../src/multiply_function.cpp | 40 +++ .../src/normalize_l2_function.cpp | 77 ++--- .../src/split_function.cpp | 10 +- .../src/subtract_function.cpp | 51 ++++ .../src/transpose_after_mat_mul_function.cpp | 48 +++ .../src/variadic_split_function.cpp | 8 +- 169 files changed, 3062 insertions(+), 1480 deletions(-) create mode 100644 inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp create mode 100644 inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp create mode 100644 inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp create mode 100644 inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp diff --git a/inference-engine/src/low_precision_transformations/include/low_precision/transformer.hpp b/inference-engine/src/low_precision_transformations/include/low_precision/transformer.hpp index e62c1c48897..fe8a43784bd 100644 --- a/inference-engine/src/low_precision_transformations/include/low_precision/transformer.hpp +++ b/inference-engine/src/low_precision_transformations/include/low_precision/transformer.hpp @@ -39,10 +39,98 @@ public: void setUpdatePrecisions(const bool updatePrecisions); void setQuantizedTensorAlignmentOnActivations(const LayerTransformation::QuantizedTensorAlignment quantizedTensorAlignmentOnActivations); void setQuantizedTensorAlignmentOnWeights(const LayerTransformation::QuantizedTensorAlignment quantizedTensorAlignmentOnWeights); - LowPrecisionTransformations& remove(const std::string& operationType); - LowPrecisionTransformations& removeBranchSpecificTransformations(const std::string& operationType); - LowPrecisionTransformations& removeTransformations(const std::string& operationType); - LowPrecisionTransformations& removeCleanupTransformations(const std::string& operationType); + + /** + * Remove branch specific transformation. Transformation type and operation type are required. + * Operation type is used to find transformation by operation during precision definition. + */ + template + LowPrecisionTransformations& removeBranchSpecific() { + const std::string operationType = getType(); + const std::string transformationType = typeid(Transformation).name(); + + for (auto it = branchSpecificTransformations.begin(); it != branchSpecificTransformations.end(); ++it) { + const auto& tranformationPtr = *it->second; + if ((it->first == operationType) && (typeid(tranformationPtr).name() == transformationType)) { + branchSpecificTransformations.erase(it); + break; + } + } + return *this; + } + + /** + * Remove transformation. Transformation type and operation type are required. + * Operation type is used to find transformation by operation during precision definition. + */ + template + LowPrecisionTransformations& remove() { + const std::string operationType = getType(); + const std::string transformationType = typeid(Transformation).name(); + + for (auto it = transformations.begin(); it != transformations.end(); ++it) { + const auto& tranformationPtr = *it->second; + if ((it->first == operationType) && (typeid(tranformationPtr).name() == transformationType)) { + transformations.erase(it); + break; + } + } + return *this; + } + + /** + * Remove cleanup transformation. Transformation type and operation type are required. + * Operation type is used to find transformation by operation during precision definition. + */ + template + LowPrecisionTransformations& removeCleanup() { + const std::string operationType = getType(); + const std::string transformationType = typeid(Transformation).name(); + + const auto it = cleanupTransformations.find(operationType); + if (it != cleanupTransformations.end()) { + const auto it1 = std::find_if(it->second.begin(), it->second.end(), + [&](const std::pair& transformation) { + return transformation.first == transformationType; + }); + if (it1 != it->second.end()) { + it->second.erase(it1); + if (it->second.empty()) { + cleanupTransformations.erase(it); + } + } + } + return *this; + } + + /** + * Remove standalone cleanup transformation. Transformation type and operation type are required. + * Operation type is used to find transformation by operation during precision definition. + */ + template + LowPrecisionTransformations& removeStandaloneCleanup() { + const std::string operationType = getType(); + const std::string transformationType = typeid(Transformation).name(); + + for (auto it = standaloneCleanupTransformations.begin(); it != standaloneCleanupTransformations.end(); ++it) { + const auto& standaloneCleanup = *it; + if ((operationType == standaloneCleanup.typeName) && (transformationType == standaloneCleanup.typeId)) { + standaloneCleanupTransformations.erase(it); + break; + } + } + return *this; + } + + template + LowPrecisionTransformations& removeAll() { + removeBranchSpecific(); + remove(); + removeCleanup(); + removeStandaloneCleanup(); + + return *this; + } /** * Add branch specific transformation. Transformation type and operation type are required. diff --git a/inference-engine/src/low_precision_transformations/src/concat.cpp b/inference-engine/src/low_precision_transformations/src/concat.cpp index a7adb0a1fd2..74ea479ccc3 100644 --- a/inference-engine/src/low_precision_transformations/src/concat.cpp +++ b/inference-engine/src/low_precision_transformations/src/concat.cpp @@ -290,7 +290,9 @@ void ConcatTransformation::addDequantizationLayers( for (size_t i = 0; i < layerDequantizations.size(); ++i) { const auto& dequantization = layerDequantizations[i]; - convertNodes.push_back(dequantization.convert); + if (dequantization.convert != nullptr) { + convertNodes.push_back(dequantization.convert); + } const ngraph::element::Type precision = dequantization.data.get_element_type(); ngraph::Shape targetShape = dequantization.data.get_shape(); 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 e2b84a27067..4450a2466a3 100644 --- a/inference-engine/src/low_precision_transformations/src/network_helper.cpp +++ b/inference-engine/src/low_precision_transformations/src/network_helper.cpp @@ -678,9 +678,10 @@ FakeQuantizeDequantization NetworkHelper::makeDequantization( const std::shared_ptr input = std::make_shared(precision, dataNodeOutputShape); std::shared_ptr parent = input; - // TODO: convert should be optional: where is updatePrecision? std::shared_ptr convert; - { + if (precision == originalPrecision) { + convert = nullptr; + } else { convert = std::make_shared( input, originalPrecision); @@ -742,21 +743,28 @@ FakeQuantizeDequantization NetworkHelper::createDequantizationFromFakeQuantize( } } - const auto input = std::make_shared(precision, fq->get_output_shape(0)); - const std::shared_ptr convert = std::make_shared( - input, - fq->get_output_element_type(0)); + const auto input = std::make_shared( + updatePrecision ? precision : fq->get_output_element_type(0), + fq->get_output_shape(0)); + std::shared_ptr parent = input; - const std::shared_ptr subtract = shift == nullptr ? - nullptr : - make_shared>(convert, shift); - if (subtract != nullptr) { - subtract->set_output_type(0, fq->get_output_element_type(0), subtract->get_output_partial_shape(0)); + std::shared_ptr convert; + if (updatePrecision) { + convert = std::make_shared(parent, fq->get_output_element_type(0)); + parent = convert; + } else { + convert = nullptr; } - const std::shared_ptr multiply = std::make_shared( - subtract == nullptr ? static_cast>(convert) : subtract, - scale); + std::shared_ptr subtract; + if (shift != nullptr) { + subtract = make_shared>(parent, shift); + subtract->set_output_type(0, fq->get_output_element_type(0), subtract->get_output_partial_shape(0)); + parent = subtract; + } else { + subtract = nullptr; + } + const std::shared_ptr multiply = std::make_shared(parent, scale); return FakeQuantizeDequantization(fq, convert, subtract, multiply); } diff --git a/inference-engine/src/low_precision_transformations/src/transformer.cpp b/inference-engine/src/low_precision_transformations/src/transformer.cpp index 66ae78c5165..b475b83ca40 100644 --- a/inference-engine/src/low_precision_transformations/src/transformer.cpp +++ b/inference-engine/src/low_precision_transformations/src/transformer.cpp @@ -101,28 +101,6 @@ void LowPrecisionTransformations::setQuantizedTensorAlignmentOnWeights( } } -LowPrecisionTransformations& LowPrecisionTransformations::remove(const std::string& operationType) { - removeBranchSpecificTransformations(operationType); - removeTransformations(operationType); - removeCleanupTransformations(operationType); - return *this; -} - -LowPrecisionTransformations& LowPrecisionTransformations::removeBranchSpecificTransformations(const std::string& operationType) { - branchSpecificTransformations.erase(operationType); - return *this; -} - -LowPrecisionTransformations& LowPrecisionTransformations::removeTransformations(const std::string& operationType) { - transformations.erase(operationType); - return *this; -} - -LowPrecisionTransformations& LowPrecisionTransformations::removeCleanupTransformations(const std::string& operationType) { - cleanupTransformations.erase(operationType); - return *this; -} - std::vector LowPrecisionTransformations::find(const std::string& transformationKey) const { auto it = branchSpecificTransformations.find(transformationKey); std::vector res; diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp index faf931bb9ac..ea09b288707 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/avg_pool_transformation.cpp @@ -18,19 +18,34 @@ #include "common_test_utils/ngraph_test_utils.hpp" #include "simple_low_precision_transformer.hpp" #include "lpt_ngraph_functions/avg_pool_function.hpp" +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" using namespace testing; using namespace ngraph::pass; class AvgPoolTransformationTestValues { public: - low_precision::LayerTransformation::Params params; - std::vector subtractValues; - std::vector mutliplyValues; +public: + class Actual { + public: + ngraph::element::Type inputPrecision; + ngraph::builder::subgraph::DequantizationOperations dequantization; + }; + + class Expected { + public: + ngraph::element::Type inputPrecision; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type preicsionAfterOperation; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter; + }; + + ngraph::pass::low_precision::LayerTransformation::Params params; + Actual actual; + Expected expected; }; typedef std::tuple< - ngraph::element::Type, ngraph::Shape, bool, // additional FakeQuantize After std::string, // additional layer before FQ @@ -39,22 +54,17 @@ typedef std::tuple< class AvgPoolTransformation : public LayerTransformation, public testing::WithParamInterface { public: void SetUp() override { - const ngraph::element::Type precision = std::get<0>(GetParam()); - const ngraph::Shape shape = std::get<1>(GetParam()); - const bool addFQ = std::get<2>(GetParam()); - const std::string additionalLayer = std::get<3>(GetParam()); - const AvgPoolTransformationTestValues testValues = std::get<4>(GetParam()); + const ngraph::Shape shape = std::get<0>(GetParam()); + const bool addFakeQuantize = std::get<1>(GetParam()); + const std::string additionalLayer = std::get<2>(GetParam()); + const AvgPoolTransformationTestValues testValues = std::get<3>(GetParam()); actualFunction = ngraph::builder::subgraph::AvgPoolFunction::getOriginal( - precision, + testValues.actual.inputPrecision, shape, - addFQ, + addFakeQuantize, additionalLayer, - { - testValues.params.updatePrecisions ? testValues.params.precisionsOnActivations[0] : precision, - testValues.subtractValues, - testValues.mutliplyValues - }); + testValues.actual.dequantization); SimpleLowPrecisionTransformer transform; transform.add(testValues.params); @@ -62,25 +72,31 @@ public: transform.transform(actualFunction); referenceFunction = ngraph::builder::subgraph::AvgPoolFunction::getReference( - precision, + testValues.expected.inputPrecision, shape, - addFQ, + addFakeQuantize, additionalLayer, - { - testValues.params.updatePrecisions ? testValues.params.precisionsOnActivations[0] : precision, - testValues.subtractValues, - testValues.mutliplyValues - }); + testValues.expected.dequantizationBefore, + testValues.expected.preicsionAfterOperation, + testValues.expected.dequantizationAfter); } static std::string getTestCaseName(testing::TestParamInfo obj) { - const ngraph::element::Type precision = std::get<0>(obj.param); - const ngraph::Shape shape = std::get<1>(obj.param); - const bool addFQ = std::get<2>(obj.param); - const std::string additionalLayer = std::get<3>(obj.param); - const AvgPoolTransformationTestValues testValues = std::get<4>(obj.param); - return LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) + - (addFQ ? "_FQ_after_" : "_") + (additionalLayer); + const ngraph::Shape shape = std::get<0>(obj.param); + const bool addFakeQuantize = std::get<1>(obj.param); + const std::string additionalLayer = std::get<2>(obj.param); + const AvgPoolTransformationTestValues testValues = std::get<3>(obj.param); + + + std::ostringstream result; + result << + LayerTransformation::getTestCaseNameByParams(testValues.actual.inputPrecision, shape, testValues.params) << "_" << + testValues.actual.dequantization << "_" << + testValues.expected.dequantizationBefore << "_" << + testValues.expected.preicsionAfterOperation << "_" << + testValues.expected.dequantizationAfter << "_" << + (addFakeQuantize ? "_FQ_after_" : "_") << additionalLayer; + return result.str(); } }; @@ -92,11 +108,6 @@ TEST_P(AvgPoolTransformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -const std::vector precisions = { - ngraph::element::f32, - // ngraph::element::f16 -}; - const std::vector additionalLayer = { "", // issue #40768 @@ -110,20 +121,216 @@ const std::vector addFQ = { }; const std::vector shapes = { - { 1, 32, 72, 48 } + { 1, 3, 72, 48 } }; const std::vector testValues = { - { LayerTransformation::createParamsU8I8(), { 128 }, { 0.02f } }, - { LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), { 128 }, { 0.02f } }, - { LayerTransformation::createParamsI8I8(), { 128 }, { 0.02f } }, + // U8 per tensor quantization + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + {{ngraph::element::f32}, {128.f}, {0.02f}} + }, + { + ngraph::element::u8, + {}, + ngraph::element::f32, + {{}, {128.f}, {0.02f}} + } + }, + // U8 without subtract + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, {0.02f}} + }, + { + ngraph::element::u8, + {}, + ngraph::element::f32, + {{}, {}, {0.02f}} + } + }, + // U8 per channel quantization with different values + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + { + {ngraph::element::f32}, + {{128.f, 0.f, 128.f / 2}}, + {{3.f, 1.f, 2.f}} + } + }, + { + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::f32, + { + {}, + {{128.f, 0.f, 128.f / 2}}, + {{3.f, 1.f, 2.f}} + }, + } + }, + // U8 per channel quantization with the same values + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + { + {ngraph::element::f32}, + {{128.f, 128.f, 128.f}}, + {{3.f, 3.f, 3.f}} + } + }, + { + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::f32, + { + {}, + {{128.f, 128.f, 128.f}}, + {{3.f, 3.f, 3.f}} + }, + } + }, + // U8 without dequantization + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + {} + }, + { + ngraph::element::u8, + {}, + ngraph::element::u8, + {} + } + }, + // U8 not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + { + ngraph::element::f32, + {{}, {128.f}, {0.02f}} + }, + { + ngraph::element::f32, + {}, + ngraph::element::f32, + {{}, {128.f}, {0.02f}} + } + }, + // I8 per tensor quantization + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + {{ngraph::element::f32}, {128.f}, {0.02f}} + }, + { + ngraph::element::i8, + {}, + ngraph::element::f32, + {{}, {128.f}, {0.02f}} + } + }, + // I8 without subtract + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + {{ngraph::element::f32}, {}, {0.02f}} + }, + { + ngraph::element::i8, + {}, + ngraph::element::f32, + {{}, {}, {0.02f}} + } + }, + // I8 per channel quantization with different values + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + { + {ngraph::element::f32}, + {{64.f, 0.f, 32.f}}, + {{3.f, 1.f, 2.f}} + } + }, + { + ngraph::element::i8, + {{}, {}, {}}, + ngraph::element::f32, + { + {}, + {{64.f, 0.f, 32.f}}, + {{3.f, 1.f, 2.f}} + }, + } + }, + // I8 per channel quantization with the same values + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + { + {ngraph::element::f32}, + {{64.f, 64.f, 64.f}}, + {{3.f, 3.f, 3.f}} + } + }, + { + ngraph::element::i8, + {{}, {}, {}}, + ngraph::element::f32, + { + {}, + {{64.f, 64.f, 64.f}}, + {{3.f, 3.f, 3.f}} + }, + } + }, + // I8 without dequantization + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + {} + }, + { + ngraph::element::i8, + {}, + ngraph::element::i8, + {} + } + }, + // I8 not update precisions + { + LayerTransformation::createParamsI8I8().setUpdatePrecisions(false), + { + ngraph::element::f32, + {{}, {128.f}, {0.02f}} + }, + { + ngraph::element::f32, + {}, + ngraph::element::f32, + {{}, {128.f}, {0.02f}} + } + }, }; INSTANTIATE_TEST_CASE_P( smoke_LPT, AvgPoolTransformation, ::testing::Combine( - ::testing::ValuesIn(precisions), ::testing::ValuesIn(shapes), ::testing::ValuesIn(addFQ), ::testing::ValuesIn(additionalLayer), diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp index 6d8d75195ee..f8528f9c45b 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_selection_with_intermediate_transformation.cpp @@ -42,12 +42,17 @@ class ResultValues { public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; - ngraph::builder::subgraph::DequantizationOperations dequantization1; - ngraph::builder::subgraph::DequantizationOperations dequantization2; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore1; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore2; + ngraph::element::Type precisionAfterOperation; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2; }; inline std::ostream& operator<<(std::ostream& out, const ResultValues& values) { - return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" << values.dequantization1 << "_" << values.dequantization2; + return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" + << values.dequantizationAfter1 << "_" << values.dequantizationAfter2; } class TestValues { @@ -65,7 +70,6 @@ inline std::ostream& operator<<(std::ostream& out, const TestValues& values) { typedef std::tuple < ngraph::element::Type, - bool, TestValues > ConcatTransformationParams; @@ -73,14 +77,7 @@ class ConcatSelectionWithIntermediateTransformation : public LayerTransformation public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); - TestValues testValues = std::get<2>(GetParam()); - - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - } + TestValues testValues = std::get<1>(GetParam()); actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalSelectionWithIntermediate( precision, @@ -100,14 +97,17 @@ public: testValues.transparentIntermediate, testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, - testValues.result.dequantization1, - testValues.result.dequantization2); + testValues.result.precisionBeforeOp, + testValues.result.dequantizationBefore1, + testValues.result.dequantizationBefore2, + testValues.result.precisionAfterOperation, + testValues.result.dequantizationAfter1, + testValues.result.dequantizationAfter2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); - const TestValues testValues = std::get<2>(obj.param); + const TestValues testValues = std::get<1>(obj.param); std::ostringstream result; result << @@ -120,8 +120,6 @@ public: }; TEST_P(ConcatSelectionWithIntermediateTransformation, CompareFunctions) { - const TestValues testValues = std::get<2>(GetParam()); - actualFunction->validate_nodes_and_infer_types(); auto res = compare_functions(referenceFunction, actualFunction, true, true); ASSERT_TRUE(res.first) << res.second; @@ -132,8 +130,6 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { true, false }; - const std::vector testValues = { // U8: Concat + MaxPool { @@ -142,23 +138,46 @@ const std::vector testValues = { true, { { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f}, ngraph::element::u8 }, - { ngraph::element::f32, {}, { 0.01f } }, - { ngraph::element::f32, {}, { 0.01f } } + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, + { {ngraph::element::f32}, {}, { {0.01f, 0.01f, 0.01f, 0.1f, 0.1f, 0.1f} } }, + { {ngraph::element::f32}, {}, { 0.1f } } + } + }, + // not update precisions + { + Shape{ 1, 3, 9, 9 }, + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + true, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {255.f} }, + ngraph::element::f32, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::f32, + { {}, {}, { {0.01f, 0.01f, 0.01f, 0.1f, 0.1f, 0.1f} } }, + { {}, {}, { 0.1f } } } } }; -// INSTANTIATE_TEST_CASE_P( -// DISABLED_LPT, -// ConcatSelectionWithIntermediateTransformation, -// ::testing::Combine( -// ::testing::ValuesIn(precisions), -// ::testing::ValuesIn(updatePrecisions), -// ::testing::ValuesIn(testValues)), -// ConcatSelectionWithIntermediateTransformation::getTestCaseName); + INSTANTIATE_TEST_CASE_P( + smoke_LPT, + ConcatSelectionWithIntermediateTransformation, + ::testing::Combine( + ::testing::ValuesIn(precisions), + ::testing::ValuesIn(testValues)), + ConcatSelectionWithIntermediateTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp index d30ff9bc603..79c2c507b7b 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_transformation.cpp @@ -41,11 +41,14 @@ class ConcatTransformationResultValues { public: ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fakeQuantize2; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationOperations1; + ngraph::element::Type precisionAfterOperation; + ngraph::builder::subgraph::DequantizationOperations dequantizationOperations2; }; inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationResultValues& values) { - return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" << values.dequantizationOperations; + return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" << values.dequantizationOperations2; } class ConcatTransformationTestValues { @@ -62,7 +65,6 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTes typedef std::tuple < ngraph::element::Type, - bool, ngraph::Shape, ConcatTransformationTestValues > ConcatTransformationParams; @@ -71,15 +73,8 @@ class ConcatTransformation : public LayerTransformation, public testing::WithPar public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); - const ngraph::Shape shape = std::get<2>(GetParam()); - ConcatTransformationTestValues testValues = std::get<3>(GetParam()); - - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - } + const ngraph::Shape shape = std::get<1>(GetParam()); + ConcatTransformationTestValues testValues = std::get<2>(GetParam()); actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginal( precision, @@ -100,20 +95,21 @@ public: shape, testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, - testValues.result.dequantizationOperations); + testValues.result.precisionBeforeOp, + testValues.result.dequantizationOperations1, + testValues.result.precisionAfterOperation, + testValues.result.dequantizationOperations2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); - const ngraph::Shape shape = std::get<2>(obj.param); - const ConcatTransformationTestValues testValues = std::get<3>(obj.param); + const ngraph::Shape shape = std::get<1>(obj.param); + const ConcatTransformationTestValues testValues = std::get<2>(obj.param); std::ostringstream result; result << LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << "_" << (testValues.multiChannels ? "multiChannels_" : "notMultiChannels_") << - (updatePrecision ? "updatePrecision_" : "notUpdatePrecision_") << testValues.actual << "_" << testValues.result << "_"; return result.str(); @@ -131,8 +127,6 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { true, false }; - const std::vector testValues = { // U8: concat { @@ -143,9 +137,12 @@ const std::vector testValues = { { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} } }, { - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { ngraph::element::f32, {}, { 0.01f } } + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, + { ngraph::element::f32, {}, { 0.01f } }, } }, // U8: concat @@ -157,8 +154,11 @@ const std::vector testValues = { { 256ul, {{1}, {1}, {1}, {1}}, {0.f}, {2.55f}, {0.f}, {2.55f} } }, { - { 256ul, {{1}, {1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {{1}, {1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {{1}, {1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {{1}, {1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } } } }, @@ -171,8 +171,11 @@ const std::vector testValues = { { 256ul, {{1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}, {1, 1, 1, 1}}, {0.f}, {2.55f}, {0.f}, {2.55f} } }, { - { 256ul, {{1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {{1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {{1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {{1, 1, 1, 1}, {1, 1, 1, 1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } } } }, @@ -185,8 +188,11 @@ const std::vector testValues = { { 256ul, {}, {0.f}, {1.275f}, {0.f}, {1.275f} } }, { - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {0.f}, {1.275f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {1.275f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} } } }, @@ -199,8 +205,11 @@ const std::vector testValues = { { 256ul, {{1}, {1}, {1}, {1}}, {0.f}, {1.275f}, {0.f}, {1.275f} } }, { - { 256ul, {{1}, {1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {{1}, {1}, {}, {}}, {0.f}, {1.275f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {{1}, {1}, {}, {}}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {{1}, {1}, {}, {}}, {0.f}, {1.275f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} } } }, @@ -235,6 +244,9 @@ const std::vector testValues = { {0.f, 0.f, 0.f}, {1.275f, 1.275f, 1.275f}, {0.f}, {255.f}, ngraph::element::u8 }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f / 1.f, 0.01f / 2.f, 0.01f / 3.f, 0.005f / 1.f, 0.005f / 2.f, 0.005f / 3.f }} } } }, @@ -247,8 +259,11 @@ const std::vector testValues = { { 256ul, {}, {1.275f}, {2.55f}, {1.275f}, {2.55f} } }, { - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {1.275f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {1.275f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {{ 0.f, 0.f, 0.f, -255.f, -255.f, -255.f }}, @@ -265,8 +280,11 @@ const std::vector testValues = { { 256ul, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f} } }, { - { 256ul, {}, {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, {}, {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, + { 256ul, {}, {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, {}, {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + ngraph::element::i8, + { {}, {}, {} }, + ngraph::element::i8, { ngraph::element::f32, {}, { 0.01f } } } }, @@ -279,8 +297,11 @@ const std::vector testValues = { { 256ul, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f} } }, { - { 256ul, {}, {0.f}, {2.55f}, {85.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {-1.28f}, {1.27f}, {0.f}, {170.f}, ngraph::element::u8 }, + { 256ul, {}, {0.f}, {2.55f}, {85.f}, {255.f} }, + { 256ul, {}, {-1.28f}, {1.27f}, {0.f}, {170.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, { 85 }, { 0.015f } } } }, @@ -293,8 +314,11 @@ const std::vector testValues = { { 256ul, {}, {-1.28f}, {1.27f}, {-1.28f}, {1.27f} } }, { - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {-1.28f}, {1.27f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {-1.28f}, {1.27f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, {{ 0.f, 0.f, 0.f, 128.f, 128.f, 128.f }}, { 0.01f } } } }, @@ -307,8 +331,11 @@ const std::vector testValues = { { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} } }, { - { 256ul, {}, {-1.28f}, {1.27f}, {0.f}, {170.f}, ngraph::element::u8 }, - { 256ul, {}, {0.f}, {2.55f}, {85.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {}, {-1.28f}, {1.27f}, {0.f}, {170.f} }, + { 256ul, {}, {0.f}, {2.55f}, {85.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, { 85 }, { 0.015f } } } }, @@ -321,11 +348,31 @@ const std::vector testValues = { { 256ul, {}, {0.f}, {2.55f}, {-3.873046875f}, {3.84375} } }, { - { 256ul, {}, {-1.28f}, {1.27f}, {128.f}, {204.f}, ngraph::element::u8 }, - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {}, {-1.28f}, {1.27f}, {128.f}, {204.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + { {}, {}, {} }, + ngraph::element::u8, { ngraph::element::f32, { 128 }, { 0.0302619f } } } - } + }, + // not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + false, + { + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} } + }, + { + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::f32, + { {}, {}, {} }, + ngraph::element::f32, + { {}, {}, { 0.01f } }, + } + }, }; const std::vector shapes = { @@ -338,7 +385,6 @@ INSTANTIATE_TEST_CASE_P( ConcatTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::ValuesIn(updatePrecisions), ::testing::ValuesIn(shapes), ::testing::ValuesIn(testValues)), ConcatTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_childs.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_childs.cpp index f7060401b70..bdff5a4abad 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_childs.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_different_precision_on_childs.cpp @@ -44,21 +44,23 @@ class ConcatTransformationResultValues { public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations1; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations2; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOperation; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2; }; inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationResultValues& values) { return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" << - values.dequantizationOperations1 << "_" << - values.dequantizationOperations2; + values.dequantizationAfter1 << "_" << + values.dequantizationAfter2; } class ConcatTransformationTestValues { public: - ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; bool multiChannels; ConcatTransformationActualValues actual; @@ -71,7 +73,7 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTes typedef std::tuple < ngraph::element::Type, - bool, + ngraph::Shape, ConcatTransformationTestValues > ConcatTransformationParams; @@ -79,18 +81,12 @@ class ConcatWithDifferentChildsTransformation : public LayerTransformation, publ public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); + const ngraph::Shape inputShape = std::get<1>(GetParam()); ConcatTransformationTestValues testValues = std::get<2>(GetParam()); - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - } - actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithDifferentPrecisionOnChilds( precision, - testValues.inputShape, + inputShape, testValues.actual.fakeQuantize1, testValues.actual.fakeQuantize2); @@ -104,31 +100,28 @@ public: transform.add(testValues.params); transform.transform(actualFunction); - if (!updatePrecisions) { - // there is no Convert operation after MaxPool in FP32 - testValues.result.dequantizationOperations2.convert = {}; - } - referenceFunction = ngraph::builder::subgraph::ConcatFunction::getReferenceWithDifferentPrecisionOnChilds( precision, - testValues.inputShape, + inputShape, testValues.multiChannels, testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, - testValues.result.dequantizationOperations1, - testValues.result.dequantizationOperations2); + testValues.result.precisionBeforeOp, + testValues.result.dequantizationBefore, + testValues.result.precisionAfterOperation, + testValues.result.dequantizationAfter1, + testValues.result.dequantizationAfter2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); + const ngraph::Shape inputShape = std::get<1>(obj.param); const ConcatTransformationTestValues testValues = std::get<2>(obj.param); std::ostringstream result; result << - LayerTransformation::getTestCaseNameByParams(precision, testValues.inputShape, testValues.params) << "_" << + LayerTransformation::getTestCaseNameByParams(precision, inputShape, testValues.params) << "_" << (testValues.multiChannels ? "multiChannels_" : "notMultiChannels_") << - (updatePrecision ? "updatePrecision_" : "notUpdatePrecision_") << testValues.actual << "_" << testValues.result << "_"; return result.str(); @@ -136,8 +129,6 @@ public: }; TEST_P(ConcatWithDifferentChildsTransformation, CompareFunctions) { - const ConcatTransformationTestValues testValues = std::get<2>(GetParam()); - actualFunction->validate_nodes_and_infer_types(); auto res = compare_functions(referenceFunction, actualFunction, true, true, true); ASSERT_TRUE(res.first) << res.second; @@ -148,12 +139,14 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { true, false }; +const std::vector shapes = { + { 1, 3, 10, 10 }, + { 4, 3, 10, 10 } +}; const std::vector testValues = { // U8 { - { 1, 3, 10, 10 }, LayerTransformation::createParamsU8I8(), false, { @@ -161,15 +154,17 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } }, // I8 { - { 1, 3, 10, 10 }, LayerTransformation::createParamsI8I8(), false, { @@ -177,15 +172,17 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f} }, + ngraph::element::i8, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } }, // U8: concat multi channels { - { 1, 3, 10, 10 }, LayerTransformation::createParamsU8I8(), true, { @@ -193,15 +190,17 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, } }, // I8: concat multi channels { - { 1, 3, 10, 10 }, LayerTransformation::createParamsI8I8(), true, { @@ -209,12 +208,33 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f} }, + ngraph::element::i8, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, } }, + // not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + false, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} }, + ngraph::element::f32, + {{}, {}, {}}, + ngraph::element::f32, + { {}, {}, { 0.01f } }, + { {}, {}, { 0.01f } } + } + }, }; INSTANTIATE_TEST_CASE_P( @@ -222,7 +242,7 @@ INSTANTIATE_TEST_CASE_P( ConcatWithDifferentChildsTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::ValuesIn(updatePrecisions), + ::testing::ValuesIn(shapes), ::testing::ValuesIn(testValues)), ConcatWithDifferentChildsTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp index 01d518c58f5..3a7f27bbb67 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_transformation.cpp @@ -42,16 +42,20 @@ class ConcatTransformationResultValues { public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations1; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations2; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore1; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore2; + ngraph::element::Type precisionAfterOperation; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2; }; inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationResultValues& values) { return out << "_" << values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" << - values.dequantizationOperations1 << "_" << - values.dequantizationOperations2; + values.dequantizationAfter1 << "_" << + values.dequantizationAfter2; } class ConcatTransformationTestValues { @@ -69,7 +73,6 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTes typedef std::tuple < ngraph::element::Type, - bool, ngraph::Shape, ConcatTransformationTestValues > ConcatTransformationParams; @@ -78,15 +81,8 @@ class ConcatWithIntermediateTransformation : public LayerTransformation, public public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); - const ngraph::Shape shape = std::get<2>(GetParam()); - ConcatTransformationTestValues testValues = std::get<3>(GetParam()); - - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - } + const ngraph::Shape shape = std::get<1>(GetParam()); + ConcatTransformationTestValues testValues = std::get<2>(GetParam()); actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithIntermediate( precision, @@ -110,21 +106,23 @@ public: testValues.transparentIntermediate, testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, - testValues.result.dequantizationOperations1, - testValues.result.dequantizationOperations2); + testValues.result.precisionBeforeOp, + testValues.result.dequantizationBefore1, + testValues.result.dequantizationBefore2, + testValues.result.precisionAfterOperation, + testValues.result.dequantizationAfter1, + testValues.result.dequantizationAfter2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); - const ngraph::Shape shape = std::get<2>(obj.param); - const ConcatTransformationTestValues testValues = std::get<3>(obj.param); + const ngraph::Shape shape = std::get<1>(obj.param); + const ConcatTransformationTestValues testValues = std::get<2>(obj.param); std::ostringstream result; result << LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << "_" << (testValues.multiChannels ? "multiChannels_" : "notMultiChannels_") << - (updatePrecision ? "updatePrecision_" : "notUpdatePrecision_") << testValues.actual << "_" << testValues.result << "_"; return result.str(); @@ -142,8 +140,6 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { true, false }; - const std::vector testValues = { // U8: concat { @@ -155,8 +151,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -171,8 +171,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f} }, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -187,8 +191,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {1.275f}, {2.55f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {128.f}, {255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {128.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -203,8 +211,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, { 0.005f } } } @@ -219,8 +231,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f} }, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, { 0.005f } } } @@ -235,8 +251,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {1.275f}, {2.55f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {{ 0.f, 0.f, 0.f, -255.f, -255.f, -255.f }}, @@ -245,6 +265,26 @@ const std::vector testValues = { { ngraph::element::f32, {-255.f}, { 0.005f } } } }, + // not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + false, + true, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f} }, + ngraph::element::f32, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::f32, + { {}, {}, { 0.01f } }, + { {}, {}, { 0.01f } } + } + }, }; const std::vector shapes = { @@ -257,7 +297,6 @@ INSTANTIATE_TEST_CASE_P( ConcatWithIntermediateTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::ValuesIn(updatePrecisions), ::testing::ValuesIn(shapes), ::testing::ValuesIn(testValues)), ConcatWithIntermediateTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp index 2189be7ff71..dc2936bd687 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_intermediate_with_constant_transformation.cpp @@ -215,7 +215,7 @@ const std::vector testValues = { { {}, {}, {} }, ngraph::element::f32, ngraph::element::f32, - { ngraph::element::f32, {}, { 0.01f } }, + { {}, {}, { 0.01f } }, ngraph::element::f32 } }, @@ -296,7 +296,7 @@ const std::vector testValues = { ngraph::element::f32, ngraph::element::f32, { - ngraph::element::f32, + {}, {{ -255.f, -255.f, -255.f, 0.f, 0.f, 0.f }}, {{ 0.005f, 0.005f, 0.005f, 0.01f, 0.01f, 0.01f }} }, 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 40424cefd8b..38a925a5235 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 @@ -43,8 +43,11 @@ public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize3; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations1; - ngraph::builder::subgraph::DequantizationOperations dequantizationOperations2; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2; }; inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationResultValues& values) { @@ -52,8 +55,8 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationRes values.fakeQuantize1 << "_" << values.fakeQuantize2 << "_" << values.fakeQuantize3 << "_" << - values.dequantizationOperations1 << "_" << - values.dequantizationOperations2; + values.dequantizationAfter1 << "_" << + values.dequantizationAfter2; } class ConcatTransformationTestValues { @@ -70,7 +73,6 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTes typedef std::tuple < ngraph::element::Type, - bool, ngraph::Shape, ConcatTransformationTestValues > ConcatTransformationParams; @@ -79,16 +81,8 @@ class ConcatWithNeighborsTransformation : public LayerTransformation, public tes public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); - const ngraph::Shape shape = std::get<2>(GetParam()); - ConcatTransformationTestValues testValues = std::get<3>(GetParam()); - - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - testValues.result.fakeQuantize3.outputPrecision = testValues.actual.fakeQuantize3.outputPrecision; - } + const ngraph::Shape shape = std::get<1>(GetParam()); + ConcatTransformationTestValues testValues = std::get<2>(GetParam()); actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithNeighbors( precision, @@ -111,21 +105,22 @@ public: testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, testValues.result.fakeQuantize3, - testValues.result.dequantizationOperations1, - testValues.result.dequantizationOperations2); + testValues.result.precisionBeforeOp, + testValues.result.dequantizationBefore, + testValues.result.precisionAfterOp, + testValues.result.dequantizationAfter1, + testValues.result.dequantizationAfter2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); - const ngraph::Shape shape = std::get<2>(obj.param); - const ConcatTransformationTestValues testValues = std::get<3>(obj.param); + const ngraph::Shape shape = std::get<1>(obj.param); + const ConcatTransformationTestValues testValues = std::get<2>(obj.param); std::ostringstream result; result << LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << "_" << (testValues.multiChannels ? "multiChannels_" : "notMultiChannels_") << - (updatePrecision ? "updatePrecision_" : "notUpdatePrecision_") << testValues.actual << "_" << testValues.result << "_"; return result.str(); @@ -143,8 +138,6 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { true, false }; - const std::vector testValues = { // U8: concat { @@ -156,9 +149,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 3.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {128.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {85.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {128.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {85.f} }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -173,9 +169,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 3.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, {{ 0.005f, 0.005f, 0.005f, 0.00333f, 0.00333f, 0.00333f }} } } @@ -190,9 +189,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {1.275f}, {2.55f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {{ 0.f, 0.f, 0.f, -255.f, -255.f, -255.f }}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, { -255.f }, { 0.005f } } } @@ -207,9 +209,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 3.f}, {1.27f / 3.f}, {-1.28f / 3.f}, {1.27f / 3.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64}, {64.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 3.f}, {1.27f / 3.f}, {-43}, {42.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64}, {64.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 3.f}, {1.27f / 3.f}, {-43}, {42.f} }, + ngraph::element::i8, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -224,9 +229,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 3.f}, {1.27f / 3.f}, {-1.28f / 3.f}, {1.27f / 3.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 3.f}, {1.27f / 3.f}, {-128.f}, {127.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 3.f}, {1.27f / 3.f}, {-128.f}, {127.f} }, + ngraph::element::i8, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, {{ 0.005f, 0.005f, 0.005f, 0.00333f, 0.00333f, 0.00333f }} } } @@ -241,13 +249,36 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f} }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {{ 0.f, 0.f, 0.f, 128.f, 128.f, 128.f }}, { 0.01f } }, { ngraph::element::f32, { 128.f }, { 0.01f } } } }, + // not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + true, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} } + }, + { + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f} }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {0.f}, {255.f} }, + ngraph::element::f32, + {{}, {}, {}}, + ngraph::element::f32, + { {}, {{ 0.f, 0.f, 0.f, 128.f, 128.f, 128.f }}, { 0.01f } }, + { {}, { 128.f }, { 0.01f } } + } + }, }; const std::vector shapes = { @@ -260,7 +291,6 @@ INSTANTIATE_TEST_CASE_P( ConcatWithNeighborsTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::ValuesIn(updatePrecisions), ::testing::ValuesIn(shapes), ::testing::ValuesIn(testValues)), ConcatWithNeighborsTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp index 80710523d70..2c51ee7d67a 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_reshape_at_the_end_transformation.cpp @@ -45,6 +45,8 @@ public: ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fakeQuantize2; ngraph::builder::subgraph::FakeQuantizeOnDataWithConstant fakeQuantize3; + ngraph::element::Type precisionBeforeOp; + ngraph::element::Type precisionAfterOp; ngraph::builder::subgraph::DequantizationOperations dequantizationOperations; }; @@ -65,7 +67,6 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTes typedef std::tuple < ngraph::element::Type, - bool, ngraph::Shape, ConcatTransformationTestValues > ConcatTransformationParams; @@ -74,16 +75,8 @@ class ConcatWithReshapeAtTheEndTransformation : public LayerTransformation, publ public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); - const ngraph::Shape shape = std::get<2>(GetParam()); - ConcatTransformationTestValues testValues = std::get<3>(GetParam()); - - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - testValues.result.fakeQuantize3.outputPrecision = testValues.actual.fakeQuantize3.outputPrecision; - } + const ngraph::Shape shape = std::get<1>(GetParam()); + ConcatTransformationTestValues testValues = std::get<2>(GetParam()); actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithReshapeAtTheEndTransformation( precision, @@ -98,30 +91,25 @@ public: transform.add(testValues.params); transform.transform(actualFunction); - if (!testValues.params.updatePrecisions) { - // there is no Convert operation after MaxPool in FP32 - testValues.result.dequantizationOperations.convert = {}; - } - referenceFunction = ngraph::builder::subgraph::ConcatFunction::getReferenceWithReshapeAtTheEndTransformation( precision, shape, testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, testValues.result.fakeQuantize3, + testValues.result.precisionBeforeOp, + testValues.result.precisionAfterOp, testValues.result.dequantizationOperations); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); - const ngraph::Shape shape = std::get<2>(obj.param); - const ConcatTransformationTestValues testValues = std::get<3>(obj.param); + const ngraph::Shape shape = std::get<1>(obj.param); + const ConcatTransformationTestValues testValues = std::get<2>(obj.param); std::ostringstream result; result << LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << "_" << - (updatePrecision ? "updatePrecision_" : "notUpdatePrecision_") << testValues.actual << "_" << testValues.result << "_"; return result.str(); @@ -138,8 +126,6 @@ const std::vector precisions = { ngraph::element::f32, }; -const std::vector updatePrecisions = { true, false }; - const std::vector testValues = { { LayerTransformation::createParamsU8I8(), @@ -149,12 +135,30 @@ const std::vector testValues = { { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} }, }, { - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::u8, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } } } }, + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + { + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {2.55f} }, + }, + { + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + { 256ul, {}, {0.f}, {2.55f}, {0.f}, {255.f} }, + ngraph::element::f32, + ngraph::element::f32, + { {}, {}, { 0.01f } } + } + }, { LayerTransformation::createParamsU8I8(), { @@ -178,20 +182,20 @@ const std::vector testValues = { { 256ul, {{1, 3, 1, 1}, {1, 3, 1, 1}, {}, {}}, - {0.f, 0.f, 0.f}, {2.55f / 1.f, 2.55f / 2.f, 2.55f / 3.f}, {0.f}, {255.f}, ngraph::element::u8 + {0.f, 0.f, 0.f}, {2.55f / 1.f, 2.55f / 2.f, 2.55f / 3.f}, {0.f}, {255.f} }, { 256ul, {{1, 3, 1, 1}, {1, 3, 1, 1}, {}, {}}, - {0.f, 0.f, 0.f}, {2.55f / 1.f, 2.55f / 2.f, 2.55f / 3.f}, {0.f}, {255.f}, - ngraph::element::u8 + {0.f, 0.f, 0.f}, {2.55f / 1.f, 2.55f / 2.f, 2.55f / 3.f}, {0.f}, {255.f} }, { 256ul, {{1, 3, 1, 1}, {1, 3, 1, 1}, {}, {}}, - {0.f, 0.f, 0.f}, {2.55f / 1.f, 2.55f / 2.f, 2.55f / 3.f}, {0.f}, {255.f}, - ngraph::element::u8 + {0.f, 0.f, 0.f}, {2.55f / 1.f, 2.55f / 2.f, 2.55f / 3.f}, {0.f}, {255.f} }, + ngraph::element::u8, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f / 2.f, 0.01f / 3.f, 0.01f, 0.01f / 2.f, 0.01f / 3.f, 0.01f, 0.01f / 2.f, 0.01f / 3.f }} } } } @@ -207,7 +211,6 @@ INSTANTIATE_TEST_CASE_P( ConcatWithReshapeAtTheEndTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::ValuesIn(updatePrecisions), ::testing::ValuesIn(shapes), ::testing::ValuesIn(testValues)), ConcatWithReshapeAtTheEndTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp index 324e59a0e88..05962a7a09f 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/concat_with_split_transformation.cpp @@ -43,6 +43,10 @@ class ConcatTransformationResultValues { public: ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize1; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize2; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore1; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore2; + ngraph::element::Type precisionAfterOperation; ngraph::builder::subgraph::DequantizationOperations dequantizationOperations1; ngraph::builder::subgraph::DequantizationOperations dequantizationOperations2; }; @@ -70,7 +74,6 @@ inline std::ostream& operator<<(std::ostream& out, const ConcatTransformationTes typedef std::tuple < ngraph::element::Type, - bool, ConcatTransformationTestValues > ConcatTransformationParams; @@ -78,14 +81,7 @@ class ConcatWithSplitTransformation : public LayerTransformation, public testing public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); - const bool updatePrecisions = std::get<1>(GetParam()); - ConcatTransformationTestValues testValues = std::get<2>(GetParam()); - - testValues.params.updatePrecisions = updatePrecisions; - if (!updatePrecisions) { - testValues.result.fakeQuantize1.outputPrecision = testValues.actual.fakeQuantize1.outputPrecision; - testValues.result.fakeQuantize2.outputPrecision = testValues.actual.fakeQuantize2.outputPrecision; - } + ConcatTransformationTestValues testValues = std::get<1>(GetParam()); actualFunction = ngraph::builder::subgraph::ConcatFunction::getOriginalWithSplitedIntermediate( precision, @@ -107,20 +103,22 @@ public: testValues.inputShape, testValues.result.fakeQuantize1, testValues.result.fakeQuantize2, + testValues.result.precisionBeforeOp, + testValues.result.dequantizationBefore1, + testValues.result.dequantizationBefore2, + testValues.result.precisionAfterOperation, testValues.result.dequantizationOperations1, testValues.result.dequantizationOperations2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); - const bool updatePrecision = std::get<1>(obj.param); - const ConcatTransformationTestValues testValues = std::get<2>(obj.param); + const ConcatTransformationTestValues testValues = std::get<1>(obj.param); std::ostringstream result; result << LayerTransformation::getTestCaseNameByParams(precision, testValues.inputShape, testValues.params) << "_" << (testValues.multiChannels ? "multiChannels_" : "notMultiChannels_") << - (updatePrecision ? "updatePrecision_" : "notUpdatePrecision_") << testValues.actual << "_" << testValues.result << "_"; return result.str(); @@ -128,8 +126,6 @@ public: }; TEST_P(ConcatWithSplitTransformation, CompareFunctions) { - const ConcatTransformationTestValues testValues = std::get<2>(GetParam()); - actualFunction->validate_nodes_and_infer_types(); auto res = compare_functions(referenceFunction, actualFunction, true); ASSERT_TRUE(res.first) << res.second; @@ -140,8 +136,6 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { true, false }; - const std::vector testValues = { // U8: concat { @@ -153,8 +147,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}}, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 128.f}}, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -169,8 +167,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}}, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-64.f}, { 64.f}}, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -185,8 +187,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {1.275f}, {2.55f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {128.f}, {255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}}, + { 256ul, ngraph::Shape({}), {1.275f}, {2.55f}, {128.f}, {255.f}}, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.01f } }, { ngraph::element::f32, {}, { 0.01f } } } @@ -201,8 +207,12 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, {2.55f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}, ngraph::element::u8 }, - { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f}, ngraph::element::u8 }, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {255.f}}, + { 256ul, ngraph::Shape({}), {0.f}, {2.55f / 2.f}, {0.f}, { 255.f}}, + ngraph::element::u8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::u8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, { 0.005f } } } @@ -217,21 +227,44 @@ const std::vector testValues = { { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } }, { - { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}, ngraph::element::i8 }, - { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f}, ngraph::element::i8 }, + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}}, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f}}, + ngraph::element::i8, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::i8, { ngraph::element::f32, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, { ngraph::element::f32, {}, { 0.005f } } } }, + // not update precisions + { + { 1, 6, 10, 10 }, + LayerTransformation::createParamsI8I8().setUpdatePrecisions(false), + true, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-1.28f}, {1.27f} }, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-1.28f / 2.f}, {1.27f / 2.f} } + }, + { + { 256ul, ngraph::Shape({}), {-1.28f}, {1.27f}, {-128.f}, {127.f}}, + { 256ul, ngraph::Shape({}), {-1.28f / 2.f}, {1.27f / 2.f}, {-128.f}, {127.f}}, + ngraph::element::f32, + {{}, {}, {}}, + {{}, {}, {}}, + ngraph::element::f32, + { {}, {}, {{ 0.01f, 0.01f, 0.01f, 0.005f, 0.005f, 0.005f }} }, + { {}, {}, { 0.005f } } + } + }, }; // TODO: Split/VariadicSplit operations are not supported in ConcatTransformation INSTANTIATE_TEST_CASE_P( - DISABLED_LPT, + DISABLED_smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::ValuesIn(updatePrecisions), ::testing::ValuesIn(testValues)), ConcatWithSplitTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp index 464cae1db93..6d880a3ecb2 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/depth_to_space_transformation.cpp @@ -34,6 +34,7 @@ public: public: ngraph::element::Type precisionBeforeDequantization; ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOperation; ngraph::builder::subgraph::DequantizationOperations dequantizationAfter; }; @@ -68,6 +69,7 @@ public: testValues.blockSize, testValues.expected.precisionBeforeDequantization, testValues.expected.dequantizationBefore, + testValues.expected.precisionAfterOperation, testValues.expected.dequantizationAfter); } @@ -110,6 +112,7 @@ const std::vector testValues = { { ngraph::element::u8, {{}, {}, {}}, + ngraph::element::u8, {{ngraph::element::f32}, {0.32f}, {0.45f}} } }, @@ -126,6 +129,7 @@ const std::vector testValues = { { ngraph::element::u8, {{}, {}, {}}, + ngraph::element::u8, {{ngraph::element::f32}, {0.32f}, {0.45f}} } }, @@ -142,10 +146,11 @@ const std::vector testValues = { { ngraph::element::u8, {{}, {}, {}}, + ngraph::element::u8, {{ngraph::element::f32}, {0.32f}, {0.45f}} } }, - // not scalar-like dequantizations + // not scalar-like dequantizations with different values { ngraph::Shape{ 1, 4, 3, 3 }, DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, @@ -166,9 +171,56 @@ const std::vector testValues = { {{0.32f, 0.5f, 0.6f, 0.77f}}, {{0.1f, 0.55f, 0.3f, 0.8f}} }, + ngraph::element::f32, + { {}, {}, {}} + } + }, + // not scalar-like dequantizations with the same values + { + ngraph::Shape{ 1, 4, 3, 3 }, + DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, + 2, + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + { + {ngraph::element::f32}, + {{0.32f, 0.32f, 0.32f, 0.32f}}, + {{0.1f, 0.1f, 0.1f, 0.1f}} + } + }, + { + ngraph::element::u8, + { {}, {}, {}}, + ngraph::element::u8, + { + {ngraph::element::f32}, + {{0.32f, 0.32f, 0.32f, 0.32f}}, + {{0.1f, 0.1f, 0.1f, 0.1f}} + } + } + }, + // without dequantization + { + ngraph::Shape{ 1, 4, 3, 3 }, + DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, + 2, + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + {} + }, + { + ngraph::element::u8, + { {}, {}, {}}, + ngraph::element::u8, { {}, {}, {}} } }, }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, DepthToSpaceTransformation, ::testing::ValuesIn(testValues), DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_CASE_P( + smoke_LPT, + DepthToSpaceTransformation, + ::testing::ValuesIn(testValues), + DepthToSpaceTransformation::getTestCaseName); 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 32c5aa348dc..462f57d7f3a 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 @@ -18,6 +18,7 @@ #include "lpt_ngraph_functions/common/fake_quantize_on_data.hpp" #include "lpt_ngraph_functions/common/fake_quantize_on_weights.hpp" +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" #include "lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp" #include "simple_low_precision_transformer.hpp" @@ -28,35 +29,33 @@ using namespace ngraph::pass; class FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues { public: + class ActualValues { + public: + ngraph::builder::subgraph::FakeQuantizeOnData fqOnData; + ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights1; + ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights2; + }; + + class ExpectedValues { + public: + ngraph::builder::subgraph::FakeQuantizeOnData fqOnData; + ngraph::element::Type precisionBeforeOp; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOp; + ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights1; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter1; + ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights2; + ngraph::builder::subgraph::DequantizationOperations dequantizationAfter2; + }; + low_precision::LayerTransformation::Params params; - ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ActualValues actual; - ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ExpectedValues expected; + ActualValues actual; + ExpectedValues expected; }; -inline std::ostream& operator<<(std::ostream& os, const std::vector& values) { - os << "{ "; - for (size_t i = 0; i < values.size(); ++i) { - os << values[i]; - if (i != (values.size() - 1ul)) { - os << ", "; - } - } - os << " }"; - return os; -} - -inline std::ostream& operator<<(std::ostream& out, const FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues& testValue) { - return out << "_" << - testValue.params.precisionsOnActivations[0] << "_" << - testValue.actual.fqOnData << "_" << - testValue.actual.fqOnWeights1 << "_" << - testValue.actual.fqOnWeights2; -} - typedef std::tuple< ngraph::element::Type, ngraph::Shape, - bool, FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues> FakeQuantizeAndTwoOutputBranchesWithConvolutionParams; class FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation : @@ -66,39 +65,41 @@ public: void SetUp() override { const ngraph::element::Type precision = std::get<0>(GetParam()); const ngraph::Shape shape = std::get<1>(GetParam()); - const bool updatePrecision = std::get<2>(GetParam()); - const FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues testValues = std::get<3>(GetParam()); - - const low_precision::LayerTransformation::Params params = low_precision::LayerTransformation::Params(testValues.params). - setUpdatePrecisions(updatePrecision); + const FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues testValues = std::get<2>(GetParam()); actualFunction = ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getOriginal( precision, shape, - testValues.actual); + testValues.actual.fqOnData, + testValues.actual.fqOnWeights1, + testValues.actual.fqOnWeights2); SimpleLowPrecisionTransformer transform; - transform.add(params); - transform.add(params); + transform.add(testValues.params); + transform.add(testValues.params); transform.transform(actualFunction); referenceFunction = ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getReference( precision, shape, - params, - testValues.expected); + testValues.params, + testValues.expected.fqOnData, + testValues.expected.precisionBeforeOp, + testValues.expected.dequantizationBefore, + testValues.expected.precisionAfterOp, + testValues.expected.dequantizationAfter1, + testValues.expected.dequantizationAfter2); } static std::string getTestCaseName(testing::TestParamInfo obj) { const ngraph::element::Type precision = std::get<0>(obj.param); const ngraph::Shape shape = std::get<1>(obj.param); - const bool updatePrecision = std::get<2>(obj.param); - const FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues testValues = std::get<3>(obj.param); + const FakeQuantizeAndTwoOutputBranchesWithConvolutionTestValues testValues = std::get<2>(obj.param); std::ostringstream result; - result << LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << - (updatePrecision ? "" : "_notUpdatePrecision_") << - testValues; + result << LayerTransformation::getTestCaseNameByParams(precision, shape, testValues.params) << "_" + << testValues.expected.fqOnData << "_" << testValues.expected.dequantizationAfter1 << "_" + << testValues.expected.dequantizationAfter2; return result.str(); } }; @@ -114,11 +115,6 @@ const std::vector precisions = { // ngraph::element::f16 }; -const std::vector updatePrecisions = { - true, - false -}; - const std::vector fakeQuantizeOnDataTestValues = { // U8 { @@ -130,10 +126,32 @@ const std::vector fak }, { { 256ul, {}, { 0.f }, { 2.55f }, { 0.f }, { 2.55f } }, + ngraph::element::u8, + {{}, {}, {}}, + ngraph::element::f32, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, - { 1.f }, + {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1 }}}, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, - { 1.f } + {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1 }}}, + } + }, + // not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + { + { 256ul, {}, { 0.f }, { 2.55f }, { 0.f }, { 2.55f } }, + { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + }, + { + { 256ul, {}, { 0.f }, { 2.55f }, { 0.f }, { 2.55f } }, + ngraph::element::f32, + {{}, {}, {}}, + ngraph::element::f32, + { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1 }}}, + { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, + {{}, {}, {{ 1.f }, ngraph::element::f32, { 1, 1, 1 }}}, } } }; @@ -149,6 +167,5 @@ INSTANTIATE_TEST_CASE_P( ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::ValuesIn(shapes), - ::testing::ValuesIn(updatePrecisions), ::testing::ValuesIn(fakeQuantizeOnDataTestValues)), FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp index 0373723f1ff..f05bf5ed704 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/fake_quantize_transformation.cpp @@ -15,26 +15,23 @@ #include #include "common_test_utils/ngraph_test_utils.hpp" + #include "lpt_ngraph_functions/fake_quantize_function.hpp" +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" + #include "simple_low_precision_transformer.hpp" using namespace testing; using namespace ngraph; using namespace ngraph::pass; -class ExpectedValues { -public: - std::vector subtract; - std::vector multiply; -}; - class FakeQuantizeTransformationTestValues { public: low_precision::LayerTransformation::Params params; builder::subgraph::FakeQuantizeOnData actual; builder::subgraph::FakeQuantizeOnData expected; ngraph::element::Type expectedFakeQuantizeOnDataPrecision; - std::map expectedValues; + std::map expectedValues; }; inline std::ostream& operator<<(std::ostream& os, const std::vector& values) { @@ -87,8 +84,7 @@ public: params.updatePrecisions, fakeQuantizeOnData.expected, fakeQuantizeOnData.expectedFakeQuantizeOnDataPrecision, - fakeQuantizeOnData.expectedValues.find(element::f32)->second.subtract, - fakeQuantizeOnData.expectedValues.find(element::f32)->second.multiply); + fakeQuantizeOnData.expectedValues.find(element::f32)->second); } static std::string getTestCaseName(testing::TestParamInfo obj) { @@ -128,8 +124,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { 0.f }, { 2.55f }, { 0.f }, { 255.f } }, ngraph::element::u8, { - { ngraph::element::f32, { {}, { 0.01f }} }, - { ngraph::element::f16, { {}, { 0.01f }} } + { ngraph::element::f32, { {ngraph::element::f32}, {}, { 0.01f }} }, + { ngraph::element::f16, { {ngraph::element::f16}, {}, { 0.01f }} } } }, { @@ -138,8 +134,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { -1.23f }, { 2.55f }, { 0.f }, { 255.f } }, ngraph::element::u8, { - { ngraph::element::f32, {{ 82.97619048f }, { 0.014823529f }} }, - { ngraph::element::f16, {{ 83.f }, { 0.014823529f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { 82.97619048f }, { 0.014823529f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { 83.f }, { 0.014823529f }} } } }, { @@ -148,8 +144,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { -1.28f} , { 1.27f }, { 0.f }, { 255.f } }, ngraph::element::u8, { - { ngraph::element::f32, {{ 128.f }, { 0.01f }} }, - { ngraph::element::f16, {{ 128.f }, { 0.01f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { 128.f }, { 0.01f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { 128.f }, { 0.01f }} } } }, @@ -160,8 +156,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { -1.28f}, { 1.27f }, { -128.f}, { 127.f } }, ngraph::element::i8, { - { ngraph::element::f32, {{ }, { 0.01f }} }, - { ngraph::element::f16, {{ }, { 0.01f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { }, { 0.01f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { }, { 0.01f }} } } }, { @@ -170,8 +166,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { -0.12f}, { 1.27f }, { -128.f}, { 127.f } }, ngraph::element::i8, { - { ngraph::element::f32, {{ -105.9856115f }, { 0.00545098f }} }, - { ngraph::element::f16, {{ -105.9856115f }, { 0.00545098f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { -105.9856115f }, { 0.00545098f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { -105.9856115f }, { 0.00545098f }} } } }, { @@ -180,8 +176,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { 0.f }, { 2.55f }, { -128.f }, { 127.f } }, ngraph::element::i8, { - { ngraph::element::f32, {{ -128.f }, { 0.01f }} }, - { ngraph::element::f16, {{ -128.f }, { 0.01f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { -128.f }, { 0.01f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { -128.f }, { 0.01f }} } } }, @@ -192,7 +188,7 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { 0.f }, { 2.55f }, { 1.f }, { 1.f } }, ngraph::element::Type_t::i8, { - { ngraph::element::f32, {{}, { 2.55f }} } + { ngraph::element::f32, {{ngraph::element::f32}, {}, { 2.55f }} } } }, @@ -204,8 +200,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { -0.504395f }, { 0.5f }, { -128.f }, { 127.f } }, ngraph::element::i8, { - { ngraph::element::f32, {{ }, { -0.504395f / -128.0f }} }, - { ngraph::element::f16, {{ }, { -0.504395f / -128.0f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { }, { -0.504395f / -128.0f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { }, { -0.504395f / -128.0f }} } } }, @@ -216,8 +212,8 @@ const std::vector fakeQuantizeTransformati { 256ul, {}, { 0.f }, { 25.5f }, { 0.f }, { 255.f } }, ngraph::element::u8, { - { ngraph::element::f32, {{ }, { 1e-32f }} }, - { ngraph::element::f16, {{ }, { 1e-32f }} } + { ngraph::element::f32, {{ngraph::element::f32}, { }, { 1e-32f }} }, + { ngraph::element::f16, {{ngraph::element::f16}, { }, { 1e-32f }} } } } }; diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/low_precision_transformations_test.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/low_precision_transformations_test.cpp index 2189ae3c9e3..89e994e426c 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/low_precision_transformations_test.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/low_precision_transformations_test.cpp @@ -5,48 +5,65 @@ #include #include "low_precision/transformer.hpp" +#include "low_precision/concat_multi_channels.hpp" +#include "low_precision/convolution.hpp" +#include "low_precision/mat_mul.hpp" +#include "low_precision/fuse_convert.hpp" +#include "low_precision/subtract_multiply_to_multiply_add.hpp" + using namespace ::testing; using namespace ngraph::pass::low_precision; class LowPrecisionTransformationsTests : public Test {}; -TEST_F(LowPrecisionTransformationsTests, remove) { +TEST_F(LowPrecisionTransformationsTests, removeAll) { LowPrecisionTransformations transformations = LowPrecisionTransformer::getAllTransformations(LayerTransformation::Params()); auto transformation = transformations.find("Convolution"); ASSERT_NE(0, transformation.size()); - transformations.remove("Convolution"); + transformations.removeAll(); transformation = transformations.find("Convolution"); ASSERT_EQ(0, transformation.size()); } -TEST_F(LowPrecisionTransformationsTests, removeBranchSpecificTransformations) { +TEST_F(LowPrecisionTransformationsTests, removeBranchSpecific) { LowPrecisionTransformations transformations = LowPrecisionTransformer::getAllTransformations(LayerTransformation::Params()); auto transformation = transformations.find("Concat"); ASSERT_NE(0, transformation.size()); - transformations.removeBranchSpecificTransformations("Concat"); + transformations.removeBranchSpecific(); transformation = transformations.find("Concat"); ASSERT_EQ(0, transformation.size()); } -TEST_F(LowPrecisionTransformationsTests, removeTransformations) { +TEST_F(LowPrecisionTransformationsTests, remove) { LowPrecisionTransformations transformations = LowPrecisionTransformer::getAllTransformations(LayerTransformation::Params()); auto transformation = transformations.find("MatMul"); ASSERT_NE(0, transformation.size()); - transformations.removeTransformations("MatMul"); + transformations.remove(); transformation = transformations.find("MatMul"); ASSERT_EQ(0, transformation.size()); } -TEST_F(LowPrecisionTransformationsTests, removeCleanupTransformations) { +TEST_F(LowPrecisionTransformationsTests, removeCleanup) { LowPrecisionTransformations transformations = LowPrecisionTransformer::getAllTransformations(LayerTransformation::Params()); auto transformation = transformations.find("Multiply"); ASSERT_NE(0, transformation.size()); const size_t originalSize = transformation.size(); - transformations.removeCleanupTransformations("Multiply"); + transformations.removeCleanup(); + transformation = transformations.find("Multiply"); + ASSERT_EQ(originalSize - 1, transformation.size()); +} + +TEST_F(LowPrecisionTransformationsTests, removeStandaloneCleanup) { + LowPrecisionTransformations transformations = LowPrecisionTransformer::getAllTransformations(LayerTransformation::Params()); + auto transformation = transformations.find("Multiply"); + ASSERT_NE(0, transformation.size()); + const size_t originalSize = transformation.size(); + + transformations.removeStandaloneCleanup(); transformation = transformations.find("Multiply"); ASSERT_EQ(originalSize - 1, transformation.size()); } diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp index 6bba63856b3..8f0efa0a00a 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/max_pool_transformation.cpp @@ -29,6 +29,7 @@ public: public: ngraph::element::Type precisionBeforeDequantization; ngraph::builder::subgraph::DequantizationOperations dequantization1; + ngraph::element::Type preicsionAfterOperation; ngraph::builder::subgraph::DequantizationOperations dequantization2; }; @@ -36,6 +37,7 @@ public: public: ngraph::element::Type precisionBeforeDequantization; ngraph::builder::subgraph::DequantizationOperations dequantization1; + ngraph::element::Type preicsionAfterOperation; ngraph::builder::subgraph::DequantizationOperations dequantization2; }; @@ -58,6 +60,7 @@ public: shape, testValues.actual.precisionBeforeDequantization, testValues.actual.dequantization1, + testValues.actual.preicsionAfterOperation, testValues.actual.dequantization2); SimpleLowPrecisionTransformer transform; @@ -68,6 +71,7 @@ public: shape, testValues.expected.precisionBeforeDequantization, testValues.expected.dequantization1, + testValues.expected.preicsionAfterOperation, testValues.expected.dequantization2); } @@ -104,11 +108,13 @@ const std::vector testValues = { { ngraph::element::u8, { {}, {}, { {0.02f}, ngraph::element::f32, {}, true, 1, ngraph::element::f32 }}, + ngraph::element::f32, {} }, { ngraph::element::u8, {}, + ngraph::element::u8, { ngraph::element::f32, {}, { {0.02f}, ngraph::element::f32, {}, true, 1, ngraph::element::f32 }} } }, @@ -122,11 +128,13 @@ const std::vector testValues = { { {128.f}, ngraph::element::f32, {}, true, 1, ngraph::element::f32 }, { {0.02f}, ngraph::element::f32, {}, true, 1, ngraph::element::f32 } }, + ngraph::element::f32, {} }, { ngraph::element::u8, {}, + ngraph::element::u8, { ngraph::element::f32, { {128.f}, ngraph::element::f32, {}, true, 1, ngraph::element::f32 }, @@ -140,11 +148,13 @@ const std::vector testValues = { { ngraph::element::u8, { ngraph::element::f32, { 128 }, { 0.02f }}, + ngraph::element::f32, {} }, { ngraph::element::u8, {}, + ngraph::element::u8, { ngraph::element::f32, { 128 }, { 0.02f }} } }, @@ -154,11 +164,13 @@ const std::vector testValues = { { ngraph::element::u8, { ngraph::element::f32, {}, { 0.02f }}, + ngraph::element::f32, {} }, { ngraph::element::u8, {}, + ngraph::element::u8, { ngraph::element::f32, {}, { 0.02f }} } }, @@ -166,28 +178,32 @@ const std::vector testValues = { { LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), { - ngraph::element::u8, + ngraph::element::f32, { ngraph::element::f32, { 128 }, { 0.02f }}, + ngraph::element::f32, {} }, { - ngraph::element::u8, + ngraph::element::f32, {}, - { ngraph::element::f32, { 128 }, { 0.02f }} + ngraph::element::f32, + { {}, { 128 }, { 0.02f }} } }, // Convert + Subtract + Multiply { LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), { - ngraph::element::u8, + ngraph::element::f32, { ngraph::element::f32, {}, { 0.02f }}, + ngraph::element::f32, {} }, { - ngraph::element::u8, + ngraph::element::f32, {}, - { ngraph::element::f32, {}, { 0.02f }} + ngraph::element::f32, + { {}, {}, { 0.02f }} } } }; diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp index 4648aa6e85d..a8418ec771d 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/normalize_l2_transformation.cpp @@ -15,7 +15,9 @@ #include #include "common_test_utils/ngraph_test_utils.hpp" + #include "lpt_ngraph_functions/normalize_l2_function.hpp" +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" using namespace testing; using namespace ngraph::pass; @@ -23,60 +25,72 @@ using namespace ngraph::builder::subgraph; class NormalizeL2TransformationTestValues { public: + class Actual { + public: + ngraph::element::Type inputPrecision; + DequantizationOperations dequantization; + }; + class Expected { + public: + ngraph::element::Type inputPrecision; + DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOperation; + DequantizationOperations dequantizationAfter; + }; low_precision::LayerTransformation::Params transformationParams; - - NormalizeL2ActualValues actual; - NormalizeL2ExpectedValues expected; + Actual actual; + Expected expected; }; typedef std::tuple< - ngraph::element::Type, ngraph::Shape, ngraph::op::EpsMode, + std::vector, NormalizeL2TransformationTestValues> NormalizeL2TransformationParams; class NormalizeL2Transformation : public LayerTransformation, public testing::WithParamInterface { public: void SetUp() override { - const ngraph::element::Type precision = std::get<0>(GetParam()); - const ngraph::Shape shape = std::get<1>(GetParam()); - const ngraph::op::EpsMode epsMode = std::get<2>(GetParam()); - const NormalizeL2TransformationTestValues params = std::get<3>(GetParam()); + ngraph::Shape shape; + ngraph::op::EpsMode epsMode; + std::vector axes; + NormalizeL2TransformationTestValues params; + std::tie(shape, epsMode, axes, params) = GetParam(); actualFunction = ngraph::builder::subgraph::NormalizeL2Function::getOriginal( - precision, + params.actual.inputPrecision, shape, epsMode, - params.actual); + axes, + params.actual.dequantization); + SimpleLowPrecisionTransformer transform; transform.add( low_precision::LayerTransformation::Params(params.transformationParams)); transform.transform(actualFunction); - referenceFunction = !params.expected.subtractValues.empty() ? - ngraph::builder::subgraph::NormalizeL2Function::getOriginal( - precision, - shape, - epsMode, - params.actual) : - ngraph::builder::subgraph::NormalizeL2Function::getReference( - precision, - shape, - epsMode, - params.expected); + referenceFunction = ngraph::builder::subgraph::NormalizeL2Function::getReference( + params.expected.inputPrecision, + shape, + epsMode, + axes, + params.expected.dequantizationBefore, + params.expected.precisionAfterOperation, + params.expected.dequantizationAfter); } static std::string getTestCaseName(testing::TestParamInfo obj) { - ngraph::element::Type precision; ngraph::Shape shape; ngraph::Shape axes; ngraph::op::EpsMode epsMode; NormalizeL2TransformationTestValues params; - std::tie(precision, shape, epsMode, params) = obj.param; + std::tie(shape, epsMode, axes, params) = obj.param; std::ostringstream result; - result << toString(params.transformationParams) << precision << "_" << shape << "_" << - axes << epsMode << params.actual << params.expected; + result << + toString(params.transformationParams) << shape << "_" << + axes << "_" << epsMode << "_" << params.actual.inputPrecision << "_" << + params.actual.dequantization; return result.str(); } }; @@ -87,13 +101,8 @@ TEST_P(NormalizeL2Transformation, CompareFunctions) { ASSERT_TRUE(res.first) << res.second; } -const std::vector precisions = { - ngraph::element::f32, - // ngraph::element::f16 -}; - const std::vector shapes = { - { 1, 4, 16, 16 } + { 1, 3, 16, 16 } }; std::vector epsMode = { @@ -101,37 +110,151 @@ std::vector epsMode = { ngraph::op::EpsMode::MAX }; +std::vector> axes = { + { 1 }, + { 1, 2, 3 } +}; + const std::vector normalizeL2TransformationTestValues = { - { - LayerTransformation::createParamsU8I8().setSupportAsymmetricQuantization(false), - { ngraph::element::u8, { 1 }, { 2.f }, { -12.3f, -12.3f, -12.3f, -12.3f }}, - { ngraph::element::u8, { 1 }, { 2.f }, { -1.f, -1.f, -1.f, -1.f}} - }, - - // U8 + // U8 per tensor quantization { LayerTransformation::createParamsU8I8(), - { ngraph::element::u8, { 1 }, { 2.f }, { -12.3f, -12.3f, -12.3f, -12.3f }}, - { ngraph::element::u8, { 1 }, { 2.f }, { -1.f, -1.f, -1.f, -1.f}} + { + ngraph::element::u8, + {{ngraph::element::f32}, {2.f}, {-12.3f}} + }, + { + ngraph::element::u8, + {{ngraph::element::f32}, {2.f}, {-12.3f}}, + ngraph::element::f32, + {} + } }, - + // U8 per tensor quantization without subtract { LayerTransformation::createParamsU8I8(), - { ngraph::element::u8, { 1, 2, 3 }, { }, { 12.3f }}, - { ngraph::element::u8, { 1, 2, 3 }, { }, { 1.f }} + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, {-12.3f}} + }, + { + ngraph::element::u8, + {}, + ngraph::element::f32, + {{}, {}, {-1.f}} + } }, - - // I8 + // U8 per channel quantization with the same values + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, {{12.3f, 12.3f, 12.3f}}} + }, + { + ngraph::element::u8, + {}, + ngraph::element::f32, + {{}, {}, {{1.f, 1.f, 1.f}}} + } + }, + // U8 per channel quantization with different values + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, {{12.3f, -12.3f, 12.3f}}} + }, + { + ngraph::element::u8, + {{ngraph::element::f32}, {}, {{12.3f, -12.3f, 12.3f}}}, + ngraph::element::f32, + {} + } + }, + // U8 not update precisions + { + LayerTransformation::createParamsU8I8().setUpdatePrecisions(false), + { + ngraph::element::f32, + {{}, {}, {12.3f}} + }, + { + ngraph::element::f32, + {}, + ngraph::element::f32, + {{}, {}, {1.f}} + } + }, + // U8 without dequantization + { + LayerTransformation::createParamsU8I8(), + { + ngraph::element::f32, + {} + }, + { + ngraph::element::f32, + {}, + ngraph::element::f32, + {} + } + }, + // I8 per tensor quantization { LayerTransformation::createParamsI8I8(), - { ngraph::element::i8, { 1 }, { 2.f }, { -12.3f, -12.3f, -12.3f, -12.3f }}, - { ngraph::element::i8, { 1 }, { 2.f }, { -1.f, -1.f, -1.f, -1.f}} + { + ngraph::element::i8, + {{ngraph::element::f32}, {2.f}, {-12.3f}} + }, + { + ngraph::element::i8, + {{ngraph::element::f32}, {2.f}, {-12.3f}}, + ngraph::element::f32, + {} + } }, - + // I8 per tensor quantization without subtract { LayerTransformation::createParamsI8I8(), - { ngraph::element::i8, { 1, 2, 3 }, { }, { 12.3f }}, - { ngraph::element::i8, { 1, 2, 3 }, { }, { 1.f }} + { + ngraph::element::i8, + {{ngraph::element::f32}, {}, {-12.3f}} + }, + { + ngraph::element::i8, + {}, + ngraph::element::f32, + {{}, {}, {-1.f}} + } + }, + // I8 per channel quantization with the same values + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + {{ngraph::element::f32}, {}, {{12.3f, 12.3f, 12.3f}}} + }, + { + ngraph::element::i8, + {}, + ngraph::element::f32, + {{}, {}, {{1.f, 1.f, 1.f}}} + } + }, + // I8 per channel quantization with different values + { + LayerTransformation::createParamsI8I8(), + { + ngraph::element::i8, + {{ngraph::element::f32}, {}, {{12.3f, -12.3f, 12.3f}}} + }, + { + ngraph::element::i8, + {{ngraph::element::f32}, {}, {{12.3f, -12.3f, 12.3f}}}, + ngraph::element::f32, + {} + } }, }; @@ -139,8 +262,8 @@ INSTANTIATE_TEST_CASE_P( smoke_LPT, NormalizeL2Transformation, ::testing::Combine( - ::testing::ValuesIn(precisions), ::testing::ValuesIn(shapes), ::testing::ValuesIn(epsMode), + ::testing::ValuesIn(axes), ::testing::ValuesIn(normalizeL2TransformationTestValues)), NormalizeL2Transformation::getTestCaseName); diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp index e25e7ee506f..4282d18f563 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/split_transformation.cpp @@ -30,7 +30,9 @@ public: class Expected { public: - ngraph::element::Type precision; + ngraph::element::Type inputPrecision; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOperation; std::vector dequantizationAfter; }; @@ -73,7 +75,9 @@ public: referenceFunction = ngraph::builder::subgraph::SplitFunction::getReference( testValues.inputShape, - testValues.expected.precision, + testValues.expected.inputPrecision, + testValues.expected.dequantizationBefore, + testValues.expected.precisionAfterOperation, testValues.expected.dequantizationAfter, testValues.splitedAxis, testValues.numSplits); @@ -114,6 +118,8 @@ const std::vector testValues = { }, // ExpectedValues { + ngraph::element::u8, + {}, ngraph::element::u8, { {{ngraph::element::f32}, {128.f}, {3.f}}, @@ -131,6 +137,8 @@ const std::vector testValues = { }, { ngraph::element::i8, + {}, + ngraph::element::u8, { {{ngraph::element::f32}, {128.f}, {3.f}}, {{ngraph::element::f32}, {128.f}, {3.f}}, @@ -148,6 +156,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -179,6 +189,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -210,6 +222,8 @@ const std::vector testValues = { {{11.f, 11.f, 11.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -241,6 +255,8 @@ const std::vector testValues = { {{11.f, 11.f, 11.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -272,6 +288,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -303,6 +321,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -334,6 +354,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -365,6 +387,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -396,6 +420,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f, 44.f}, ngraph::element::f32, {1, 4, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -422,6 +448,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f, 44.f}, ngraph::element::f32, {1, 4, 1, 1}}} }, { + ngraph::element::f32, + {}, ngraph::element::f32, { { diff --git a/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp index cc686f5320b..c114ac0e090 100644 --- a/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/inference_engine/lp_transformations/variadic_split_transformation.cpp @@ -30,7 +30,9 @@ public: class Expected { public: - ngraph::element::Type precision; + ngraph::element::Type inputPrecision; + ngraph::builder::subgraph::DequantizationOperations dequantizationBefore; + ngraph::element::Type precisionAfterOperation; std::vector dequantizationAfter; }; @@ -86,7 +88,9 @@ public: referenceFunction = ngraph::builder::subgraph::VariadicSplitFunction::getReference( testValues.inputShape, - testValues.expected.precision, + testValues.expected.inputPrecision, + testValues.expected.dequantizationBefore, + testValues.expected.precisionAfterOperation, testValues.expected.dequantizationAfter, testValues.axis, testValues.splitLengths); @@ -126,6 +130,8 @@ const std::vector testValues = { }, // ExpectedValues { + ngraph::element::u8, + {}, ngraph::element::u8, { {{ngraph::element::f32}, {128.f}, {3.f}}, @@ -142,6 +148,8 @@ const std::vector testValues = { {{ngraph::element::f32}, {128.f}, {3.f}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { {{ngraph::element::f32}, {128.f}, {3.f}}, @@ -160,6 +168,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -186,6 +196,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -212,6 +224,8 @@ const std::vector testValues = { {{11.f, 11.f, 11.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -238,6 +252,8 @@ const std::vector testValues = { {{11.f, 11.f, 11.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -262,6 +278,8 @@ const std::vector testValues = { {{ngraph::element::f32}, {128.f}, {3.f}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { {{ngraph::element::f32}, {128.f}, {3.f}}, @@ -279,6 +297,8 @@ const std::vector testValues = { {{ngraph::element::f32}, {128.f}, {3.f}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { {{ngraph::element::f32}, {128.f}, {3.f}}, @@ -298,6 +318,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f, 44.f}, ngraph::element::f32, {1, 4, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -329,6 +351,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::u8, + {}, ngraph::element::u8, { { @@ -360,6 +384,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f}, ngraph::element::f32, {1, 3, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -391,6 +417,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f, 44.f}, ngraph::element::f32, {1, 4, 1, 1}}} }, { + ngraph::element::i8, + {}, ngraph::element::i8, { { @@ -417,6 +445,8 @@ const std::vector testValues = { {{11.f, 22.f, 33.f, 44.f}, ngraph::element::f32, {1, 4, 1, 1}}} }, { + ngraph::element::f32, + {}, ngraph::element::f32, { { diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp index 1036908dac4..e19a1366ce8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp @@ -19,48 +19,48 @@ const std::vector netPrecisions = { const std::vector params = { { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.8f }, { 12.7f } }, false, {ngraph::element::i8}, {ngraph::element::f32, ngraph::element::i8} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, false, {ngraph::element::i8}, {ngraph::element::f32, ngraph::element::i8} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, true, {ngraph::element::i8}, {ngraph::element::i8, ngraph::element::f32} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -12.8f }, { 12.7f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, true, {ngraph::element::i8}, {ngraph::element::i8, ngraph::element::f32} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -127.f }, { 128.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.7f }, { 12.8f } }, false, {ngraph::element::u8}, {ngraph::element::f32, ngraph::element::u8} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, false, {ngraph::element::u8}, {ngraph::element::f32, ngraph::element::u8} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -127.f }, { 128.f } }, true, {ngraph::element::u8}, {ngraph::element::u8, ngraph::element::f32} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -12.8f }, { 12.7f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, true, {ngraph::element::u8}, {ngraph::element::u8, ngraph::element::f32} diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp index 7879137469d..a5ca8f23b68 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp @@ -45,7 +45,8 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithSplitTransformation, +// TODO: Split/VariadicSplit operations are not supported in ConcatTransformation +INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index e22490fc832..31f5105ced9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -11,16 +11,16 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; -const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() +const std::vector trasformationParamValues = { + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; -const std::vector testValues = { +const std::vector testValues = { { { 256ul, {}, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, @@ -32,7 +32,7 @@ const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector testValues = { @@ -59,7 +59,7 @@ const std::vector testVa INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp index 6cbc68d5dd5..55691f55d08 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp @@ -12,17 +12,17 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector trasformationParamValues = { // can not be passed to plugin // nGraph: I8 -> FP32 Convert is not supported - // LayerTestsUtils::LayerTransformationParamsFactory::createParams(), - // LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + // LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams(), + // LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector fakeQuantizeOnDataValues = { @@ -38,7 +38,7 @@ const std::vector fakeQuantizeOnD INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index ac65ff3ff12..c7a5e7cc8d8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -12,12 +12,12 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector fakeQuantizeOnDataValues = { @@ -36,7 +36,7 @@ const std::vector fakeQuantizeOnD INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 9, 9 })), + ::testing::Values(ngraph::Shape({ 1, 3, 9, 9 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp index 1cb4019c9ae..61398d107af 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp @@ -11,20 +11,20 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; -const std::vector dimensions = { - InferenceEngine::SizeVector({ 1, 3, 16, 16 }) +const std::vector dimensions = { + { 1, 3, 16, 16 } }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParams().setSupportAsymmetricQuantization(true), - LayerTestsUtils::LayerTransformationParamsFactory::createParams().setSupportAsymmetricQuantization(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setSupportAsymmetricQuantization(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setSupportAsymmetricQuantization(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; INSTANTIATE_TEST_CASE_P(smoke_LPT, GemmTransformation, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp index 36554c84cca..0fa7125babe 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp @@ -99,16 +99,10 @@ std::shared_ptr convert(std::shared_ptr LayerTransformation::transformNGraph( const ngraph::pass::low_precision::LayerTransformation::Params& params, - const ngraph::pass::low_precision::LowPrecisionTransformations additionalTransformations) { + const ngraph::pass::low_precision::LowPrecisionTransformations& transformations) { std::shared_ptr clonedNetwork = convert(function); auto nGraphFunc = clonedNetwork->getFunction(); - auto transformations = getLowPrecisionTransformationsNGraph(params); - - for (auto& additionalTransformation : additionalTransformations.transformations) { - transformations.transformations.emplace(additionalTransformation.first, additionalTransformation.second); - } - ngraph::pass::low_precision::LowPrecisionTransformer transformer(transformations); transformer.transform(nGraphFunc); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index 77d560d4107..55ea00321bd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -10,8 +10,8 @@ using namespace LayerTestsDefinitions; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32 }; const std::vector params = { @@ -21,9 +21,9 @@ const std::vector> inputShapes = { - std::pair({ InferenceEngine::SizeVector({ 1, 16 }), InferenceEngine::SizeVector({ 10, 16 }) }), - std::pair({ InferenceEngine::SizeVector({ 1, 16 }), InferenceEngine::SizeVector({ 16, 10 }) }) +const std::vector> inputShapes = { + std::pair({ 1, 16 }, { 10, 16 }), + std::pair({ 1, 16 }, { 16, 10 }) }; INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp index c0510c904d2..8f75d570d15 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -10,9 +10,9 @@ using namespace LayerTestsDefinitions; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector values = { @@ -24,7 +24,7 @@ const std::vector values = { INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyWithOneParentTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(values)), MultiplyWithOneParentTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp index f5f62bcf94c..dd772ed9099 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp @@ -15,18 +15,18 @@ const std::vector precisions = { ngraph::element::f32 }; -std::vector testValues = { - {}, - { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, - { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} } +std::vector testValues = { + { {}, false}, + { { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, false }, + { { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, true }, + { { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, true }, + { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; INSTANTIATE_TEST_CASE_P(smoke_LPT, PReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(testValues)), PReluTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp index f8608ad74f7..70a06e3c49d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp @@ -16,12 +16,12 @@ const std::vector precisions = { // ngraph::element::f16 }; -std::vector testValues = { - {}, - { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, - { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} } +std::vector testValues = { + { {}, false}, + { { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, false }, + { { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, true }, + { { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, true }, + { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; INSTANTIATE_TEST_CASE_P(smoke_LPT, ReluTransformation, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index 4f10d29387c..7d67e8143c8 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -27,18 +27,21 @@ const std::vector params = { ngraph::Shape{ 1, 3, 32 }, { 1, 3, 4, 8 }, { 256ul, ngraph::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + true }, // 4D -> 3D { ngraph::Shape{ 1, 3, 16, 16 }, { 1, 3, 256 }, { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + true }, // 4D -> 2D { ngraph::Shape{ 1, 3, 4, 8 }, { 1, -1 }, { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + true }, }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp index 14c89005919..0aaeef6e16d 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp @@ -11,36 +11,36 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { - const std::vector precisions = { - InferenceEngine::Precision::FP32, + const std::vector precisions = { + ngraph::element::f32 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(true), }; const std::vector params = { { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0, 3 }, + { 3 }, { 1, 3, 5, 1} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0, 1, 2 }, + { 2, 3 }, { 1, 1, 1, 1 } }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0, 3 }, + { 3 }, { 1, 64, 32, 1 } }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0.0, 2.0, 3.0 }, + { 2.0, 3.0 }, { 1, 32, 1, 1 } } }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp index 8a641baa8c1..ff766e36dc4 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp @@ -44,19 +44,18 @@ const std::vector testVal {2.55f, 2.55f / 2.f, 2.55f / 3.f} }, }, - // TODO: uncomment test - //{ - // {1, 3, 16, 16}, - // ngraph::element::f32, - // { - // 256ul, - // ngraph::Shape({1}), - // {2.55f / 2}, - // {2.55f}, - // {2.55f / 2}, - // {2.55f} - // }, - //}, + { + {1, 3, 16, 16}, + ngraph::element::f32, + { + 256ul, + ngraph::Shape({1}), + {2.55f / 2}, + {2.55f}, + {2.55f / 2}, + {2.55f} + }, + }, }; INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp index e7359538880..127c277a26f 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp @@ -11,21 +11,21 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + ngraph::element::f16 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParams().setUpdatePrecisions(true), - LayerTestsUtils::LayerTransformationParamsFactory::createParams().setUpdatePrecisions(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues)), SubtractTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp index a87b7cbd57f..afced61e1fd 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -11,15 +11,15 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParams().setUpdatePrecisions(true), - LayerTestsUtils::LayerTransformationParamsFactory::createParams().setUpdatePrecisions(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams().setUpdatePrecisions(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector perTensorValues = { true, false }; @@ -29,7 +29,7 @@ const std::vector transposeChannelDimValues = { true, false }; INSTANTIATE_TEST_CASE_P(smoke_LPT, TransposeAfterMatMulTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_CPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(perTensorValues), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp index de81010cf8d..a5ab487f5b4 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp @@ -11,42 +11,42 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { - const std::vector precisions = { - InferenceEngine::Precision::FP32, + const std::vector precisions = { + ngraph::element::f32 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(true), }; const std::vector params = { { { 256ul, ngraph::Shape { 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0.0, 3.0 }, + { 3.0 }, { 3, 3, 5} }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0.0, 1.0 }, - { 3, 3, 3 } + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.8f }, { 12.7f } }, + { 3.0 }, + { 3, 3, 3, 5 } }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, { 3.0 }, { 3, 4, 5, 6 } }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0.0, 3.0 }, - { 1, 32, 2} + { 256ul, ngraph::Shape { 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 2.0, 3.0 }, + { 3, 4 } }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, - { 0.0, 1.0 }, - { 46, 128, 2 } + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 4.0 }, + { 46, 128, 2, 3 } } }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp index c0ab3a6619a..4dac9d08b39 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/add_transformation.cpp @@ -19,48 +19,48 @@ const std::vector netPrecisions = { const std::vector params = { { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.8f }, { 12.7f } }, false, {ngraph::element::i8}, {ngraph::element::f32, ngraph::element::i8} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, false, {ngraph::element::i8}, {ngraph::element::f32, ngraph::element::i8} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, true, {ngraph::element::i8}, {ngraph::element::i8, ngraph::element::f32} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -12.8f }, { 12.7f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, true, {ngraph::element::i8}, {ngraph::element::i8, ngraph::element::f32} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -127.f }, { 128.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.7f }, { 12.8f } }, false, {ngraph::element::u8}, {ngraph::element::f32, ngraph::element::u8} }, { { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, false, {ngraph::element::u8}, {ngraph::element::f32, ngraph::element::u8} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -127.f }, { 128.f } }, true, {ngraph::element::u8}, {ngraph::element::u8, ngraph::element::f32} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -128.f }, { 127.f }, { -12.8f }, { 12.7f } }, { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 255.f } }, true, {ngraph::element::u8}, {ngraph::element::u8, ngraph::element::f32} @@ -71,7 +71,7 @@ const std::vector params = { INSTANTIATE_TEST_CASE_P(smoke_LPT, AddTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(params)), AddTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp index 1d898673593..1ba16c0c26c 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/concat_with_split_transformation.cpp @@ -45,7 +45,8 @@ const std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ConcatWithSplitTransformation, +// TODO: Split/VariadicSplit operations are not supported in ConcatTransformation +INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, ConcatWithSplitTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), ::testing::Values(ngraph::Shape({ 1, 6, 10, 10 })), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp index 9a68f267892..e1832b85f5a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/convolution_transformation.cpp @@ -40,24 +40,18 @@ const std::vector params { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, false }, - // { - // { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 1.f }, { 25.5f } }, - // true, - // { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, - // false - // }, - // { - // { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, - // false, - // { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -1.f }, { 12.7f } }, - // true - // } + { + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.75f }, { 6.375f } }, + true, + { 255ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 254.f }, { -12.7f }, { 12.7f } }, + false + } }; INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), @@ -81,8 +75,8 @@ const std::vector i INSTANTIATE_TEST_CASE_P(smoke_LPT, ConvolutionWIthIncorrectWeightsTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), - ::testing::Values(CommonTestUtils::DEVICE_CPU), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), + ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(incorrectWeightsParams)), ConvolutionWIthIncorrectWeightsTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index 16f00c54e60..9bbd0465de2 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -11,16 +11,16 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; -const std::vector testValues = { +const std::vector testValues = { { { 256ul, {}, { 0.f }, { 25.5f }, { 0.f }, { 25.5f } }, { 255ul, {1, 1, 1, 1}, { 0.f }, { 254.f }, { -127.f }, { 127.f } }, @@ -32,7 +32,7 @@ const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector testValues = { @@ -60,7 +60,7 @@ const std::vector testVa INSTANTIATE_TEST_CASE_P(DISABLED_LPT, FakeQuantizePrecisionSelectionTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(testValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp index 381bcf0ea52..f627ae13182 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fake_quantize_transformation.cpp @@ -12,17 +12,17 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector trasformationParamValues = { // can not be passed to plugin // nGraph: I8 -> FP32 Convert is not supported - // LayerTestsUtils::LayerTransformationParamsFactory::createParams(), - // LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + // LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams(), + // LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector fakeQuantizeOnDataValues = { @@ -37,7 +37,7 @@ const std::vector fakeQuantizeOnD INSTANTIATE_TEST_CASE_P(smoke_LPT, FakeQuantizeTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 32, 72, 48 })), + ::testing::Values(ngraph::Shape({ 1, 32, 72, 48 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp index fca317ad154..c91489b2dd6 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fully_connected_transformation.cpp @@ -12,8 +12,8 @@ using namespace InferenceEngine::details; namespace { const std::vector netPrecisions = { - ngraph::element::f32, - // ngraph::element::f16 + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector shapes = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index 260c322ed4e..dd82d742186 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -12,12 +12,12 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32, }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8() }; const std::vector fakeQuantizeOnDataValues = { @@ -36,7 +36,7 @@ const std::vector fakeQuantizeOnD INSTANTIATE_TEST_CASE_P(smoke_LPT, FuseFakeQuantizeAndScaleShiftTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 9, 9 })), + ::testing::Values(ngraph::Shape({ 1, 3, 9, 9 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(fakeQuantizeOnDataValues)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp index dc899145821..1c6a30d00ec 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/gemm_transformation.cpp @@ -11,16 +11,16 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32, }; -const std::vector dimensions = { - InferenceEngine::SizeVector({ 1, 3, 16, 16 }) +const std::vector dimensions = { + {1, 3, 16, 16} }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8() }; INSTANTIATE_TEST_CASE_P(smoke_LPT, GemmTransformation, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp index 661688835bf..e53419c77f5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/layer_transformation.cpp @@ -132,17 +132,12 @@ std::shared_ptr convert(std::shared_ptr LayerTransformation::transformNGraph( const ngraph::pass::low_precision::LayerTransformation::Params& params, - const ngraph::pass::low_precision::LowPrecisionTransformations additionalTransformations) { + const ngraph::pass::low_precision::LowPrecisionTransformations& transformations) { std::shared_ptr clonedNetwork = convert(function); InferenceEngine::NetPass::ConvertPrecision(*clonedNetwork, InferenceEngine::Precision::FP16, InferenceEngine::Precision::FP32); auto nGraphFunc = clonedNetwork->getFunction(); - auto transformations = getLowPrecisionTransformationsNGraph(params); - - for (auto& additionalTransformation : additionalTransformations.transformations) { - transformations.transformations.emplace(additionalTransformation.first, additionalTransformation.second); - } ngraph::pass::low_precision::LowPrecisionTransformer transformer(transformations); transformer.transform(nGraphFunc); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index b1d7ce63d61..e53eb5db75a 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -33,7 +33,7 @@ std::vector testValues = { INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 384, 1024 })), + ::testing::Values(ngraph::Shape({ 1, 384, 1024 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), MatMulTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index 766f5aa5714..b2d596b2059 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -10,8 +10,8 @@ using namespace LayerTestsDefinitions; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32, }; const std::vector params = { @@ -21,9 +21,9 @@ const std::vector> inputShapes = { - std::pair({ InferenceEngine::SizeVector({ 1, 16 }), InferenceEngine::SizeVector({ 10, 16 }) }), - std::pair({ InferenceEngine::SizeVector({ 1, 16 }), InferenceEngine::SizeVector({ 16, 10 }) }) +const std::vector> inputShapes = { + std::pair({ 1, 16 }, { 10, 16 }), + std::pair({ 1, 16 }, { 16, 10 }) }; INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithOptimizedConstantFakeQuantizeTransformation, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp index 6f993c34526..e5edaab9593 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_transformation.cpp @@ -70,7 +70,7 @@ const std::vector params = { INSTANTIATE_TEST_CASE_P(smoke_LPT, MultiplyTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(params)), MultiplyTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp index ccacca05743..bfc9ead8219 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -10,9 +10,9 @@ using namespace LayerTestsDefinitions; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - // InferenceEngine::Precision::FP16 +const std::vector netPrecisions = { + ngraph::element::f32, + // ngraph::element::f16 }; const std::vector values = { diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp index 3ec6d974244..5eb1dec35c5 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/prelu_transformation.cpp @@ -4,7 +4,7 @@ #include -#include "low_precision_transformations/relu_transformation.hpp" +#include "low_precision_transformations/prelu_transformation.hpp" #include "common_test_utils/test_constants.hpp" using namespace LayerTestsDefinitions; @@ -12,23 +12,22 @@ using namespace InferenceEngine::details; namespace { const std::vector precisions = { - ngraph::element::f32, - // ngraph::element::f16 + ngraph::element::f32 }; -std::vector testValues = { - {}, - { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, - { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} } +std::vector testValues = { + { {}, false}, + { { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, false }, + { { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, true }, + { { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, true }, + { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; -INSTANTIATE_TEST_CASE_P(smoke_LPT, ReluTransformation, +INSTANTIATE_TEST_CASE_P(LPT, PReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), - ReluTransformation::getTestCaseName); + PReluTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp index 3ec6d974244..25050e63019 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/relu_transformation.cpp @@ -16,18 +16,18 @@ const std::vector precisions = { // ngraph::element::f16 }; -std::vector testValues = { - {}, - { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, - { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, - { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} } +std::vector testValues = { + { {}, false}, + { { 256ul, ngraph::Shape({}), {0.f}, {25.5f}, {0.f}, {25.5f} }, false }, + { { 256ul, ngraph::Shape({}), {-12.8f}, {12.7f}, {-12.8f}, {12.7f} }, true }, + { { 256ul, ngraph::Shape({}), {12.75f}, {25.5f}, {12.75f}, {25.5f} }, true }, + { { 256ul, ngraph::Shape({}), {-12.8f / 2.f}, {12.7f}, {-12.8f / 2.f}, {12.7f} }, true } }; INSTANTIATE_TEST_CASE_P(smoke_LPT, ReluTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(testValues)), ReluTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp index f7d81187155..98e2f916f1e 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/reshape_transformation.cpp @@ -27,18 +27,21 @@ const std::vector params = { ngraph::Shape{ 1, 3, 32 }, { 1, 3, 4, 8 }, { 256ul, ngraph::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + true }, // 4D -> 3D { ngraph::Shape{ 1, 3, 16, 16 }, { 1, 3, 256 }, - { 256ul, ngraph::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + true }, // 4D -> 2D { ngraph::Shape{ 1, 3, 4, 8 }, { 1, -1 }, - { 256ul, ngraph::Shape{ 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + { 256ul, ngraph::Shape{ 1, 1, 1, 1 }, { 0.f }, { 255.f }, { 0.f }, { 25.5f } }, + true }, }; diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp index 4fa1d324da0..fe4a476aeee 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/squeeze_transformation.cpp @@ -11,43 +11,43 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { - const std::vector precisions = { - InferenceEngine::Precision::FP32, + const std::vector netPrecisions = { + ngraph::element::f32, }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(true), }; const std::vector params = { { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 3.0 }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 3 }, { 1, 3, 5, 1} }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 1.0, 2.0 }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 2, 3 }, { 1, 1, 1, 1 } }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 3.0 }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 3 }, { 1, 64, 32, 1 } }, { - { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 2.0, 3.0 }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 2.0, 3.0 }, { 1, 32, 1, 1 } } }; INSTANTIATE_TEST_CASE_P(smoke_LPT, SqueezeTransformation, ::testing::Combine( - ::testing::ValuesIn(precisions), + ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp index 88e9dcacddf..ad07d3acc31 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp @@ -43,19 +43,18 @@ const std::vector testVal {2.55f, 2.55f / 2.f, 2.55f / 3.f} }, }, - // TODO: uncomment test - // { - // {1, 3, 16, 16}, - // ngraph::element::f32, - // { - // 256ul, - // ngraph::Shape({1}), - // {2.55f / 2}, - // {2.55f}, - // {2.55f / 2}, - // {2.55f} - // }, - // }, + { + {1, 3, 16, 16}, + ngraph::element::f32, + { + 256ul, + ngraph::Shape({1}), + {2.55f / 2}, + {2.55f}, + {2.55f / 2}, + {2.55f} + }, + }, }; INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractMultiplyToMultiplyAddTransformation, diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp index 9febfd7a852..ac97b4f9036 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/subtract_transformation.cpp @@ -11,18 +11,18 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32, }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParams() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() }; INSTANTIATE_TEST_CASE_P(smoke_LPT, SubtractTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues)), SubtractTransformation::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp index c75616a76d6..97af7bed373 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -11,12 +11,12 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32 +const std::vector netPrecisions = { + ngraph::element::f32, }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParams() + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams() }; const std::vector perTensorValues = { true, false }; @@ -26,7 +26,7 @@ const std::vector transposeChannelDimValues = { true, false }; INSTANTIATE_TEST_CASE_P(smoke_LPT, TransposeAfterMatMulTransformation, ::testing::Combine( ::testing::ValuesIn(netPrecisions), - ::testing::Values(InferenceEngine::SizeVector({ 1, 3, 16, 16 })), + ::testing::Values(ngraph::Shape({ 1, 3, 16, 16 })), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(perTensorValues), diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp index d657debac3e..dac07734f18 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/low_precision_transformations/unsqueeze_transformation.cpp @@ -11,48 +11,48 @@ using namespace LayerTestsDefinitions; using namespace ngraph::pass::low_precision; namespace { - const std::vector precisions = { - InferenceEngine::Precision::FP32, + const std::vector netPrecisions = { + ngraph::element::f32, }; const std::vector trasformationParamValues = { - LayerTestsUtils::LayerTransformationParamsFactory::createParamsU8I8(), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(false), - LayerTestsUtils::LayerTransformationParamsFactory::createParamsI8I8().setUpdatePrecisions(true), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(false), + LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsI8I8().setUpdatePrecisions(true), }; const std::vector params = { { - { 256ul, ngraph::Shape { 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 3.0 }, + { 256ul, ngraph::Shape { 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 3.0 }, { 3, 3, 5} }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 1.0 }, - { 3, 3, 3 } + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { 0.f }, { 255.f }, { -12.8f }, { 12.7f } }, + { 3.0 }, + { 3, 3, 3, 5 } }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, { 3.0 }, { 3, 4, 5, 6 } }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 3.0 }, - { 1, 32, 2} + { 256ul, ngraph::Shape { 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 2.0, 3.0 }, + { 3, 4 } }, { - { 256ul, ngraph::Shape { 1, 1, 1 }, { 0.f }, { 255.f }, { -128.f }, { 127.f } }, - { 0.0, 1.0 }, - { 46, 128, 2 } + { 256ul, ngraph::Shape { 1, 1, 1, 1 }, { -12.8f }, { 12.7f }, { -12.8f }, { 12.7f } }, + { 4.0 }, + { 46, 128, 2, 3 } } }; INSTANTIATE_TEST_CASE_P(smoke_LPT, UnsqueezeTransformation, ::testing::Combine( - ::testing::ValuesIn(precisions), + ::testing::ValuesIn(netPrecisions), ::testing::Values(CommonTestUtils::DEVICE_GPU), ::testing::ValuesIn(trasformationParamValues), ::testing::ValuesIn(params)), diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp index 866d6d2da3a..7e2aac14507 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/add_transformation.hpp @@ -35,6 +35,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp index 97ff925b9ea..bd2427ac0e1 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/clamp_transformation.hpp @@ -33,6 +33,6 @@ public: protected: void SetUp() override; private: - void validateNGraph(); + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp index 46f66663d28..bca64ee6963 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_transformation.hpp @@ -33,6 +33,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_childs.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_childs.hpp index 9ef385d1447..87b173c7a86 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_childs.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_different_precision_on_childs.hpp @@ -35,6 +35,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp index 29633c8738f..8261a5093fd 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_intermediate_transformation.hpp @@ -29,6 +29,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp index c83f9339a14..e008ab805c6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/concat_with_neighbors_graph_transformation.hpp @@ -26,6 +26,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_transformation.hpp index 90cfd756675..61f52d4007a 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_transformation.hpp @@ -43,7 +43,7 @@ protected: void Run() override; private: - void validateNGraph(); + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_with_incorrect_weights.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_with_incorrect_weights.hpp index c501166e0de..fd9655fd44e 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_with_incorrect_weights.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/convolution_with_incorrect_weights.hpp @@ -36,6 +36,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp index d3ca0b12eab..8456834c68f 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_avg_pool_transformation.hpp @@ -27,6 +27,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp index 4aef7c28182..3f1eab8e6d8 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_max_pool_transformation.hpp @@ -27,6 +27,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp index d065259e2af..3c69b34d2d6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.hpp @@ -13,13 +13,19 @@ #include "lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp" namespace LayerTestsDefinitions { +class FakeQuantizeAndTwoOutputBranchesWithConvolution { +public: + ngraph::builder::subgraph::FakeQuantizeOnData fqOnData; + ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights1; + ngraph::builder::subgraph::FakeQuantizeOnWeights fqOnWeights2; +}; typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::SizeVector, + ngraph::element::Type, + ngraph::Shape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, - ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ActualValues + FakeQuantizeAndTwoOutputBranchesWithConvolution > FakeQuantizeAndTwoOutputBranchesWithConvolutionParams; class FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation : @@ -30,6 +36,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp index 7a57360d9f8..7bc7d09ad1c 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_precision_selection_transformation.hpp @@ -49,8 +49,8 @@ inline std::ostream& operator<<(std::ostream& out, const FakeQuantizePrecisionSe } typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::SizeVector, + ngraph::element::Type, + ngraph::Shape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, FakeQuantizePrecisionSelectionTransformationTestValues> FakeQuantizeTransformationParams; @@ -63,6 +63,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp index 8c9cb2cbc23..14addaf29b6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fake_quantize_transformation.hpp @@ -11,10 +11,9 @@ namespace LayerTestsDefinitions { -// ngraph::builder::subgraph::FakeQuantizeOnData typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::SizeVector, + ngraph::element::Type, + ngraph::Shape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ngraph::builder::subgraph::FakeQuantizeOnData> FakeQuantizeTransformationParams; @@ -27,6 +26,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp index 2004b77be12..14cb1ebcd3d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fully_connected_transformation.hpp @@ -33,6 +33,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp index 48bd9ae6053..d5ac61f2cc7 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.hpp @@ -12,8 +12,8 @@ namespace LayerTestsDefinitions { typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::SizeVector, + ngraph::element::Type, + ngraph::Shape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, ngraph::builder::subgraph::FakeQuantizeOnData> FuseFakeQuantizeAndScaleShiftTransformationParams; @@ -26,6 +26,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp index a1d5b94e74d..4e6d958e813 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_fake_quantize_transformation.hpp @@ -43,6 +43,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp index 549249a8419..f15b5e8999e 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.hpp @@ -39,6 +39,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp index c8d6d273a80..2b2f3ffb45d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.hpp @@ -39,6 +39,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp index dedd5fd0322..20ac52494fc 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/gemm_transformation.hpp @@ -11,15 +11,24 @@ namespace LayerTestsDefinitions { +typedef std::tuple< + ngraph::element::Type, + ngraph::Shape, + std::string, + ngraph::pass::low_precision::LayerTransformation::Params> GemmTransformationParams; + // TODO: use MatMulTransformation class GemmTransformation : - public testing::WithParamInterface, + public testing::WithParamInterface, public LayerTestsUtils::LayerTransformation { public: - static std::string getTestCaseName(testing::TestParamInfo obj); + static std::string getTestCaseName(testing::TestParamInfo obj); protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp index 448cfcae64e..3307efb886c 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/group_convolution_transformation.hpp @@ -39,7 +39,7 @@ protected: void SetUp() override; private: - void validateNGraph(); + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp index a94291142a9..54a49c14a2f 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/interpolate_transformation.hpp @@ -49,6 +49,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp index 45357d54b88..1ac5bc2cdc8 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_transformation.hpp @@ -36,6 +36,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp index 42ae7cca2f8..98493955c1a 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_constant_transformation.hpp @@ -41,6 +41,9 @@ protected: void SetUp() override; void Run() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp index 0df49f02c09..8390fe1bb48 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.hpp @@ -19,8 +19,8 @@ public: }; typedef std::tuple< - InferenceEngine::Precision, - std::pair, + ngraph::element::Type, + std::pair, std::string, MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues > MatMulWithOptimizedConstantFakeQuantizeTransformationTransformationParams; @@ -33,6 +33,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp index 3f2f03714c3..28af51870c3 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_transformation.hpp @@ -36,6 +36,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp index 2f8ddaa55bb..1af156dd7dc 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/multiply_with_one_parent_transformation.hpp @@ -18,8 +18,8 @@ public: }; typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::SizeVector, + ngraph::element::Type, + ngraph::Shape, std::string, MultiplyWithOneParentTransformationValues > MultiplyWithOneParentTransformationParams; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp index 081049829c2..6ae88bde8f9 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/mvn_transformation.hpp @@ -29,6 +29,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp index 8512169b336..71ca3fb466a 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/normalize_transformation.hpp @@ -28,6 +28,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp index 399256b5ee2..b3c1b27c44a 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/prelu_transformation.hpp @@ -11,11 +11,17 @@ namespace LayerTestsDefinitions { +class PReluTestValues { +public: + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; + bool isSubtract; +}; + typedef std::tuple< ngraph::element::Type, ngraph::Shape, std::string, - ngraph::builder::subgraph::FakeQuantizeOnData> PReluTransformationParams; + PReluTestValues> PReluTransformationParams; class PReluTransformation : public testing::WithParamInterface, @@ -26,6 +32,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp index 6f920a37962..a137d2b0a69 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/relu_transformation.hpp @@ -11,11 +11,17 @@ namespace LayerTestsDefinitions { +class ReluTestValues { +public: + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; + bool isSubtract; +}; + typedef std::tuple< ngraph::element::Type, ngraph::Shape, std::string, - ngraph::builder::subgraph::FakeQuantizeOnData> ReluTransformationParams; + ReluTestValues> ReluTransformationParams; class ReluTransformation : public testing::WithParamInterface, @@ -26,6 +32,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp index b74fffed8b0..9e1e57b8ace 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/reshape_transformation.hpp @@ -17,6 +17,7 @@ public: ngraph::Shape inputShape; std::vector reshapeConstValues; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; + bool isTransformed; }; typedef std::tuple< @@ -34,6 +35,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp index ae71cfca2b7..83dd127b5d7 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/split_transformation.hpp @@ -33,6 +33,6 @@ protected: void SetUp() override; private: - void validateNGraph(); + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp index 00d7cc51094..ba0305b1366 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/squeeze_transformation.hpp @@ -22,7 +22,7 @@ public: std::string stringifySqueezeArgs(const std::vector& axes); typedef std::tuple< - InferenceEngine::Precision, + ngraph::element::Type, std::string, ngraph::pass::low_precision::LayerTransformation::Params, SqueezeTransformationParam @@ -37,6 +37,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp index d99db9477ae..795a67570c6 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.hpp @@ -31,7 +31,9 @@ public: protected: void SetUp() override; - void validateNGraph(); + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp index 49fc0367f0f..3ea36179013 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/subtract_transformation.hpp @@ -11,11 +11,18 @@ namespace LayerTestsDefinitions { +typedef std::tuple< + ngraph::element::Type, + ngraph::Shape, + std::string, + ngraph::pass::low_precision::LayerTransformation::Params +> SubtractTransformationParams; + class SubtractTransformation : - public testing::WithParamInterface, + public testing::WithParamInterface, public LayerTestsUtils::LayerTransformation { public: - static std::string getTestCaseName(testing::TestParamInfo obj); + static std::string getTestCaseName(testing::TestParamInfo obj); protected: void SetUp() override; diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp index 5982a3f6ab6..3acce880d70 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_after_matmul_transformation.hpp @@ -12,8 +12,8 @@ namespace LayerTestsDefinitions { typedef std::tuple< - InferenceEngine::Precision, - InferenceEngine::SizeVector, + ngraph::element::Type, + ngraph::Shape, std::string, ngraph::pass::low_precision::LayerTransformation::Params, bool, @@ -27,6 +27,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp index 72abdfa57d1..39e2c1aae3a 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/transpose_transformation.hpp @@ -34,6 +34,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp index d54ac53c8e3..ce477099e97 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/unsqueeze_transformation.hpp @@ -20,7 +20,7 @@ public: }; typedef std::tuple< - InferenceEngine::Precision, + ngraph::element::Type, std::string, ngraph::pass::low_precision::LayerTransformation::Params, UnsqueezeTransformationParam @@ -35,6 +35,9 @@ public: protected: void SetUp() override; + +private: + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp index 53f264ca37e..f076d1564e5 100644 --- a/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/low_precision_transformations/variadic_split_transformation.hpp @@ -33,6 +33,6 @@ protected: void SetUp() override; private: - void validateNGraph(); + void validate(); }; } // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp index beebb9ff703..bfb9e412939 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/add_transformation.cpp @@ -50,42 +50,34 @@ std::string AddTransformation::getTestCaseName(testing::TestParamInfo< AddTransf void AddTransformation::SetUp() { ngraph::element::Type precision; - ngraph::Shape inputShape1; + ngraph::Shape inputShape; AddTestValues param; - std::tie(precision, inputShape1, targetDevice, param) = this->GetParam(); + std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); - ngraph::Shape inputShape2 = inputShape1; - - if (param.broadcast) { - inputShape2[2] = 1; - inputShape2[3] = 1; - } - - auto fq1 = param.fakeQuantize1; - auto fq2 = param.fakeQuantize2; - - const auto input1 = std::make_shared(precision, inputShape1); - const auto fakeQuantize1 = fq1.empty() ? - nullptr : - ngraph::builder::makeFakeQuantize( - input1, precision, fq1.quantizationLevel, fq1.constantShape, - fq1.inputLowValues, fq1.inputHighValues, fq1.outputLowValues, fq1.outputHighValues); - - const auto input2 = std::make_shared(precision, inputShape2); - const auto fakeQuantize2 = fq2.empty() ? - nullptr : - ngraph::builder::makeFakeQuantize( - input2, precision, fq2.quantizationLevel, fq2.constantShape, - fq2.inputLowValues, fq2.inputHighValues, fq2.outputLowValues, fq2.outputHighValues); - - const auto add = std::make_shared( - fq1.empty() ? input1 : fakeQuantize1, - fq2.empty() ? input2 : fakeQuantize2); - - ngraph::ResultVector results{ std::make_shared(add) }; - function = std::make_shared(results, ngraph::ParameterVector{ input1, input2 }, "AddTransformation"); + function = ngraph::builder::subgraph::AddFunction::getOriginal( + precision, inputShape, param.broadcast, + param.fakeQuantize1, param.fakeQuantize2); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void AddTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + AddTestValues param; + std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); + + const auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + if ((!param.fakeQuantize1.empty()) && (!param.fakeQuantize2.empty())) { + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); + } } TEST_P(AddTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp index 74e956d91df..3a450a2462a 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/clamp_transformation.cpp @@ -42,10 +42,10 @@ void ClampTransformation::SetUp() { param.clampLowConst, param.clampHighConst); - validateNGraph(); + validate(); } -void ClampTransformation::validateNGraph() { +void ClampTransformation::validate() { ngraph::element::Type netPrecision; ngraph::Shape inputShape; std::string targetDevice; @@ -53,7 +53,8 @@ void ClampTransformation::validateNGraph() { ClampTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); - auto transformed = transformNGraph(params); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); std::shared_ptr output = transformed->get_output_op(0); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp index 7f299ac9cd4..03e95ab46b9 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_transformation.cpp @@ -57,6 +57,24 @@ void ConcatTransformation::SetUp() { inputShape, testValues.fqOnData1, testValues.fqOnData2); + + validate(); +} + +void ConcatTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShapes; + std::string targetDevice; + ConcatTransformationTestValues testValues; + std::tie(precision, inputShapes, targetDevice, testValues) = GetParam(); + + const auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(ConcatTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_childs.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_childs.cpp index 58bb6df113d..0c8a4fd7596 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_childs.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_different_precision_on_childs.cpp @@ -59,6 +59,28 @@ void ConcatWithDifferentChildsTransformation::SetUp() { function = ngraph::builder::subgraph::ConcatFunction::getOriginalWithDifferentPrecisionOnChilds( netPrecision, inputShapes, param.fqOnData1, param.fqOnData2); + + validate(); +} + +void ConcatWithDifferentChildsTransformation::validate() { + ngraph::element::Type netPrecision; + ngraph::Shape inputShapes; + std::string targetDevice; + ConcatWithDifferentChildsTransformationParam param; + ngraph::pass::low_precision::LayerTransformation::Params params; + bool multiChannel; + std::tie(netPrecision, inputShapes, targetDevice, param, params, multiChannel) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + ASSERT_EQ(2ul, transformed->get_output_size()); + for (size_t i = 0; i < 2ul; ++i) { + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); + } } TEST_P(ConcatWithDifferentChildsTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp index 2e06ee9d724..ef51a937680 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_intermediate_transformation.cpp @@ -72,6 +72,35 @@ void ConcatWithIntermediateTransformation::SetUp() { transparentIntermediate, { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} }); + + validate(); +} + +void ConcatWithIntermediateTransformation::validate() { + ngraph::element::Type netPrecision; + InferenceEngine::SizeVector inputShape; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + bool transparentIntermediate; + bool multichannel; + std::tie(netPrecision, inputShape, targetDevice, params, transparentIntermediate, multichannel) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + ASSERT_EQ(2ul, transformed->get_output_size()); + + const auto concatOutput = transformed->get_output_op(0); + const auto scaleShiftOrConcat = concatOutput->get_input_node_shared_ptr(0); + const std::string typeName = scaleShiftOrConcat->get_type_name(); + if (transparentIntermediate) { + ASSERT_EQ("ScaleShiftIE", typeName); + } else { + ASSERT_EQ("Concat", typeName); + } + + const auto convOutput = transformed->get_output_op(1); + const auto convolution = convOutput->get_input_node_shared_ptr(0); + const std::string convName = convolution->get_type_name(); + ASSERT_EQ("ConvolutionIE", convName); } TEST_P(ConcatWithIntermediateTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp index 4177b03ef95..f100a544335 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/concat_with_neighbors_graph_transformation.cpp @@ -53,6 +53,26 @@ void ConcatWithNeighborsGraphTransformation::SetUp() { { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f} }, { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 2.f} }, { 256ul, ngraph::Shape({}), {0.f}, {2.55f}, {0.f}, {2.55f / 3.f} }); + + validate(); +} + +void ConcatWithNeighborsGraphTransformation::validate() { + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + std::tie(netPrecision, inputShape, targetDevice, params) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + ASSERT_EQ(2ul, transformed->get_output_size()); + + for (size_t i = 0; i < 2ul; ++i) { + const auto concatOutput = transformed->get_output_op(0); + const auto scaleShift = concatOutput->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); + } } TEST_P(ConcatWithNeighborsGraphTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp index 96aca0b3309..f9d8df8d7c5 100755 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_transformation.cpp @@ -51,7 +51,7 @@ void ConvolutionTransformation::SetUp() { param.fakeQuantizeOnData, param.fakeQuantizeOnWeights); - validateNGraph(); + validate(); } void ConvolutionTransformation::Run() { @@ -62,7 +62,7 @@ void ConvolutionTransformation::Run() { EXPECT_EQ(actualType, params.expectedKernelType); } -void ConvolutionTransformation::validateNGraph() { +void ConvolutionTransformation::validate() { ngraph::element::Type netPrecision; ngraph::Shape inputShape; std::string targetDevice; @@ -70,14 +70,14 @@ void ConvolutionTransformation::validateNGraph() { ConvolutionTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); - auto transformed = transformNGraph(params); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); EXPECT_EQ(1ul, transformed->get_output_size()); - std::shared_ptr output = transformed->get_output_op(0); - std::shared_ptr parent = output->get_input_node_shared_ptr(0); + const auto output = transformed->get_output_op(0); + const auto parent = output->get_input_node_shared_ptr(0); ASSERT_FALSE(parent == nullptr); - const std::string typeName = parent->get_type_name(); + const std::string typeName = parent->get_type_name(); if (param.fakeQuantizeOnData.empty() || param.fakeQuantizeOnWeights.empty()) { ASSERT_EQ("ConvolutionIE", typeName); } else { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp index 29aee459c01..36b666c4f78 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/convolution_with_incorrect_weights.cpp @@ -51,7 +51,33 @@ void ConvolutionWIthIncorrectWeightsTransformation::SetUp() { param.fakeQuantizeOnWeights, param.fakeQuantizeOnData, param.isCorrect); + + validate(); } + +void ConvolutionWIthIncorrectWeightsTransformation::validate() { + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + ConvolutionWIthIncorrectWeightsParam param; + std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto parent = output->get_input_node_shared_ptr(0); + ASSERT_FALSE(parent == nullptr); + + const std::string typeName = parent->get_type_name(); + if (param.isCorrect) { + ASSERT_EQ("ScaleShiftIE", typeName); + } else { + ASSERT_EQ("ConvolutionIE", typeName); + } +} + TEST_P(ConvolutionWIthIncorrectWeightsTransformation, CompareWithRefImpl) { Run(); }; diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp index ac4575e284a..4b78b5cd8bd 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/depth_to_space_transformation.cpp @@ -66,6 +66,28 @@ void DepthToSpaceTransformation::SetUp() { } function = ngraph::builder::subgraph::DepthToSpaceFunction::getOriginal(precision, inputShape, mode, blockSize); + + validate(); +} + +void DepthToSpaceTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + DepthToSpace::DepthToSpaceMode mode; + size_t blockSize; + auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + std::tie(precision, inputShape, targetDevice, mode, blockSize) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + ASSERT_FALSE(scaleShift == nullptr); + + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(DepthToSpaceTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp index ffd1a3fc952..0473aa1bf16 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_avg_pool_transformation.cpp @@ -41,6 +41,26 @@ void FakeQuantizeAndAvgPoolTransformation::SetUp() { fakeQuantize); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FakeQuantizeAndAvgPoolTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; + std::tie(precision, inputShapes, targetDevice, params, fakeQuantize) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + ASSERT_FALSE(scaleShift == nullptr); + + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(FakeQuantizeAndAvgPoolTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp index 1197a6ffd3d..4417c217ad5 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_max_pool_transformation.cpp @@ -40,6 +40,26 @@ void FakeQuantizeAndMaxPoolTransformation::SetUp() { fakeQuantize); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FakeQuantizeAndMaxPoolTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantize; + std::tie(precision, inputShapes, targetDevice, params, fakeQuantize) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + ASSERT_FALSE(scaleShift == nullptr); + + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(FakeQuantizeAndMaxPoolTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp index d82c34d4a1f..c097755ba95 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_and_two_output_branches_with_convolution.cpp @@ -17,39 +17,65 @@ #include "functional_test_utils/blob_utils.hpp" #include "ngraph_functions/pass/convert_prc.hpp" -// TODO: debug only -#include - namespace LayerTestsDefinitions { std::string FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::getTestCaseName( testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; - ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ActualValues testValues; - std::tie(netPrecision, inputShapes, targetDevice, params, testValues) = obj.param; + FakeQuantizeAndTwoOutputBranchesWithConvolution testValues; + std::tie(netPrecision, inputShape, targetDevice, params, testValues) = obj.param; std::ostringstream result; - result << netPrecision << "_" << targetDevice << "_" << testValues; + result << netPrecision << "_" << inputShape << "_" + << targetDevice << "_" << testValues.fqOnData << "_" + << testValues.fqOnWeights1 << "_" << testValues.fqOnWeights2; return result.str(); } void FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::SetUp() { threshold = 0.1f; - - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShape; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; - ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ActualValues testValues; + FakeQuantizeAndTwoOutputBranchesWithConvolution testValues; std::tie(netPrecision, inputShape, targetDevice, params, testValues) = this->GetParam(); - auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); function = ngraph::builder::subgraph::FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getOriginal( - precision, + netPrecision, inputShape, - testValues); + testValues.fqOnData, + testValues.fqOnWeights1, + testValues.fqOnWeights2); + + validate(); +} + +void FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + FakeQuantizeAndTwoOutputBranchesWithConvolution testValues; + std::tie(precision, inputShapes, targetDevice, params, testValues) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto concat = output->get_input_node_shared_ptr(0); + + const std::string typeName = concat->get_type_name(); + ASSERT_EQ("Concat", typeName); + + EXPECT_EQ(2ul, concat->get_input_size()); + for (size_t i = 0; i < 2; ++i) { + const auto scaleShift = concat->get_input_node_shared_ptr(i); + const std::string scaleShiftName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", scaleShiftName); + } } TEST_P(FakeQuantizeAndTwoOutputBranchesWithConvolutionTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp index db78324ea9d..c61efbfc871 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_precision_selection_transformation.cpp @@ -16,27 +16,27 @@ namespace LayerTestsDefinitions { std::string FakeQuantizePrecisionSelectionTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizePrecisionSelectionTransformationTestValues testValues; - std::tie(netPrecision, inputShapes, targetDevice, params, testValues) = obj.param; + std::tie(netPrecision, inputShape, targetDevice, params, testValues) = obj.param; std::ostringstream result; - result << getTestCaseNameByParams(netPrecision, inputShapes, targetDevice, params) << "_" << testValues; + result << getTestCaseNameByParams(netPrecision, inputShape, targetDevice, params) << "_" << testValues; return result.str(); } void FakeQuantizePrecisionSelectionTransformation::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; FakeQuantizePrecisionSelectionTransformationTestValues testValues; std::tie(netPrecision, inputShape, targetDevice, params, testValues) = this->GetParam(); function = ngraph::builder::subgraph::FakeQuantizePrecisionSelectionFunction::getOriginal( - FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision), + netPrecision, inputShape, { testValues.operationBeforeLimitedOperationIsPrecisionTransparent, @@ -45,6 +45,39 @@ void FakeQuantizePrecisionSelectionTransformation::SetUp() { }); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FakeQuantizePrecisionSelectionTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + FakeQuantizePrecisionSelectionTransformationTestValues param; + std::tie(precision, inputShapes, targetDevice, params, param) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto concat = output->get_input_node_shared_ptr(0); + + const std::string typeName = concat->get_type_name(); + ASSERT_EQ("Concat", typeName); + + EXPECT_EQ(2ul, concat->get_input_size()); + + const auto scaleShiftOrConv = concat->get_input_node_shared_ptr(0); + const std::string scaleShiftOrConvName = scaleShiftOrConv->get_type_name(); + if (param.operationBeforeLimitedOperationIsPrecisionTransparent) { + ASSERT_EQ("ScaleShiftIE", scaleShiftOrConvName); + } else { + ASSERT_EQ("ConvolutionIE", scaleShiftOrConvName); + } + + const auto scaleShift = concat->get_input_node_shared_ptr(1); + const std::string scaleShiftName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", scaleShiftName); } TEST_P(FakeQuantizePrecisionSelectionTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp index 420eea7d844..d9eebb44f98 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fake_quantize_transformation.cpp @@ -12,34 +12,59 @@ #include +#include "low_precision/fuse_subtract_to_fake_quantize.hpp" +#include "low_precision/fuse_multiply_to_fake_quantize.hpp" + namespace LayerTestsDefinitions { std::string FakeQuantizeTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; - std::tie(netPrecision, inputShapes, targetDevice, params, fakeQuantizeOnData) = obj.param; + std::tie(netPrecision, inputShape, targetDevice, params, fakeQuantizeOnData) = obj.param; std::ostringstream result; - result << getTestCaseNameByParams(netPrecision, inputShapes, targetDevice, params) << "_" << fakeQuantizeOnData; + result << getTestCaseNameByParams(netPrecision, inputShape, targetDevice, params) << "_" << fakeQuantizeOnData; return result.str(); } void FakeQuantizeTransformation::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; std::tie(netPrecision, inputShape, targetDevice, params, fakeQuantizeOnData) = this->GetParam(); function = ngraph::builder::subgraph::FakeQuantizeFunction::getOriginal( - FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision), + netPrecision, inputShape, fakeQuantizeOnData); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FakeQuantizeTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; + std::tie(precision, inputShapes, targetDevice, params, fakeQuantizeOnData) = this->GetParam(); + + auto transformations = getLowPrecisionTransformationsNGraph(params); + transformations.removeStandaloneCleanup(); + transformations.removeStandaloneCleanup(); + + const auto transformed = transformNGraph(params, transformations); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(FakeQuantizeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fully_connected_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fully_connected_transformation.cpp index d84f563afca..b8bcfd80c8f 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fully_connected_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fully_connected_transformation.cpp @@ -17,6 +17,7 @@ #include "functional_test_utils/blob_utils.hpp" #include "ngraph_functions/pass/convert_prc.hpp" #include "ngraph_functions/builders.hpp" +#include "lpt_ngraph_functions/mat_mul_function.hpp" namespace LayerTestsDefinitions { @@ -43,34 +44,29 @@ void FullyConnectedTransformation::SetUp() { ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(precision, shapes, targetDevice, params) = this->GetParam(); - InferenceEngine::SizeVector shapeOnActivations; - InferenceEngine::SizeVector shapeOnWeights; - - const auto paramNode = std::make_shared(precision, ngraph::Shape(shapes.inputA)); - const std::vector constShapes(shapes.inputA.size(), 1ul); - const auto fakeQuantizeOnAcitvations = ngraph::builder::makeFakeQuantize( - paramNode, precision, 256ul, constShapes, - { 0.f }, { 255.f / 4.f }, { 0.f }, { 255.f / 4.f }); - fakeQuantizeOnAcitvations->set_friendly_name("fakeQuantizeOnAcitvations"); - - auto weightsConst = std::make_shared( + function = ngraph::builder::subgraph::MatMulFunction::getOriginal( precision, + shapes.inputA, shapes.inputB, - std::vector({ 1.f })); - const auto fakeQuantizeOnWeights = ngraph::builder::makeFakeQuantize( - weightsConst, precision, 256ul, { 1ul, 1ul }, - { -128.f / 8.f }, { 127.f / 8.f }, { -128.f / 8.f }, { 127.f / 8.f }); - fakeQuantizeOnWeights->set_friendly_name("fakeQuantizeOnWeights"); - - const std::shared_ptr fullyConnected = std::make_shared( - fakeQuantizeOnAcitvations->output(0), - fakeQuantizeOnWeights->output(0), shapes.transposeA, shapes.transposeB); - fullyConnected->set_friendly_name("fullyConnected"); - ngraph::ResultVector results {std::make_shared(fullyConnected)}; - function = std::make_shared(results, ngraph::ParameterVector { paramNode }, "FullyConnectedTransformation"); + validate(); +} + +void FullyConnectedTransformation::validate() { + ngraph::element::Type precision; + MatMulShapes shapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + std::tie(precision, shapes, targetDevice, params) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(FullyConnectedTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp index 035d9a99d8c..aa44e25e090 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_and_scale_shift_transformation.cpp @@ -15,12 +15,12 @@ namespace LayerTestsDefinitions { std::string FuseFakeQuantizeAndScaleShiftTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; - std::tie(netPrecision, inputShapes, targetDevice, params, fakeQuantizeOnData) = obj.param; + std::tie(netPrecision, inputShape, targetDevice, params, fakeQuantizeOnData) = obj.param; std::ostringstream result; result << netPrecision << "_" << targetDevice << "_" << fakeQuantizeOnData; @@ -28,21 +28,37 @@ std::string FuseFakeQuantizeAndScaleShiftTransformation::getTestCaseName(testing } void FuseFakeQuantizeAndScaleShiftTransformation::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; std::tie(netPrecision, inputShape, targetDevice, params, fakeQuantizeOnData) = this->GetParam(); function = ngraph::builder::subgraph::FuseFakeQuantizeAndScaleShiftFunction::getOriginal( - FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision), + netPrecision, inputShape, fakeQuantizeOnData); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} - EXPECT_EQ(1ul, function->get_output_size()); +void FuseFakeQuantizeAndScaleShiftTransformation::validate() { + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + ngraph::builder::subgraph::FakeQuantizeOnData fakeQuantizeOnData; + std::tie(netPrecision, inputShape, targetDevice, params, fakeQuantizeOnData) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); EXPECT_EQ(1ul, function->get_output_op(0)->get_input_size()); + + const auto output = transformed->get_output_op(0); + const auto fakeQuantize = output->get_input_node_shared_ptr(0); + const std::string typeName = fakeQuantize->get_type_name(); + ASSERT_EQ("FakeQuantize", typeName); } TEST_P(FuseFakeQuantizeAndScaleShiftTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_transformation.cpp index a1f4d509d4a..b57a9ee5b10 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_fake_quantize_transformation.cpp @@ -47,6 +47,21 @@ void FuseFakeQuantizeTransformation::SetUp() { testValues.actual.fakeQuantizeOnData); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FuseFakeQuantizeTransformation::validate() { + std::string targetDevice; + FuseFakeQuantizeTransformationTestValues testValues; + std::tie(targetDevice, testValues) = this->GetParam(); + + const auto transformed = transformNGraph(testValues.params, getLowPrecisionTransformationsNGraph(testValues.params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto fakeQuantize = output->get_input_node_shared_ptr(0); + const std::string typeName = fakeQuantize->get_type_name(); + ASSERT_EQ("FakeQuantize", typeName); } TEST_P(FuseFakeQuantizeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp index 68ade881f0a..1aaaaeb830d 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_multiply_to_fake_quantize_transformation.cpp @@ -36,6 +36,21 @@ void FuseMultiplyToFakeQuantizeTransformation::SetUp() { testValues.actual.dequantization); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FuseMultiplyToFakeQuantizeTransformation::validate() { + std::string targetDevice; + FuseMultiplyToFakeQuantizeTransformationTestValues testValues; + std::tie(targetDevice, testValues) = this->GetParam(); + + const auto transformed = transformNGraph(testValues.params, getLowPrecisionTransformationsNGraph(testValues.params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto fakeQuantize = output->get_input_node_shared_ptr(0); + const std::string typeName = fakeQuantize->get_type_name(); + ASSERT_EQ("FakeQuantize", typeName); } TEST_P(FuseMultiplyToFakeQuantizeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp index 582597bde0f..e58af683a55 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/fuse_subtract_to_fake_quantize_transformation.cpp @@ -36,6 +36,21 @@ void FuseSubtractToFakeQuantizeTransformation::SetUp() { testValues.actual.dequantization); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void FuseSubtractToFakeQuantizeTransformation::validate() { + std::string targetDevice; + FuseSubtractToFakeQuantizeTransformationTestValues testValues; + std::tie(targetDevice, testValues) = this->GetParam(); + + const auto transformed = transformNGraph(testValues.params, getLowPrecisionTransformationsNGraph(testValues.params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto fakeQuantize = output->get_input_node_shared_ptr(0); + const std::string typeName = fakeQuantize->get_type_name(); + ASSERT_EQ("FakeQuantize", typeName); } TEST_P(FuseSubtractToFakeQuantizeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp index 6987280fba9..d96c20520ff 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/gemm_transformation.cpp @@ -15,53 +15,54 @@ #include "functional_test_utils/plugin_cache.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "functional_test_utils/blob_utils.hpp" -#include "ngraph_functions/pass/convert_prc.hpp" #include "ngraph_functions/builders.hpp" +#include "lpt_ngraph_functions/mat_mul_function.hpp" + namespace LayerTestsDefinitions { -std::string GemmTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; +std::string GemmTransformation::getTestCaseName(testing::TestParamInfo obj) { + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; - std::tie(netPrecision, inputShapes, targetDevice, params) = obj.param; + std::tie(netPrecision, inputShape, targetDevice, params) = obj.param; - return getTestCaseNameByParams(netPrecision, inputShapes, targetDevice, params); + return getTestCaseNameByParams(netPrecision, inputShape, targetDevice, params); } void GemmTransformation::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShape, targetDevice, params) = this->GetParam(); - auto ngPrecision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - const float low = params.precisionsOnActivations[0] == ngraph::element::u8 ? 0.f : -128.f; const float high = params.precisionsOnActivations[0] == ngraph::element::u8 ? 255.f : 127.f; - const auto input1 = std::make_shared(ngPrecision, ngraph::Shape(inputShape)); - const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize( - input1, ngPrecision, 256ul, { 1ul }, - { low / 4.f }, { high / 4.f }, { low / 4.f }, { high / 4.f }); - fakeQuantize1->set_friendly_name("fakeQuantize1"); + function = ngraph::builder::subgraph::MatMulFunction::getOriginal( + netPrecision, + inputShape, + low, + high); - const auto input2 = std::make_shared(ngPrecision, ngraph::Shape(inputShape)); - const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize( - input2, ngPrecision, 256ul, { 1ul }, - { low / 8.f }, { high / 8.f }, { low / 8.f }, { high / 8.f }); - fakeQuantize2->set_friendly_name("fakeQuantize2"); + validate(); +} - const auto matMul = std::make_shared( - fakeQuantize1->output(0), - fakeQuantize2->output(0), - false, - false); - matMul->set_friendly_name("matMul"); +void GemmTransformation::validate() { + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + std::tie(netPrecision, inputShape, targetDevice, params) = this->GetParam(); - ngraph::ResultVector results {std::make_shared(matMul)}; - function = std::make_shared(results, ngraph::ParameterVector { input1, input2 }, "GemmTransformation"); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + EXPECT_EQ(1ul, transformed->get_output_size()); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(GemmTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp index 7451e65ad8c..540ed38b63f 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/group_convolution_transformation.cpp @@ -54,17 +54,17 @@ void GroupConvolutionTransformation::SetUp() { param.fakeQuantizeOnData, param.fakeQuantizeOnWeights); - validateNGraph(); + validate(); } -void GroupConvolutionTransformation::validateNGraph() { +void GroupConvolutionTransformation::validate() { ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; GroupConvolutionTransformationParam param; std::tie(netPrecision, targetDevice, params, param) = this->GetParam(); - auto transformed = transformNGraph(params); + auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); EXPECT_EQ(1ul, transformed->get_output_size()); std::shared_ptr output = transformed->get_output_op(0); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp index 162140ad1eb..ed247408de4 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/interpolate_transformation.cpp @@ -65,6 +65,28 @@ void InterpolateTransformation::SetUp() { interpAttrs.pads_end = attributes.pads_end; function = ngraph::builder::subgraph::InterpolateFunction::getOriginal(precision, shapes.first, shapes.second, interpAttrs); + + validate(); +} + +void InterpolateTransformation::validate() { + ngraph::element::Type precision; + std::pair shapes; + std::string targetDevice; + interpAttributes attributes; + auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + std::tie(precision, shapes, targetDevice, attributes) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + if (attributes.mode == "nearest") { + ASSERT_EQ("ScaleShiftIE", typeName); + } else { + ASSERT_EQ("Interp", typeName); + } } TEST_P(InterpolateTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp index 67df482ac82..86e72caffaa 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp @@ -72,6 +72,23 @@ void MatMulTransformation::SetUp() { testValues.fqOnData2); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void MatMulTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + MatMulTransformationTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); + + const auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(MatMulTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp index 817c8f5f2fa..a519b6e32e4 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_constant_transformation.cpp @@ -69,6 +69,22 @@ void MatMulWithConstantTransformation::SetUp() { testValues.fqOnWeights); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void MatMulWithConstantTransformation::validate() { + ngraph::element::Type precision; + std::string targetDevice; + MatMulWithConstantTransformationTestValues testValues; + std::tie(precision, targetDevice, testValues) = this->GetParam(); + + const auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } void MatMulWithConstantTransformation::Run() { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp index 12ec61335ee..29b5f141a8b 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_with_optimized_constant_fake_quantize_transformation.cpp @@ -22,8 +22,8 @@ namespace LayerTestsDefinitions { std::string MatMulWithOptimizedConstantFakeQuantizeTransformation::getTestCaseName( testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - std::pair shapes; + ngraph::element::Type netPrecision; + std::pair shapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues param; @@ -31,7 +31,7 @@ std::string MatMulWithOptimizedConstantFakeQuantizeTransformation::getTestCaseNa std::tie(netPrecision, shapes, targetDevice, param) = obj.param; std::ostringstream result; - result << netPrecision.name() << "_" << + result << netPrecision << "_" << CommonTestUtils::vec2str(shapes.first) << "_" << CommonTestUtils::vec2str(shapes.second) << "_" << targetDevice << "_" << param.fqOnData << "_" << @@ -42,12 +42,11 @@ std::string MatMulWithOptimizedConstantFakeQuantizeTransformation::getTestCaseNa void MatMulWithOptimizedConstantFakeQuantizeTransformation::SetUp() { threshold = 0.01f; - InferenceEngine::Precision netPrecision; - std::pair shapes; + ngraph::element::Type precision; + std::pair shapes; ngraph::pass::low_precision::LayerTransformation::Params params; MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues param; - std::tie(netPrecision, shapes, targetDevice, param) = this->GetParam(); - auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + std::tie(precision, shapes, targetDevice, param) = this->GetParam(); function = ngraph::builder::subgraph::MatMulWithOptimizedConstantFakeQuantizeFunction::getOriginal( precision, @@ -55,6 +54,24 @@ void MatMulWithOptimizedConstantFakeQuantizeTransformation::SetUp() { shapes.second, param.fqOnData, param.fqOnWeights); + + validate(); +} + +void MatMulWithOptimizedConstantFakeQuantizeTransformation::validate() { + ngraph::element::Type precision; + std::pair shapes; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + MatMulWithOptimizedConstantFakeQuantizeTransformationTestValues param; + std::tie(precision, shapes, targetDevice, param) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); + const std::string typeName = scaleShift->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(MatMulWithOptimizedConstantFakeQuantizeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp index ff1ab2e21db..f96ff145315 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_transformation.cpp @@ -51,42 +51,45 @@ std::string MultiplyTransformation::getTestCaseName(testing::TestParamInfoGetParam(); + std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); - ngraph::Shape inputShape2 = inputShape1; - - if (param.broadcast) { - inputShape2[2] = 1; - inputShape2[3] = 1; - } - - auto fq1 = param.fakeQuantize1; - auto fq2 = param.fakeQuantize2; - - const auto input1 = std::make_shared(precision, inputShape1); - const auto fakeQuantize1 = fq1.empty() ? - nullptr : - ngraph::builder::makeFakeQuantize( - input1, precision, fq1.quantizationLevel, fq1.constantShape, - fq1.inputLowValues, fq1.inputHighValues, fq1.outputLowValues, fq1.outputHighValues); - - const auto input2 = std::make_shared(precision, inputShape2); - const auto fakeQuantize2 = fq2.empty() ? - nullptr : - ngraph::builder::makeFakeQuantize( - input2, precision, fq2.quantizationLevel, fq2.constantShape, - fq2.inputLowValues, fq2.inputHighValues, fq2.outputLowValues, fq2.outputHighValues); - - const auto multiply = std::make_shared( - fq1.empty() ? input1 : fakeQuantize1, - fq2.empty() ? input2 : fakeQuantize2); - - ngraph::ResultVector results{ std::make_shared(multiply) }; - function = std::make_shared(results, ngraph::ParameterVector{ input1, input2 }, "MultiplyTransformation"); + function = ngraph::builder::subgraph::MultiplyFunction::getOriginal( + precision, + inputShape, + param.broadcast, + param.fakeQuantize1, + param.fakeQuantize2); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void MultiplyTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + MultiplyTestValues param; + std::tie(precision, inputShape, targetDevice, param) = this->GetParam(); + + const auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(). + setPrecisionsOnActivations(param.precisionOnActivations); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + const auto output = transformed->get_output_op(0); + + if ((!param.fakeQuantize1.empty()) && (!param.fakeQuantize2.empty())) { + const auto mul = output->get_input_node_shared_ptr(0); + const std::string typeName = mul->get_type_name(); + ASSERT_EQ("Eltwise", typeName); + + for (size_t i = 0; i < param.expectedPrecisions.size(); ++i) { + const auto curPrecision = mul->get_input_element_type(i); + const auto expectedPrecision = param.expectedPrecisions[i]; + ASSERT_EQ(curPrecision, expectedPrecision); + } + } } TEST_P(MultiplyTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp index 500bbc4245b..0b5ef33f05d 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/multiply_with_one_parent_transformation.cpp @@ -16,29 +16,28 @@ namespace LayerTestsDefinitions { std::string MultiplyWithOneParentTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShape; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; std::string targetDevice; MultiplyWithOneParentTransformationValues values; std::tie(netPrecision, inputShape, targetDevice, values) = obj.param; std::ostringstream result; - result << netPrecision.name() << "_" << CommonTestUtils::vec2str(inputShape); + result << netPrecision << "_" << CommonTestUtils::vec2str(inputShape); return result.str(); } void MultiplyWithOneParentTransformation::SetUp() { threshold = 0.01f; - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShape; + ngraph::element::Type netPrecision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; MultiplyWithOneParentTransformationValues values; std::tie(netPrecision, inputShape, targetDevice, values) = this->GetParam(); - auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - function = ngraph::builder::subgraph::MultiplyWithOneParentFunction::getOriginal(precision, inputShape, values.fakeQuantize); + function = ngraph::builder::subgraph::MultiplyWithOneParentFunction::getOriginal(netPrecision, inputShape, values.fakeQuantize); } TEST_P(MultiplyWithOneParentTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp index e8a80f7c7a9..c1a21b5db32 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mvn_transformation.cpp @@ -51,6 +51,29 @@ void MVNTransformation::SetUp() { shape, reductionAxes, normalizeVariance); + + validate(); +} + +void MVNTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape shape; + std::string targetDevice; + ngraph::AxisSet reductionAxes; + bool normalizeVariance; + std::tie(precision, shape, targetDevice, reductionAxes, normalizeVariance) = this->GetParam(); + + auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + if (normalizeVariance) { + ASSERT_EQ("MVN", typeName); + } else { + ASSERT_EQ("ScaleShiftIE", typeName); + } } TEST_P(MVNTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/normalize_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/normalize_transformation.cpp index edaaf823bbc..2dba6bae513 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/normalize_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/normalize_transformation.cpp @@ -60,6 +60,30 @@ void NormalizeL2Transformation::SetUp() { axes, fuseMultiply, shift); + + validate(); +} + +void NormalizeL2Transformation::validate() { + ngraph::element::Type precision; + std::pair shapes; + std::string targetDevice; + std::vector axes; + bool fuseMultiply; + bool shift; + std::tie(precision, shapes, targetDevice, axes, fuseMultiply, shift) = this->GetParam(); + + auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto normalize = output->get_input_node_shared_ptr(0); + const std::string typeName = normalize->get_type_name(); + ASSERT_EQ("NormalizeIE", typeName); + + const auto inputPrecision = normalize->get_input_element_type(0); + const auto expectedPrecision = shift ? ngraph::element::f32 : ngraph::element::u8; + ASSERT_EQ(inputPrecision, expectedPrecision); } TEST_P(NormalizeL2Transformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp index fa57d7dd7af..863018e0305 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/prelu_transformation.cpp @@ -19,14 +19,14 @@ std::string PReluTransformation::getTestCaseName(testing::TestParamInfoGetParam(); + PReluTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); + const auto fqOnData = testValues.fakeQuantize; return FuncTestUtils::createAndFillBlobConsistently( info.getTensorDesc(), static_cast(fqOnData.empty() ? 25.f : fqOnData.outputHighValues[0] - fqOnData.outputLowValues[0]), @@ -48,12 +49,33 @@ InferenceEngine::Blob::Ptr PReluTransformation::GenerateInput(const InferenceEng void PReluTransformation::SetUp() { ngraph::element::Type precision; ngraph::Shape inputShape; - ngraph::builder::subgraph::FakeQuantizeOnData fqOnData; - std::tie(precision, inputShape, targetDevice, fqOnData) = this->GetParam(); + PReluTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); - function = ngraph::builder::subgraph::PReluFunction::getOriginal(inputShape, precision, fqOnData); + function = ngraph::builder::subgraph::PReluFunction::getOriginal(inputShape, precision, testValues.fakeQuantize); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void PReluTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + PReluTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); + + auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + if ((!testValues.fakeQuantize.empty()) && (!testValues.isSubtract)) { + ASSERT_EQ("ScaleShiftIE", typeName); + } else { + ASSERT_EQ("ReLUIE", typeName); + } } TEST_P(PReluTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/relu_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/relu_transformation.cpp index c6e6cc61151..e06285eeaba 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/relu_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/relu_transformation.cpp @@ -19,14 +19,14 @@ std::string ReluTransformation::getTestCaseName(testing::TestParamInfoGetParam(); + ReluTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); + const auto fqOnData = testValues.fakeQuantize; return FuncTestUtils::createAndFillBlobConsistently( info.getTensorDesc(), static_cast(fqOnData.empty() ? 25.f : fqOnData.outputHighValues[0] - fqOnData.outputLowValues[0]), @@ -48,12 +49,34 @@ InferenceEngine::Blob::Ptr ReluTransformation::GenerateInput(const InferenceEngi void ReluTransformation::SetUp() { ngraph::element::Type precision; ngraph::Shape inputShape; - ngraph::builder::subgraph::FakeQuantizeOnData fqOnData; - std::tie(precision, inputShape, targetDevice, fqOnData) = this->GetParam(); + ReluTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); - function = ngraph::builder::subgraph::ReluFunction::getOriginal(inputShape, precision, fqOnData); + function = ngraph::builder::subgraph::ReluFunction::getOriginal(inputShape, precision, testValues.fakeQuantize); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void ReluTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + ReluTestValues testValues; + std::tie(precision, inputShape, targetDevice, testValues) = this->GetParam(); + + auto params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParamsU8I8(); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + if ((!testValues.fakeQuantize.empty()) && (!testValues.isSubtract)) { + ASSERT_EQ("ScaleShiftIE", typeName); + } else { + ASSERT_EQ("Relu", typeName); + } } TEST_P(ReluTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp index 2c2a2088866..9afc5c064e3 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/reshape_transformation.cpp @@ -48,6 +48,28 @@ void ReshapeTransformation::SetUp() { param.reshapeConstValues, netPrecision, param.fakeQuantize); + + validate(); +} + +void ReshapeTransformation::validate() { + ngraph::element::Type netPrecision; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + ReshapeTransformationParam param; + std::tie(netPrecision, targetDevice, params, param) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + + if (param.isTransformed) { + ASSERT_EQ("ScaleShiftIE", typeName); + } else { + ASSERT_EQ("Reshape", typeName); + } } TEST_P(ReshapeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp index f3e23b76bac..5289acc9f2f 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/split_transformation.cpp @@ -59,10 +59,10 @@ void SplitTransformation::SetUp() { param.splitedAxis, param.numSplit); - validateNGraph(); + validate(); } -void SplitTransformation::validateNGraph() { +void SplitTransformation::validate() { ngraph::element::Type netPrecision; ngraph::Shape inputShape; std::string targetDevice; @@ -70,15 +70,15 @@ void SplitTransformation::validateNGraph() { SplitTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); - ngraph::pass::low_precision::LowPrecisionTransformations additionalTransformations; - additionalTransformations.add(params); - auto transformed = transformNGraph(params, additionalTransformations); + ngraph::pass::low_precision::LowPrecisionTransformations transformations = getLowPrecisionTransformationsNGraph(params); + transformations.add(params); + const auto transformed = transformNGraph(params, transformations); EXPECT_EQ(param.numSplit, transformed->get_output_size()); for (size_t i = 0; i < param.numSplit; ++i) { - std::shared_ptr output = transformed->get_output_op(0); - std::shared_ptr scaleShift = output->get_input_node_shared_ptr(0); + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); const std::string typeName = scaleShift->get_type_name(); ASSERT_TRUE(typeName == "ScaleShiftIE" || typeName == "PowerIE" || typeName == "ConvolutionIE"); } diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp index b8e723716ed..80fd06ae846 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/squeeze_transformation.cpp @@ -32,7 +32,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::vector& valu } InferenceEngine::Blob::Ptr SqueezeTransformation::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; SqueezeTransformationParam squeezeParam; std::string targetDevice; @@ -49,7 +49,7 @@ InferenceEngine::Blob::Ptr SqueezeTransformation::GenerateInput(const InferenceE } std::string SqueezeTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; std::string targetDevice; SqueezeTransformationParam squeezeParam; @@ -65,20 +65,37 @@ std::string SqueezeTransformation::getTestCaseName(testing::TestParamInfoGetParam(); - ngraph::element::Type ngraphPrecision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); function = ngraph::builder::subgraph::SqueezeFunction::getOriginal( - ngraphPrecision, + netPrecision, squeezeParam.shape, squeezeParam.fakeQuantize, squeezeParam.squeezeAxes); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void SqueezeTransformation::validate() { + ngraph::element::Type netPrecision; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + SqueezeTransformationParam squeezeParam; + + std::tie(netPrecision, targetDevice, params, squeezeParam) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(SqueezeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp index 28e1ae82a1a..7d5971265f6 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_multiply_to_multiply_add_transformation.cpp @@ -38,15 +38,15 @@ void SubtractMultiplyToMultiplyAddTransformation::SetUp() { testValues.precision, testValues.fqOnData); - validateNGraph(); + validate(); } -void SubtractMultiplyToMultiplyAddTransformation::validateNGraph() { +void SubtractMultiplyToMultiplyAddTransformation::validate() { SubtractMultiplyToMultiplyAddTransformationTestValues testValues; std::tie(targetDevice, testValues) = this->GetParam(); const ngraph::pass::low_precision::LayerTransformation::Params params = LayerTestsUtils::LayerTransformationParamsNGraphFactory::createParams(); - auto transformed = transformNGraph(params); + auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); ASSERT_EQ(1ul, transformed->get_output_size()); std::shared_ptr output = transformed->get_output_op(0); diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp index 512e65d4e0f..dd6659780d4 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/subtract_transformation.cpp @@ -10,15 +10,16 @@ #include #include -#include "ngraph_functions/builders.hpp" #include +#include "lpt_ngraph_functions/subtract_function.hpp" + namespace LayerTestsDefinitions { -std::string SubtractTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; +std::string SubtractTransformation::getTestCaseName(testing::TestParamInfo obj) { + ngraph::element::Type netPrecision; + ngraph::Shape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; std::tie(netPrecision, inputShapes, targetDevice, params) = obj.param; @@ -27,34 +28,12 @@ std::string SubtractTransformation::getTestCaseName(testing::TestParamInfoGetParam(); - const auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); - const float k = 50.f; - - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); - const auto fakeQuantizeOnActivations = ngraph::builder::makeFakeQuantize( - input, precision, 256ul, { 1ul }, - { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); - - const auto weights = ngraph::opset1::Constant::create( - precision, - ngraph::Shape{ inputShape[1], inputShape[1], 1, 1 }, - std::vector(inputShape[1] * inputShape[1], 1)); - - const auto convolution = std::make_shared( - fakeQuantizeOnActivations == nullptr ? input : fakeQuantizeOnActivations, - ngraph::builder::makeFakeQuantize(weights, precision, 256ul, { 1ul }, { -128.f / k }, { 127.f / k }, { -128.f / k }, { 127.f / k }), - ngraph::Strides{ 1, 1 }, - ngraph::CoordinateDiff{ 0, 0 }, - ngraph::CoordinateDiff{ 0, 0 }, - ngraph::Strides{ 1, 1 }); - - ngraph::ResultVector results {std::make_shared(convolution)}; - function = std::make_shared(results, ngraph::ParameterVector { input }, "ReshapeTransformation"); + function = ngraph::builder::subgraph::SubtractFunction::getOriginal(netPrecision, inputShape); } TEST_P(SubtractTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp index 24a3b2fea88..e4417a1a236 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_after_matmul_transformation.cpp @@ -15,15 +15,15 @@ #include "functional_test_utils/plugin_cache.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" #include "functional_test_utils/blob_utils.hpp" -#include "ngraph_functions/pass/convert_prc.hpp" -#include "ngraph_functions/builders.hpp" + +#include "lpt_ngraph_functions/transpose_after_mat_mul_function.hpp" namespace LayerTestsDefinitions { std::string TransposeAfterMatMulTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; - InferenceEngine::SizeVector inputShapes; + ngraph::element::Type netPrecision; + ngraph::Shape inputShapes; std::string targetDevice; ngraph::pass::low_precision::LayerTransformation::Params params; bool perTensor; @@ -31,42 +31,40 @@ std::string TransposeAfterMatMulTransformation::getTestCaseName(testing::TestPar std::tie(netPrecision, inputShapes, targetDevice, params, perTensor, transposeChannelDim) = obj.param; std::ostringstream result; - result << netPrecision.name() << "_" << targetDevice << "_" << toString(params) << + result << netPrecision << "_" << targetDevice << "_" << toString(params) << (perTensor ? "_perTensor" : "_perChannel") << (transposeChannelDim ? "_transposeChannelDim" : "_notTransposeChannelDim"); return result.str(); } void TransposeAfterMatMulTransformation::SetUp() { - InferenceEngine::SizeVector inputShape; - InferenceEngine::Precision netPrecision; + ngraph::element::Type precision; + ngraph::Shape inputShape; ngraph::pass::low_precision::LayerTransformation::Params params; bool perTensor; bool transposeChannelDim; - std::tie(netPrecision, inputShape, targetDevice, params, perTensor, transposeChannelDim) = this->GetParam(); + std::tie(precision, inputShape, targetDevice, params, perTensor, transposeChannelDim) = this->GetParam(); - const auto precision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); + function = ngraph::builder::subgraph::TransposeAfterMatMulFunction::getOriginal(precision, inputShape); - const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape)); - input1->set_friendly_name("input1"); + validate(); +} - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape)); - input2->set_friendly_name("input2"); +void TransposeAfterMatMulTransformation::validate() { + ngraph::element::Type precision; + ngraph::Shape inputShape; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + bool perTensor; + bool transposeChannelDim; + std::tie(precision, inputShape, targetDevice, params, perTensor, transposeChannelDim) = this->GetParam(); - const float k = 50.f; - const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(input1, precision, 256ul, { 1ul }, { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); - input2->set_friendly_name("fakeQuantize1"); - const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize(input2, precision, 256ul, { 1ul }, { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); - input2->set_friendly_name("fakeQuantize2"); - const auto matMul = std::make_shared(fakeQuantize1, fakeQuantize2, false, false); - input2->set_friendly_name("matMul"); - const auto transpose = std::make_shared( - matMul, - ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 4ul }, { 0, 2, 1, 3 })); - transpose->set_friendly_name("transpose"); + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); - ngraph::ResultVector results{ std::make_shared(transpose) }; - function = std::make_shared(results, ngraph::ParameterVector{ input1, input2 }, "TransposeAfterMatMulTransformation"); + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(TransposeAfterMatMulTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_transformation.cpp index 750ba8ceb6f..03e60f134a6 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/transpose_transformation.cpp @@ -40,6 +40,22 @@ void TransposeTransformation::SetUp() { testValues.transposeConstValues, testValues.precisionBeforeFq, testValues.fqOnData); + + validate(); +} + +void TransposeTransformation::validate() { + ngraph::element::Type precision; + std::string targetDevice; + TransposeTransformationTestValues testValues; + std::tie(precision, targetDevice, testValues) = this->GetParam(); + + const auto transformed = transformNGraph(testValues.params, getLowPrecisionTransformationsNGraph(testValues.params)); + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + ASSERT_EQ("Reshape", typeName); } TEST_P(TransposeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp index 28192ef3cb0..576c5b20abb 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/unsqueeze_transformation.cpp @@ -30,7 +30,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::vector& valu } InferenceEngine::Blob::Ptr UnsqueezeTransformation::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; UnsqueezeTransformationParam squeezeParam; std::string targetDevice; @@ -47,7 +47,7 @@ InferenceEngine::Blob::Ptr UnsqueezeTransformation::GenerateInput(const Inferenc } std::string UnsqueezeTransformation::getTestCaseName(testing::TestParamInfo obj) { - InferenceEngine::Precision netPrecision; + ngraph::element::Type netPrecision; ngraph::pass::low_precision::LayerTransformation::Params params; std::string targetDevice; UnsqueezeTransformationParam unsqueezeParam; @@ -63,20 +63,37 @@ std::string UnsqueezeTransformation::getTestCaseName(testing::TestParamInfoGetParam(); - ngraph::element::Type ngraphPrecision = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); function = ngraph::builder::subgraph::UnsqueezeFunction::getOriginal( - ngraphPrecision, + netPrecision, unsqueezeParam.shape, unsqueezeParam.fakeQuantize, unsqueezeParam.unsqueezeAxes); ngraph::pass::InitNodeInfo().run_on_function(function); + validate(); +} + +void UnsqueezeTransformation::validate() { + ngraph::element::Type netPrecision; + std::string targetDevice; + ngraph::pass::low_precision::LayerTransformation::Params params; + UnsqueezeTransformationParam unsqueezeParam; + + std::tie(netPrecision, targetDevice, params, unsqueezeParam) = this->GetParam(); + + const auto transformed = transformNGraph(params, getLowPrecisionTransformationsNGraph(params)); + + const auto output = transformed->get_output_op(0); + const auto layer = output->get_input_node_shared_ptr(0); + const std::string typeName = layer->get_type_name(); + + ASSERT_EQ("ScaleShiftIE", typeName); } TEST_P(UnsqueezeTransformation, CompareWithRefImpl) { diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp index 06e4ba14661..1b3b6d03e3d 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/variadic_split_transformation.cpp @@ -66,10 +66,10 @@ void VariadicSplitTransformation::SetUp() { param.splitedAxis, param.splitLengths); - validateNGraph(); + validate(); } -void VariadicSplitTransformation::validateNGraph() { +void VariadicSplitTransformation::validate() { ngraph::element::Type netPrecision; ngraph::Shape inputShape; std::string targetDevice; @@ -77,15 +77,15 @@ void VariadicSplitTransformation::validateNGraph() { VariadicSplitTransformationParam param; std::tie(netPrecision, inputShape, targetDevice, params, param) = this->GetParam(); - ngraph::pass::low_precision::LowPrecisionTransformations additionalTransformations; - additionalTransformations.add(params); - auto transformed = transformNGraph(params, additionalTransformations); + ngraph::pass::low_precision::LowPrecisionTransformations transformations = getLowPrecisionTransformationsNGraph(params); + transformations.add(params); + const auto transformed = transformNGraph(params, transformations); ASSERT_EQ(param.splitLengths.size(), transformed->get_output_size()); for (size_t i = 0; i < param.splitLengths.size(); ++i) { - std::shared_ptr output = transformed->get_output_op(0); - std::shared_ptr scaleShift = output->get_input_node_shared_ptr(0); + const auto output = transformed->get_output_op(0); + const auto scaleShift = output->get_input_node_shared_ptr(0); const std::string typeName = scaleShift->get_type_name(); ASSERT_TRUE(typeName == "ScaleShiftIE" || typeName == "PowerIE" || typeName == "ConvolutionIE"); } diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp index 904cac83563..4f352d60cc5 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/base/low_precision_transformations/layer_transformation.hpp @@ -44,7 +44,7 @@ protected: std::shared_ptr transformNGraph( const ngraph::pass::low_precision::LayerTransformation::Params& params, - const ngraph::pass::low_precision::LowPrecisionTransformations additionalTransformations = {}); + const ngraph::pass::low_precision::LowPrecisionTransformations& transformations); static std::pair getQuantizationInterval(const ngraph::element::Type precision); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp index 2962265b732..3a2eb1b4d9d 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/add_function.hpp @@ -68,6 +68,13 @@ public: const std::vector& constValues, const std::string& additionalLayer); + static std::shared_ptr getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const bool broadcast, + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1, + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2); + static std::shared_ptr getReference( const ngraph::element::Type precision, const ngraph::Shape& inputShape, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp index c47412f74d8..75621b7d4ec 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/avg_pool_function.hpp @@ -6,7 +6,10 @@ #include #include + +#include "low_precision/layer_transformation.hpp" #include "common/fake_quantize_on_data.hpp" +#include "common/builders.hpp" namespace ngraph { namespace builder { @@ -14,26 +17,12 @@ namespace subgraph { class AvgPoolFunction { public: - class ActualValues { - public: - ngraph::element::Type lowPrecision; - std::vector subtractValues; - std::vector mutliplyValues; - }; - - class ExpectedValues { - public: - ngraph::element::Type activationPrecision; - std::vector subtractValues; - std::vector mutliplyValues; - }; - static std::shared_ptr getOriginal( - const ngraph::element::Type originalFunctionPrecision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& inputShape, const bool addFQ, const std::string additionalLayer, - const ActualValues& values); + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore); static std::shared_ptr getOriginal( const ngraph::element::Type originalFunctionPrecision, @@ -41,11 +30,13 @@ public: const FakeQuantizeOnData& fakeQuantizeOnData); static std::shared_ptr getReference( - const ngraph::element::Type originalFunctionPrecision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& inputShape, const bool addFQ, const std::string additionalLayer, - const ExpectedValues& values); + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter); }; } // namespace subgraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp index de18bb6f63e..51f65b664e0 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/concat_function.hpp @@ -84,11 +84,14 @@ public: const DequantizationOperations& dequantizationOperations); static std::shared_ptr getReference( - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& inputShape, const FakeQuantizeOnDataWithConstant& fakeQuantize1, const FakeQuantizeOnDataWithConstant& fakeQuantize2, - const DequantizationOperations& dequantizationOperations); + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationAfter); static std::shared_ptr getReferenceWithNeighbors( const ngraph::element::Type precision, @@ -96,6 +99,9 @@ public: const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, const FakeQuantizeOnData& fqOnData3, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2); @@ -105,6 +111,10 @@ public: const bool transparentIntermediate, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2); @@ -113,6 +123,10 @@ public: const ngraph::Shape& inputShape, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2); @@ -122,6 +136,10 @@ public: const bool transparentIntermediate, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2); @@ -131,8 +149,11 @@ public: const bool multiChannel, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, - const DequantizationOperations& dequantizationOperations1, - const DequantizationOperations& dequantizationOperations2); + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationAfter1, + const DequantizationOperations& dequantizationAfter2); static std::shared_ptr getReferenceWithIntermediateWithConstant( const ngraph::element::Type precision, @@ -152,6 +173,8 @@ public: const FakeQuantizeOnDataWithConstant& fqOnData1, const FakeQuantizeOnDataWithConstant& fqOnData2, const FakeQuantizeOnDataWithConstant& fqOnData3, + const ngraph::element::Type precisionBeforeOp, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations); private: diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp index 21a6ae13f10..090f2dbaaeb 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/depth_to_space_function.hpp @@ -38,6 +38,7 @@ public: const size_t blockSize, const ngraph::element::Type precisionBeforeDequantization, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter); }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp index f392873b213..ec252ca4c06 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_and_two_output_branches_with_convolution_function.hpp @@ -6,9 +6,11 @@ #include #include + #include #include "lpt_ngraph_functions/common/fake_quantize_on_data.hpp" #include "lpt_ngraph_functions/common/fake_quantize_on_weights.hpp" +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" namespace ngraph { namespace builder { @@ -16,42 +18,25 @@ namespace subgraph { class FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction { public: - class ActualValues { - public: - FakeQuantizeOnData fqOnData; - FakeQuantizeOnWeights fqOnWeights1; - FakeQuantizeOnWeights fqOnWeights2; - }; - - class ExpectedValues { - public: - FakeQuantizeOnData fqOnData; - FakeQuantizeOnWeights fqOnWeights1; - std::vector multiplay1Values; - FakeQuantizeOnWeights fqOnWeights2; - std::vector multiplay2Values; - }; - static std::shared_ptr getOriginal( const ngraph::element::Type precision, const ngraph::Shape& inputShape, - const ActualValues& values); + const FakeQuantizeOnData& fqOnData, + const FakeQuantizeOnWeights fqOnWeights1, + FakeQuantizeOnWeights fqOnWeights2); static std::shared_ptr getReference( const ngraph::element::Type precision, const ngraph::Shape& inputShape, const ngraph::pass::low_precision::LayerTransformation::Params& params, - const ExpectedValues& values); + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData, + const ngraph::element::Type precisionBeforeOp, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOp, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter1, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter2); }; -inline std::ostream& operator<<(std::ostream& out, const FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ActualValues& values) { - return out << "_" << values.fqOnData << "_" << values.fqOnWeights1 << "_" << values.fqOnWeights2; -} - -inline std::ostream& operator<<(std::ostream& out, const FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::ExpectedValues& values) { - return out << "_" << values.fqOnData << "_" << values.fqOnWeights1 << "_" << values.fqOnWeights2; -} - } // namespace subgraph } // namespace builder } // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp index 339758aa784..91e94f9c9a3 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/fake_quantize_function.hpp @@ -9,6 +9,8 @@ #include #include "low_precision/layer_transformation.hpp" #include "common/fake_quantize_on_data.hpp" +#include "lpt_ngraph_functions/common/builders.hpp" + namespace ngraph { namespace builder { @@ -27,8 +29,7 @@ public: const bool updatePrecisions, const FakeQuantizeOnData& fakeQuantizeOnData, const ngraph::element::Type fakeQuantizeOutputPrecision, - const std::vector& expectedSubtractValues, - const std::vector& expectedMultiplyValues); + const ngraph::builder::subgraph::DequantizationOperations& dequantization); }; } // namespace subgraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp index ac1944c1b1d..672d72e0990 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/mat_mul_function.hpp @@ -16,6 +16,19 @@ namespace subgraph { class MatMulFunction { public: + static std::shared_ptr getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape inputShape, + const float low, + const float high); + + static std::shared_ptr getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape inputShape1, + const ngraph::Shape inputShape2, + const bool transpose1, + const bool transpose2); + static std::shared_ptr getOriginal( const ngraph::element::Type precision, const ngraph::Shape& inputShape1, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp index fac6d62ab40..e7282a6af57 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/max_pool_function.hpp @@ -25,6 +25,7 @@ public: const ngraph::Shape& inputShape, const ngraph::element::Type precisionBeforeDequantization, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter); }; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp index c86f3ee666d..a5a1aabfcc9 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/multiply_function.hpp @@ -40,6 +40,13 @@ inline std::ostream& operator<<(std::ostream& out, const MultiplyValues& values) class MultiplyFunction { public: static std::shared_ptr get(const ngraph::Shape& inputShape, const MultiplyValues& actualValues); + + static std::shared_ptr getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const bool broadcast, + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1, + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2); }; } // namespace subgraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp index 2dc74889faa..94a391502c7 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/normalize_l2_function.hpp @@ -11,40 +11,12 @@ #include +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" + namespace ngraph { namespace builder { namespace subgraph { -class NormalizeL2ActualValues { -public: - ngraph::element::Type precision; - std::vector axes; - std::vector subtractValues; - std::vector mutliplyValues; -}; - -inline std::ostream& operator<<(std::ostream& out, const NormalizeL2ActualValues& values) { - return out << - "_" << values.precision << "_" << values.axes.size() << - "_subtract" << values.subtractValues.size() << - "_mutliply" << values.mutliplyValues.size(); -} - -class NormalizeL2ExpectedValues { -public: - ngraph::element::Type precision; - std::vector axes; - std::vector subtractValues; - std::vector mutliplyValues; -}; - -inline std::ostream& operator<<(std::ostream& out, const NormalizeL2ExpectedValues& values) { - return out << - "_" << values.precision << "_" << values.axes.size() << - "_subtract" << values.subtractValues.size() << - "_mutliply" << values.mutliplyValues.size(); -} - class NormalizeL2Function { public: static std::shared_ptr getOriginal( @@ -56,16 +28,20 @@ public: const bool shift); static std::shared_ptr getOriginal( - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& shape, const ngraph::op::EpsMode& epsMode, - const NormalizeL2ActualValues& actualValues); + const std::vector& axes, + const ngraph::builder::subgraph::DequantizationOperations& dequantization); static std::shared_ptr getReference( - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& shape, const ngraph::op::EpsMode& epsMode, - const NormalizeL2ExpectedValues& expectedValues); + const std::vector& axes, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter); }; } // namespace subgraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp index ae8d795ed39..695de1ef32f 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/split_function.hpp @@ -35,6 +35,8 @@ public: static std::shared_ptr getReference( const ngraph::Shape& inputShape, + const ngraph::element::Type inputPrecision, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, const ngraph::element::Type precisionAfterOperation, const std::vector& dequantizationAfter, const int64_t splitedAxis, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp new file mode 100644 index 00000000000..43ed4e05bb3 --- /dev/null +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/subtract_function.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" +#include "ngraph_functions/subgraph_builders.hpp" +#include "lpt_ngraph_functions/common/builders.hpp" + +namespace ngraph { +namespace builder { +namespace subgraph { + +class SubtractFunction { +public: + static std::shared_ptr getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape); +}; + +} // namespace subgraph +} // namespace builder +} // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp new file mode 100644 index 00000000000..7376cb30b15 --- /dev/null +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/transpose_after_mat_mul_function.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "lpt_ngraph_functions/common/dequantization_operations.hpp" +#include "ngraph_functions/subgraph_builders.hpp" +#include "lpt_ngraph_functions/common/builders.hpp" + +namespace ngraph { +namespace builder { +namespace subgraph { + +class TransposeAfterMatMulFunction { +public: + static std::shared_ptr getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape); +}; + +} // namespace subgraph +} // namespace builder +} // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp index ae610611a3f..d3735c2f194 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/include/lpt_ngraph_functions/variadic_split_function.hpp @@ -35,6 +35,8 @@ public: static std::shared_ptr getReference( const ngraph::Shape& inputShape, + const ngraph::element::Type inputPrecision, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, const ngraph::element::Type precisionAfterOperation, const std::vector& dequantizationAfter, const int64_t splitedAxis, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp index b5d7d1826a0..32a2a459f8b 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/add_function.cpp @@ -8,6 +8,7 @@ #include "ngraph/opsets/opset1.hpp" #include "lpt_ngraph_functions/common/dequantization_operations.hpp" +#include "ngraph_functions/subgraph_builders.hpp" #include "lpt_ngraph_functions/add_function.hpp" using namespace ngraph::pass::low_precision; @@ -109,6 +110,44 @@ std::shared_ptr AddFunction::getOriginal( return std::make_shared(results, parameters, "AddTransformation"); } +std::shared_ptr AddFunction::getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const bool broadcast, + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData1, + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData2) { + ngraph::Shape inputShape2 = inputShape; + + if (broadcast) { + inputShape2[2] = 1; + inputShape2[3] = 1; + } + + auto fq1 = fqOnData1; + auto fq2 = fqOnData2; + + const auto input1 = std::make_shared(precision, inputShape); + const auto fakeQuantize1 = fq1.empty() ? + nullptr : + ngraph::builder::makeFakeQuantize( + input1, precision, fq1.quantizationLevel, fq1.constantShape, + fq1.inputLowValues, fq1.inputHighValues, fq1.outputLowValues, fq1.outputHighValues); + + const auto input2 = std::make_shared(precision, inputShape2); + const auto fakeQuantize2 = fq2.empty() ? + nullptr : + ngraph::builder::makeFakeQuantize( + input2, precision, fq2.quantizationLevel, fq2.constantShape, + fq2.inputLowValues, fq2.inputHighValues, fq2.outputLowValues, fq2.outputHighValues); + + const auto add = std::make_shared( + fq1.empty() ? input1 : fakeQuantize1, + fq2.empty() ? input2 : fakeQuantize2); + + ngraph::ResultVector results{ std::make_shared(add) }; + return std::make_shared(results, ngraph::ParameterVector{ input1, input2 }, "AddTransformation"); +} + std::shared_ptr AddFunction::getReference( const ngraph::element::Type precision, const ngraph::Shape& inputShape, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp index 2e3e2ead5dd..c1a87fd558d 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/avg_pool_function.cpp @@ -6,6 +6,7 @@ #include #include "low_precision/network_helper.hpp" +#include "lpt_ngraph_functions/common/builders.hpp" #include "lpt_ngraph_functions/avg_pool_function.hpp" #include "ngraph_functions/subgraph_builders.hpp" @@ -15,31 +16,18 @@ namespace builder { namespace subgraph { std::shared_ptr AvgPoolFunction::getOriginal( - const ngraph::element::Type originalFunctionPrecision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& inputShape, const bool addFQ, const std::string additionalLayer, - const ActualValues& values) { - const auto input = std::make_shared(values.lowPrecision, ngraph::Shape(inputShape)); + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore) { + const auto input = std::make_shared(inputPrecision, ngraph::Shape(inputShape)); std::shared_ptr parent = input; - const std::shared_ptr convert = std::make_shared(parent, originalFunctionPrecision); - parent = convert; - - if (!values.subtractValues.empty()) { - const std::shared_ptr subtract = std::make_shared( - parent, - std::make_shared(originalFunctionPrecision, Shape({ values.subtractValues.size() }), values.subtractValues)); - parent = subtract; - } - - const std::shared_ptr multiply = std::make_shared( - parent, - std::make_shared(originalFunctionPrecision, Shape({ values.mutliplyValues.size() }), values.mutliplyValues)); - parent = multiply; + const auto dequantization = makeDequantization(input, dequantizationBefore); const std::shared_ptr avgPool = std::make_shared( - parent, + dequantization, Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, @@ -48,7 +36,6 @@ std::shared_ptr AvgPoolFunction::getOriginal( op::RoundingType::FLOOR); std::shared_ptr lastLayer = avgPool; - if (additionalLayer == "maxpool") { lastLayer = std::make_shared( lastLayer, @@ -61,7 +48,7 @@ std::shared_ptr AvgPoolFunction::getOriginal( if (addFQ) { lastLayer = ngraph::builder::makeFakeQuantize( - lastLayer, originalFunctionPrecision, 256, {}, { 0 }, { 255 }, { 0 }, { 255 }); + lastLayer, ngraph::element::f32, 256, {}, { 0 }, { 255 }, { 0 }, { 255 }); } lastLayer->set_friendly_name("output"); @@ -94,30 +81,30 @@ std::shared_ptr AvgPoolFunction::getOriginal( } std::shared_ptr AvgPoolFunction::getReference( - const ngraph::element::Type originalFunctionPrecision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& inputShape, const bool addFQ, const std::string additionalLayer, - const ExpectedValues& values) { - auto input = std::make_shared(values.activationPrecision, ngraph::Shape(inputShape)); - std::shared_ptr parent = input; + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) { + auto input = std::make_shared(inputPrecision, ngraph::Shape(inputShape)); + const auto deqBefore = makeDequantization(input, dequantizationBefore); const std::shared_ptr avgPool = std::make_shared>( - parent, + deqBefore, Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, Shape{ 2, 2 }, true, op::RoundingType::FLOOR); - const auto avgPoolPrecision = addFQ ? originalFunctionPrecision : values.activationPrecision; - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(avgPool, avgPoolPrecision); - - parent = avgPool; + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(avgPool, precisionAfterOperation); + std::shared_ptr lastLayer = avgPool; if (additionalLayer == "maxpool") { - parent = std::make_shared( - parent, + lastLayer = std::make_shared( + lastLayer, Strides{ 1, 1 }, Shape{ 1, 1 }, Shape{ 0, 0 }, @@ -125,28 +112,11 @@ std::shared_ptr AvgPoolFunction::getReference( op::RoundingType::FLOOR); } - if (avgPoolPrecision != originalFunctionPrecision) { - const std::shared_ptr convert = std::make_shared(parent, originalFunctionPrecision); - parent = convert; - } - - if (!values.subtractValues.empty()) { - const std::shared_ptr subtract = std::make_shared>( - parent, - std::make_shared(originalFunctionPrecision, Shape({ values.subtractValues.size() }), values.subtractValues)); - - parent = subtract; - } - - const std::shared_ptr multiply = std::make_shared>( - parent, - std::make_shared(originalFunctionPrecision, Shape({ values.mutliplyValues.size() }), values.mutliplyValues)); - - std::shared_ptr lastLayer = multiply; + lastLayer = makeDequantization(lastLayer, dequantizationAfter); if (addFQ) { lastLayer = ngraph::builder::makeFakeQuantize( - lastLayer, originalFunctionPrecision, 256, {}, { 0 }, { 255 }, { 0 }, { 255 }); + lastLayer, ngraph::element::f32, 256, {}, { 0 }, { 255 }, { 0 }, { 255 }); } lastLayer->set_friendly_name("output"); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp index 7716abdb98a..49b762be9ac 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/concat_function.cpp @@ -558,27 +558,36 @@ std::shared_ptr ConcatFunction::getReference( } std::shared_ptr ConcatFunction::getReference( - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& inputShape, const FakeQuantizeOnDataWithConstant& fqOnData1, const FakeQuantizeOnDataWithConstant& fqOnData2, - const DequantizationOperations& dequantizationOperations) { - const auto input1 = std::make_shared(precision, inputShape); + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationAfter) { + const auto input1 = std::make_shared(inputPrecision, inputShape); input1->set_friendly_name("input1"); - const auto fakeQuantize1 = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); - const std::vector inputShape2 = inputShape; - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); + const auto fakeQuantize1 = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(input1, inputPrecision, fqOnData1); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore); + + const auto input2 = std::make_shared(inputPrecision, inputShape); input2->set_friendly_name("input2"); - const auto fakeQuantize2 = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); + + const auto fakeQuantize2 = ngraph::builder::subgraph::makeFakeQuantizeTypeRelaxed(input2, inputPrecision, fqOnData2); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore); const std::shared_ptr concat = std::make_shared>( - ngraph::OutputVector{ fakeQuantize1->output(0), fakeQuantize2->output(0) }, 1); + ngraph::OutputVector{ deqBefore1, deqBefore2 }, 1); auto& rtInfo = concat->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("concat"); + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOperation); - const std::shared_ptr lastDequantization = makeDequantization(concat, dequantizationOperations); + const auto lastDequantization = makeDequantization(concat, dequantizationAfter); lastDequantization->set_friendly_name("output"); ngraph::ResultVector results{ std::make_shared(lastDequantization) }; @@ -587,23 +596,6 @@ std::shared_ptr ConcatFunction::getReference( ngraph::ParameterVector{ input1, input2 }, "ConcatTransformation"); - if (fqOnData1.outputPrecision != fqOnData2.outputPrecision) { - throw std::runtime_error("FakeQuantize expected precisions are different"); - } - const ngraph::element::Type fqOnDataPrecision = fqOnData1.outputPrecision; - if (fqOnDataPrecision != ngraph::element::undefined) { - if (fakeQuantize1->get_output_element_type(0) != fakeQuantize2->get_output_element_type(0)) { - throw std::runtime_error("FakeQuantize operation precisions are different"); - } - const ngraph::element::Type fakeQuantizePrecision = fakeQuantize1->get_output_element_type(0); - - if (fqOnDataPrecision != fakeQuantizePrecision) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize2, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat, fqOnDataPrecision); - } - } - return function; } @@ -613,25 +605,37 @@ std::shared_ptr ConcatFunction::getReferenceWithNeighbors( const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, const FakeQuantizeOnData& fqOnData3, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2) { - const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input1 = std::make_shared(precision, inputShape); input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); fakeQuantize1->set_friendly_name("fakeQuantize1"); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore); - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input2 = std::make_shared(precision, inputShape); input2->set_friendly_name("input2"); - const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); - fakeQuantize2->set_friendly_name("fakeQuantize2"); - const auto input3 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); + fakeQuantize2->set_friendly_name("fakeQuantize2"); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore); + + const auto input3 = std::make_shared(precision, inputShape); input3->set_friendly_name("input3"); + const auto fakeQuantize3 = makeFakeQuantizeTypeRelaxed(input3, precision, fqOnData3); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize3, precisionBeforeOp); fakeQuantize3->set_friendly_name("fakeQuantize3"); + const auto deqBefore3 = makeDequantization(fakeQuantize3, dequantizationBefore); const auto concat1 = std::make_shared( - ngraph::OutputVector { fakeQuantize1->output(0), fakeQuantize2->output(0) }, + ngraph::OutputVector { deqBefore1, deqBefore2 }, 1ull); concat1->set_friendly_name("concat1"); @@ -639,7 +643,7 @@ std::shared_ptr ConcatFunction::getReferenceWithNeighbors( rtInfo1["Variant::std::string"] = std::make_shared>("concat1"); const auto concat2 = std::make_shared( - ngraph::OutputVector { fakeQuantize2->output(0), fakeQuantize3->output(0) }, + ngraph::OutputVector { deqBefore2, deqBefore3 }, 1ull); concat2->set_friendly_name("concat2"); @@ -662,26 +666,6 @@ std::shared_ptr ConcatFunction::getReferenceWithNeighbors( ngraph::ParameterVector { input1, input2, input3 }, "ConcatWithNeighborsTransformation"); - if ((fqOnData1.outputPrecision != fqOnData2.outputPrecision) || (fqOnData2.outputPrecision != fqOnData3.outputPrecision)) { - throw std::runtime_error("FakeQuantize expected precisions are different"); - } - const ngraph::element::Type fqOnDataPrecision = fqOnData1.outputPrecision; - if (fqOnDataPrecision != ngraph::element::undefined) { - if ((fakeQuantize1->get_output_element_type(0) != fakeQuantize2->get_output_element_type(0)) || - (fakeQuantize2->get_output_element_type(0) != fakeQuantize3->get_output_element_type(0))) { - throw std::runtime_error("FakeQuantize operation precisions are different"); - } - const ngraph::element::Type fakeQuantizePrecision = fakeQuantize1->get_output_element_type(0); - - if (fqOnDataPrecision != fakeQuantizePrecision) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize2, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize3, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat2, fqOnDataPrecision); - } - } - return function; } @@ -691,38 +675,46 @@ std::shared_ptr ConcatFunction::getReferenceWithIntermediate( const bool transparentIntermediate, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, - const DequantizationOperations& dequantizationOperations1, - const DequantizationOperations& dequantizationOperations2) { + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationAfter1, + const DequantizationOperations& dequantizationAfter2) { const std::vector inputShape1 = { inputShape[0], inputShape[1], inputShape[2] - (transparentIntermediate ? 2 : 0), inputShape[3] - (transparentIntermediate ? 2 : 0) }; - const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape1)); input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); fakeQuantize1->set_friendly_name("fakeQuantize1"); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore1); const std::vector inputShape2 = { inputShape[0], inputShape[1], inputShape[2], inputShape[3] }; const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); input2->set_friendly_name("input2"); const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); fakeQuantize2->set_friendly_name("fakeQuantize2"); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore1); std::shared_ptr intermediateOp; if (transparentIntermediate) { - intermediateOp = makeMaxPool(fakeQuantize2->output(0), { 3, 3 }); + intermediateOp = makeMaxPool(deqBefore2, { 3, 3 }); } else { - auto weights = ngraph::opset1::Constant::create( + const auto weights = ngraph::opset1::Constant::create( precision, ngraph::Shape{ inputShape[1], inputShape[1], 1, 1 }, std::vector(inputShape[1] * inputShape[1], 1)); intermediateOp = std::make_shared( - fakeQuantize2->output(0), + deqBefore2, weights, ngraph::Strides{ 1, 1 }, ngraph::CoordinateDiff{ 0, 0 }, @@ -733,25 +725,22 @@ std::shared_ptr ConcatFunction::getReferenceWithIntermediate( intermediateOp->set_friendly_name("intermediate"); const std::shared_ptr concat = std::make_shared( - ngraph::OutputVector { fakeQuantize1->output(0), intermediateOp->output(0) }, + ngraph::OutputVector { deqBefore1, intermediateOp }, 1); concat->set_friendly_name("concat"); + low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOperation); auto& rtInfo = concat->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("concat"); - const std::shared_ptr lastDequantization1 = dequantizationOperations1.empty() ? - concat : - makeDequantization(concat, dequantizationOperations1); + const std::shared_ptr lastDequantization1 = makeDequantization(concat, dequantizationAfter1); lastDequantization1->set_friendly_name("concat"); - const std::shared_ptr lastDequantization2 = dequantizationOperations2.empty() ? - nullptr : - makeDequantization(intermediateOp, dequantizationOperations2); + const std::shared_ptr lastDequantization2 = makeDequantization(intermediateOp, dequantizationAfter2); auto weights = ngraph::opset1::Constant::create(precision, ngraph::Shape{ inputShape[1], inputShape[1], 1, 1 }, { 1 }); auto convolution = std::make_shared( - lastDequantization2 == nullptr ? intermediateOp : lastDequantization2, + lastDequantization2, weights, ngraph::Strides{ 1, 1 }, ngraph::CoordinateDiff{ 0, 0 }, @@ -769,33 +758,6 @@ std::shared_ptr ConcatFunction::getReferenceWithIntermediate( ngraph::ParameterVector{ input1, input2 }, "ConcatWithIntermediateTransformation"); - if ((fqOnData1.outputPrecision != fqOnData2.outputPrecision)) { - throw std::runtime_error("FakeQuantize expected precisions are different"); - } - const ngraph::element::Type fqOnDataPrecision = fqOnData1.outputPrecision; - if (fqOnDataPrecision != ngraph::element::undefined) { - if (fakeQuantize1->get_output_element_type(0) != fakeQuantize2->get_output_element_type(0)) { - throw std::runtime_error("FakeQuantize operation precisions are different"); - } - const ngraph::element::Type fakeQuantizePrecision = fakeQuantize1->get_output_element_type(0); - - if (fqOnDataPrecision != fakeQuantizePrecision) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize2, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat, fqOnDataPrecision); - - auto intermediateOpTr = std::dynamic_pointer_cast(intermediateOp); - if (intermediateOpTr != nullptr) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(intermediateOp, fqOnDataPrecision); - } else { - // set precision to explicitly to have updated precision during transformation - for (size_t i = 0; i < intermediateOp->get_output_size(); ++i) { - intermediateOp->set_output_type(i, fqOnDataPrecision, intermediateOp->get_output_partial_shape(i)); - } - } - } - } - return function; } @@ -804,6 +766,10 @@ std::shared_ptr ConcatFunction::getReferenceWithSplitedInterme const ngraph::Shape& inputShape, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2) { size_t numSplit = 2; @@ -818,50 +784,45 @@ std::shared_ptr ConcatFunction::getReferenceWithSplitedInterme const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape1)); input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); fakeQuantize1->set_friendly_name("fakeQuantize1"); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionAfterOperation); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore1); const std::vector inputShape2 = { inputShape[0], inputShape[1], inputShape[2], inputShape[3] }; const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); input2->set_friendly_name("input2"); + const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); fakeQuantize2->set_friendly_name("fakeQuantize2"); - - const ngraph::element::Type fqOnDataPrecision = fqOnData1.outputPrecision; - if (fqOnDataPrecision != ngraph::element::undefined) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize2, fqOnDataPrecision); - } + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionAfterOperation); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore1); std::shared_ptr intermediateOp; const auto constant = std::make_shared(element::i64, Shape{ }, splitedAxis); - intermediateOp = std::make_shared(fakeQuantize2->output(0), constant, numSplit); + intermediateOp = std::make_shared(deqBefore2, constant, numSplit); intermediateOp->set_friendly_name("intermediate"); const std::shared_ptr concat = std::make_shared( - ngraph::OutputVector{ fakeQuantize1->output(0), intermediateOp->output(0) }, splitedAxis); + ngraph::OutputVector{ deqBefore1, intermediateOp->output(0) }, splitedAxis); concat->set_friendly_name("concat"); auto& rtInfo = concat->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("concat"); - const std::shared_ptr lastDequantization1 = dequantizationOperations1.empty() ? - concat : - makeDequantization(concat, dequantizationOperations1); - - const std::shared_ptr lastDequantization2 = dequantizationOperations2.empty() ? - nullptr : - makeDequantization(intermediateOp->output(1), dequantizationOperations2); + const auto lastDequantization1 = makeDequantization(concat, dequantizationOperations1); + const auto lastDequantization2 = makeDequantization(intermediateOp->output(1), dequantizationOperations2); auto weights = ngraph::opset1::Constant::create( precision, ngraph::Shape{ inputShape[1] / numSplit, inputShape[1] / numSplit, 1, 1 }, { 1 }); auto convolution = std::make_shared( - lastDequantization2 == nullptr ? intermediateOp : lastDequantization2, + lastDequantization2, weights, ngraph::Strides{ 1, 1 }, ngraph::CoordinateDiff{ 0, 0 }, @@ -879,15 +840,6 @@ std::shared_ptr ConcatFunction::getReferenceWithSplitedInterme ngraph::ParameterVector{ input1, input2 }, "ConcatWithIntermediateTransformation"); - if ((fqOnData1.outputPrecision != fqOnData2.outputPrecision)) { - throw std::runtime_error("FakeQuantize expected precisions are different"); - } - if (fqOnDataPrecision != ngraph::element::undefined) { - if (fakeQuantize1->get_output_element_type(0) != fakeQuantize2->get_output_element_type(0)) { - throw std::runtime_error("FakeQuantize operation precisions are different"); - } - } - return function; } @@ -897,6 +849,10 @@ std::shared_ptr ConcatFunction::getReferenceSelectionWithInter const bool transparentIntermediate, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore1, + const DequantizationOperations& dequantizationBefore2, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations1, const DequantizationOperations& dequantizationOperations2) { const std::vector inputShape1 = { @@ -908,8 +864,11 @@ std::shared_ptr ConcatFunction::getReferenceSelectionWithInter const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape1)); input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); fakeQuantize1->set_friendly_name("fakeQuantize1"); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore1); const std::vector inputShape2 = { inputShape[0], inputShape[1], inputShape[2], inputShape[3] }; const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape2)); @@ -917,10 +876,12 @@ std::shared_ptr ConcatFunction::getReferenceSelectionWithInter const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); fakeQuantize2->set_friendly_name("fakeQuantize2"); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore2); std::shared_ptr intermediateOp; if (transparentIntermediate) { - intermediateOp = makeMaxPool(fakeQuantize2->output(0), { 3, 3 }); + intermediateOp = makeMaxPool(deqBefore2, { 3, 3 }); } else { auto weights = ngraph::opset1::Constant::create( precision, @@ -939,9 +900,10 @@ std::shared_ptr ConcatFunction::getReferenceSelectionWithInter intermediateOp->set_friendly_name("intermediate"); const std::shared_ptr concat = std::make_shared( - ngraph::OutputVector { fakeQuantize1->output(0), intermediateOp->output(0) }, + ngraph::OutputVector { deqBefore1, intermediateOp->output(0) }, 1); concat->set_friendly_name("concat"); + low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOperation); auto& rtInfo = concat->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("concat"); @@ -975,28 +937,6 @@ std::shared_ptr ConcatFunction::getReferenceSelectionWithInter ngraph::ParameterVector{ input1, input2 }, "ConcatWithIntermediateTransformation"); - if ((fqOnData1.outputPrecision != fqOnData2.outputPrecision)) { - throw std::runtime_error("FakeQuantize expected precisions are different"); - } - const ngraph::element::Type fqOnDataPrecision = fqOnData1.outputPrecision; - if (fqOnDataPrecision != ngraph::element::undefined) { - if (fakeQuantize1->get_output_element_type(0) != fakeQuantize2->get_output_element_type(0)) { - throw std::runtime_error("FakeQuantize operation precisions are different"); - } - const ngraph::element::Type fakeQuantizePrecision = fakeQuantize1->get_output_element_type(0); - - if (fqOnDataPrecision != fakeQuantizePrecision) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize2, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat, fqOnDataPrecision); - - auto intermediateOpTr = std::dynamic_pointer_cast(intermediateOp); - if (intermediateOpTr != nullptr) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(intermediateOp, fqOnDataPrecision); - } - } - } - return function; } @@ -1006,32 +946,36 @@ std::shared_ptr ConcatFunction::getReferenceWithDifferentPreci const bool multiChannel, const FakeQuantizeOnData& fqOnData1, const FakeQuantizeOnData& fqOnData2, - const DequantizationOperations& dequantizationOperations1, - const DequantizationOperations& dequantizationOperations2) { - const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape)); + const ngraph::element::Type precisionBeforeOp, + const DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const DequantizationOperations& dequantizationAfter1, + const DequantizationOperations& dequantizationAfter2) { + const auto input1 = std::make_shared(precision, inputShape); input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); fakeQuantize1->set_friendly_name("fakeQuantize1"); + const auto deqBefore1 = makeDequantization(fakeQuantize1, dequantizationBefore); - const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto input2 = std::make_shared(precision, inputShape); input2->set_friendly_name("input2"); - const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); - fakeQuantize2->set_friendly_name("fakeQuantize2"); - const ngraph::element::Type fqOnDataPrecision = fqOnData1.outputPrecision; - if (fqOnDataPrecision != ngraph::element::undefined) { - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize1, fqOnDataPrecision); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize2, fqOnDataPrecision); - } + const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); + fakeQuantize2->set_friendly_name("fakeQuantize2"); + const auto deqBefore2 = makeDequantization(fakeQuantize2, dequantizationBefore); const std::shared_ptr concat = std::make_shared( - ngraph::OutputVector{ fakeQuantize1->output(0), fakeQuantize2->output(0) }, 1); + ngraph::OutputVector{ deqBefore1, deqBefore2 }, 1); + low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOperation); concat->set_friendly_name("concat"); auto& rtInfo = concat->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("concat"); - const auto lastDequantization1 = makeDequantization(concat->output(0), dequantizationOperations1); + const auto lastDequantization1 = makeDequantization(concat->output(0), dequantizationAfter1); const std::vector kernel = { 3, 3 }; const std::vector stride = { 1, 1 }; @@ -1054,7 +998,7 @@ std::shared_ptr ConcatFunction::getReferenceWithDifferentPreci ngraph::ResultVector results; results.push_back(std::make_shared(avgPool)); - if (!dequantizationOperations2.empty()) { + if (!dequantizationAfter2.empty()) { const std::shared_ptr maxPool = std::make_shared( concat->output(0), stride, @@ -1064,7 +1008,7 @@ std::shared_ptr ConcatFunction::getReferenceWithDifferentPreci roundingType, padType); - const std::shared_ptr lastDequantization2 = makeDequantization(maxPool, dequantizationOperations2); + const std::shared_ptr lastDequantization2 = makeDequantization(maxPool, dequantizationAfter2); lastDequantization2->set_friendly_name("MaxPool"); results.push_back(std::make_shared(lastDequantization2)); } @@ -1074,15 +1018,6 @@ std::shared_ptr ConcatFunction::getReferenceWithDifferentPreci ngraph::ParameterVector{ input1, input2 }, "ConcatWithDifferentChildsTransformation"); - if ((fqOnData1.outputPrecision != fqOnData2.outputPrecision)) { - throw std::runtime_error("FakeQuantize expected precisions are different"); - } - if (fqOnDataPrecision != ngraph::element::undefined) { - if (fakeQuantize1->get_output_element_type(0) != fakeQuantize2->get_output_element_type(0)) { - throw std::runtime_error("FakeQuantize operation precisions are different"); - } - } - return function; } @@ -1162,29 +1097,39 @@ std::shared_ptr ConcatFunction::getReferenceWithReshapeAtTheEn const FakeQuantizeOnDataWithConstant& fqOnData1, const FakeQuantizeOnDataWithConstant& fqOnData2, const FakeQuantizeOnDataWithConstant& fqOnData3, + const ngraph::element::Type precisionBeforeOp, + const ngraph::element::Type precisionAfterOperation, const DequantizationOperations& dequantizationOperations) { const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape)); input1->set_friendly_name("input1"); + const auto fakeQuantize1 = makeFakeQuantizeTypeRelaxed(input1, precision, fqOnData1); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize1, precisionBeforeOp); fakeQuantize1->set_friendly_name("fakeQuantize1"); const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape)); input2->set_friendly_name("input2"); + const auto fakeQuantize2 = makeFakeQuantizeTypeRelaxed(input2, precision, fqOnData2); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize2, precisionBeforeOp); fakeQuantize2->set_friendly_name("fakeQuantize2"); const std::shared_ptr concat1 = std::make_shared( ngraph::OutputVector{ fakeQuantize1->output(0), fakeQuantize2->output(0) }, 1); + low_precision::NetworkHelper::setOutDataPrecision(concat1, precisionAfterOperation); concat1->set_friendly_name("concat1"); std::shared_ptr intermediate = makeMaxPool(concat1->output(0), {1ul, 1ul}); const auto input3 = std::make_shared(precision, ngraph::Shape(inputShape)); input3->set_friendly_name("input3"); + const auto fakeQuantize3 = makeFakeQuantizeTypeRelaxed(input3, precision, fqOnData3); + low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantize3, precisionBeforeOp); fakeQuantize3->set_friendly_name("fakeQuantize3"); const std::shared_ptr concat2 = std::make_shared(ngraph::OutputVector{ fakeQuantize3, intermediate }, 1); + low_precision::NetworkHelper::setOutDataPrecision(concat2, precisionAfterOperation); concat2->set_friendly_name("concat2"); const Shape concat2Shape = concat2->output(0).get_shape(); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp index 9da8688ebe1..b6e9a229a68 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/depth_to_space_function.cpp @@ -60,6 +60,7 @@ std::shared_ptr DepthToSpaceFunction::getReference( const size_t blockSize, const ngraph::element::Type precisionBeforeDequantization, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) { const auto input = std::make_shared(precisionBeforeDequantization, inputShape); @@ -69,6 +70,7 @@ std::shared_ptr DepthToSpaceFunction::getReference( dequantizationOpAfter->set_friendly_name("output"); ngraph::ResultVector results = { std::make_shared(dequantizationOpAfter) }; + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(d2s, precisionAfterOperation); const auto function = std::make_shared(results, ngraph::ParameterVector{ input }, "DepthToSpaceTransformation"); return function; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp index c4eacfa26d6..44d127931dc 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_and_two_output_branches_with_convolution_function.cpp @@ -58,32 +58,34 @@ std::shared_ptr createConvolution( std::shared_ptr FakeQuantizeAndTwoOutputBranchesWithConvolutionFunction::getOriginal( const ngraph::element::Type precision, const ngraph::Shape& inputShape, - const ActualValues& values) { - const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); - const auto fakeQuantizeOnActivations = values.fqOnData.empty() ? + const FakeQuantizeOnData& fqOnData, + const FakeQuantizeOnWeights fqOnWeights1, + FakeQuantizeOnWeights fqOnWeights2) { + const auto input = std::make_shared(precision, inputShape); + const auto fakeQuantizeOnActivations = fqOnData.empty() ? nullptr : ngraph::builder::makeFakeQuantize( input, precision, - values.fqOnData.quantizationLevel, - values.fqOnData.constantShape, - values.fqOnData.inputLowValues, - values.fqOnData.inputHighValues, - values.fqOnData.outputLowValues, - values.fqOnData.outputHighValues); + fqOnData.quantizationLevel, + fqOnData.constantShape, + fqOnData.inputLowValues, + fqOnData.inputHighValues, + fqOnData.outputLowValues, + fqOnData.outputHighValues); const std::shared_ptr convolution1 = createConvolution( precision, inputShape, fakeQuantizeOnActivations, - values.fqOnWeights1, + fqOnWeights1, false); const std::shared_ptr convolution2 = createConvolution( precision, inputShape, fakeQuantizeOnActivations, - values.fqOnWeights2, + fqOnWeights2, false); const std::shared_ptr concat = std::make_shared(NodeVector{ convolution1, convolution2 }, 1ul); @@ -95,38 +97,38 @@ std::shared_ptr FakeQuantizeAndTwoOutputBranchesWithConvolutio const ngraph::element::Type precision, const ngraph::Shape& inputShape, const ngraph::pass::low_precision::LayerTransformation::Params& params, - const ExpectedValues& values) { + const ngraph::builder::subgraph::FakeQuantizeOnData& fqOnData, + const ngraph::element::Type precisionBeforeOp, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOp, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter1, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter2) { const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); - auto fakeQuantizeOnActivations = values.fqOnData.empty() ? + const auto fakeQuantizeOnActivations = fqOnData.empty() ? nullptr : - makeFakeQuantizeTypeRelaxed(input, precision, values.fqOnData); + makeFakeQuantizeTypeRelaxed(input, precision, fqOnData); + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(fakeQuantizeOnActivations, precisionBeforeOp); + const auto deqBefore = makeDequantization(fakeQuantizeOnActivations, dequantizationBefore); const std::shared_ptr convolution1 = createConvolution( precision, inputShape, - fakeQuantizeOnActivations, + deqBefore, FakeQuantizeOnWeights(), true); - const std::shared_ptr multiply1 = std::make_shared( - convolution1, - std::make_shared(precision, Shape{1, 1, 1}, values.multiplay1Values)); + const auto deqAfter1 = makeDequantization(convolution1, dequantizationAfter1); const std::shared_ptr convolution2 = createConvolution( precision, inputShape, - fakeQuantizeOnActivations, + deqBefore, FakeQuantizeOnWeights(), true); - const std::shared_ptr multiply2 = std::make_shared( - convolution2, - std::make_shared(precision, Shape{1, 1, 1}, values.multiplay2Values)); - - const std::shared_ptr concat = std::make_shared(NodeVector{ multiply1, multiply2 }, 1ul); + const auto deqAfter2 = makeDequantization(convolution2, dequantizationAfter2); + const std::shared_ptr concat = std::make_shared(NodeVector{ deqAfter1, deqAfter2 }, 1ul); + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(concat, precisionAfterOp); if (params.updatePrecisions) { - // fakeQuantizeOnActivations->set_output_type(0, params.precisionsOnActivations[0], fakeQuantizeOnActivations->get_output_partial_shape(0)); - ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantizeOnActivations, params.precisionsOnActivations[0]); - replace_node( convolution1->get_input_node_shared_ptr(1), ngraph::pass::low_precision::fold(convolution1->get_input_node_shared_ptr(1), params.precisionsOnWeights[0])); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp index f1144d9b3d0..44dd0e29a0a 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/fake_quantize_function.cpp @@ -9,6 +9,8 @@ #include "ngraph_functions/subgraph_builders.hpp" #include "low_precision/common/dequantization_op.hpp" #include "low_precision/network_helper.hpp" +#include "lpt_ngraph_functions/common/builders.hpp" + using namespace ngraph::pass::low_precision; @@ -42,8 +44,7 @@ std::shared_ptr FakeQuantizeFunction::getReference( const bool updatePrecisions, const FakeQuantizeOnData& fakeQuantizeOnData, const ngraph::element::Type fakeQuantizeOutputPrecision, - const std::vector& expectedSubtractValues, - const std::vector& expectedMultiplyValues) { + const ngraph::builder::subgraph::DequantizationOperations& dequantization) { const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); input->set_friendly_name("input"); @@ -60,47 +61,27 @@ std::shared_ptr FakeQuantizeFunction::getReference( auto& rtInfo = fakeQuantize->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("fakeQuantize"); + auto updateDequantization = dequantization; + if (!updateDequantization.subtract.empty()) { + updateDequantization.subtract.constantPrecision = element::f32; + } + if (!updateDequantization.multiply.empty()) { + updateDequantization.multiply.constantPrecision = element::f32; + } + + std::shared_ptr deq; if (updatePrecisions) { - const std::shared_ptr convert = std::make_shared(parent, element::f32); - ngraph::copy_runtime_info({ fakeQuantize, convert }, convert); - parent = convert; + deq = makeDequantization(fakeQuantize, updateDequantization); ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(fakeQuantize, fakeQuantizeOutputPrecision); } else { - if (fakeQuantize->get_output_element_type(0) != element::f32) { - const std::shared_ptr convert = std::make_shared(parent, element::f32); - ngraph::copy_runtime_info({ fakeQuantize, convert }, convert); - parent = convert; + if (precision == element::f32) { + updateDequantization.convert = {}; } + deq = makeDequantization(fakeQuantize, updateDequantization); } - const std::shared_ptr subtract = expectedSubtractValues.empty() ? - nullptr : - std::make_shared>( - parent, - ngraph::opset1::Constant::create( - element::f32, - expectedSubtractValues.size() == 1ul ? ngraph::Shape{ } : ngraph::Shape{ expectedSubtractValues.size() }, - expectedSubtractValues), - ngraph::op::AutoBroadcastSpec::NUMPY); - if (subtract != nullptr) { - ngraph::copy_runtime_info({ fakeQuantize, subtract }, subtract); - parent = subtract; - } - - const std::shared_ptr multiply = expectedMultiplyValues.empty() ? - nullptr : - std::make_shared( - parent, - ngraph::opset1::Constant::create( - element::f32, - expectedMultiplyValues.size() == 1ul ? ngraph::Shape{ } : ngraph::Shape{ expectedMultiplyValues.size() }, - expectedMultiplyValues)); - if (multiply != nullptr) { - ngraph::copy_runtime_info({ fakeQuantize, multiply }, multiply); - parent = multiply; - } - parent->set_friendly_name("fakeQuantize"); - ngraph::ResultVector results{ std::make_shared(parent) }; + deq->set_friendly_name("fakeQuantize"); + ngraph::ResultVector results{ std::make_shared(deq) }; return std::make_shared(results, ngraph::ParameterVector{ input }, "FakeQuantizeFunction"); } diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp index 0c0211dcb97..5ac07fd2498 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/mat_mul_function.cpp @@ -17,6 +17,77 @@ namespace ngraph { namespace builder { namespace subgraph { +std::shared_ptr MatMulFunction::getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape inputShape, + const float low, + const float high) { + const auto input1 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize( + input1, precision, 256ul, { 1ul }, + { low / 4.f }, { high / 4.f }, { low / 4.f }, { high / 4.f }); + fakeQuantize1->set_friendly_name("fakeQuantize1"); + + const auto input2 = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize( + input2, precision, 256ul, { 1ul }, + { low / 8.f }, { high / 8.f }, { low / 8.f }, { high / 8.f }); + fakeQuantize2->set_friendly_name("fakeQuantize2"); + + const auto matMul = std::make_shared( + fakeQuantize1->output(0), + fakeQuantize2->output(0), + false, + false); + matMul->set_friendly_name("matMul"); + + std::shared_ptr function = std::make_shared( + ngraph::ResultVector{ std::make_shared(matMul) }, + ngraph::ParameterVector{ input1, input2 }, + "GemmTransformation"); + + return function; +} + +std::shared_ptr MatMulFunction::getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape inputShape1, + const ngraph::Shape inputShape2, + const bool transpose1, + const bool transpose2) { + const auto paramNode = std::make_shared(precision, inputShape1); + const std::vector constShapes(inputShape1.size(), 1ul); + const auto fakeQuantizeOnAcitvations = ngraph::builder::makeFakeQuantize( + paramNode, precision, 256ul, constShapes, + { 0.f }, { 255.f / 4.f }, { 0.f }, { 255.f / 4.f }); + fakeQuantizeOnAcitvations->set_friendly_name("fakeQuantizeOnAcitvations"); + + auto weightsConst = std::make_shared( + precision, + inputShape2, + std::vector({ 1.f })); + const auto fakeQuantizeOnWeights = ngraph::builder::makeFakeQuantize( + weightsConst, precision, 256ul, { 1ul, 1ul }, + { -128.f / 8.f }, { 127.f / 8.f }, { -128.f / 8.f }, { 127.f / 8.f }); + fakeQuantizeOnWeights->set_friendly_name("fakeQuantizeOnWeights"); + + const std::shared_ptr fullyConnected = std::make_shared( + fakeQuantizeOnAcitvations->output(0), + fakeQuantizeOnWeights->output(0), + transpose1, + transpose2); + fullyConnected->set_friendly_name("fullyConnected"); + + ngraph::ResultVector results{ std::make_shared(fullyConnected) }; + std::shared_ptr function = std::make_shared( + results, + ngraph::ParameterVector{ paramNode }, + "FullyConnectedTransformation"); + + return function; +} + + std::shared_ptr MatMulFunction::getOriginal( const ngraph::element::Type precision, const ngraph::Shape& inputShape1, diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp index d1906b0073a..ab2b7dfa479 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/max_pool_function.cpp @@ -40,13 +40,14 @@ std::shared_ptr MaxPoolFunction::get( const ngraph::Shape& inputShape, const ngraph::element::Type precisionBeforeDequantization, const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) { const auto input = std::make_shared(precisionBeforeDequantization, ngraph::Shape(inputShape)); std::shared_ptr parent = input; - parent = dequantizationBefore.empty() ? parent : makeDequantization(parent, dequantizationBefore); + parent = makeDequantization(parent, dequantizationBefore); - const std::shared_ptr maxPool = std::make_shared( + const auto maxPool = std::make_shared( parent, Strides{ 1, 1 }, Shape{ 1, 1 }, @@ -54,8 +55,9 @@ std::shared_ptr MaxPoolFunction::get( Shape{ 2, 2 }, op::RoundingType::FLOOR); parent = maxPool; + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecision(maxPool, precisionAfterOperation); - parent = dequantizationAfter.empty() ? maxPool : makeDequantization(maxPool, dequantizationAfter); + parent = makeDequantization(maxPool, dequantizationAfter); maxPool->set_friendly_name("maxPool"); const std::shared_ptr result = std::make_shared(parent); diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp index b1d66df7f59..5b0dfe84918 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/multiply_function.cpp @@ -85,6 +85,46 @@ std::shared_ptr MultiplyFunction::get( return std::make_shared(results, inputs, "MultiplyTransformation"); } +std::shared_ptr MultiplyFunction::getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape, + const bool broadcast, + const ngraph::builder::subgraph::FakeQuantizeOnData& fq1, + const ngraph::builder::subgraph::FakeQuantizeOnData& fq2) { + ngraph::Shape inputShape2 = inputShape; + + if (broadcast) { + inputShape2[2] = 1; + inputShape2[3] = 1; + } + + const auto input1 = std::make_shared(precision, inputShape); + const auto fakeQuantize1 = fq1.empty() ? + nullptr : + ngraph::builder::makeFakeQuantize( + input1, precision, fq1.quantizationLevel, fq1.constantShape, + fq1.inputLowValues, fq1.inputHighValues, fq1.outputLowValues, fq1.outputHighValues); + + const auto input2 = std::make_shared(precision, inputShape2); + const auto fakeQuantize2 = fq2.empty() ? + nullptr : + ngraph::builder::makeFakeQuantize( + input2, precision, fq2.quantizationLevel, fq2.constantShape, + fq2.inputLowValues, fq2.inputHighValues, fq2.outputLowValues, fq2.outputHighValues); + + const auto multiply = std::make_shared( + fq1.empty() ? input1 : fakeQuantize1, + fq2.empty() ? input2 : fakeQuantize2); + + ngraph::ResultVector results{ std::make_shared(multiply) }; + std::shared_ptr function = std::make_shared( + results, + ngraph::ParameterVector{ input1, input2 }, + "MultiplyTransformation"); + + return function; +} + } // namespace subgraph } // namespace builder } // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp index d1b7a8075cd..e02f51575a4 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/normalize_l2_function.cpp @@ -8,6 +8,7 @@ #include #include "ngraph_functions/subgraph_builders.hpp" #include "low_precision/common/dequantization_op.hpp" +#include "lpt_ngraph_functions/common/builders.hpp" namespace ngraph { namespace builder { @@ -59,34 +60,17 @@ std::shared_ptr NormalizeL2Function::getOriginal( } std::shared_ptr NormalizeL2Function::getOriginal( - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& shape, const ngraph::op::EpsMode& epsMode, - const NormalizeL2ActualValues& actualValues) { - const auto input = std::make_shared(actualValues.precision, shape); - std::shared_ptr parent = input; + const std::vector& axes, + const ngraph::builder::subgraph::DequantizationOperations& dequantization) { + const auto input = std::make_shared(inputPrecision, shape); - const std::shared_ptr convert = std::make_shared(parent, precision); - parent = convert; + const auto deq = makeDequantization(input, dequantization); - if (!actualValues.subtractValues.empty()) { - const std::shared_ptr subtract = std::make_shared< ngraph::opset1::Subtract >( - parent, - std::make_shared( - precision, Shape({ actualValues.subtractValues.size() }), actualValues.subtractValues)); - parent = subtract; - } - - if (!actualValues.mutliplyValues.empty()) { - const std::shared_ptr multiply = std::make_shared< ngraph::opset1::Multiply >( - parent, - std::make_shared( - precision, Shape({ 1, actualValues.mutliplyValues.size(), 1, 1 }), actualValues.mutliplyValues)); - parent = multiply; - } - - const auto axesNode = std::make_shared(ngraph::element::i64, ngraph::Shape{ actualValues.axes.size() }, actualValues.axes); - const auto normalizeL2 = std::make_shared(parent, axesNode, 1e-6, epsMode); + const auto axesNode = std::make_shared(ngraph::element::i64, ngraph::Shape{ axes.size() }, axes); + const auto normalizeL2 = std::make_shared(deq, axesNode, 1e-6, epsMode); normalizeL2->set_friendly_name("output"); auto& rtInfo = normalizeL2->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("normalizeL2"); @@ -97,50 +81,33 @@ std::shared_ptr NormalizeL2Function::getOriginal( } std::shared_ptr NormalizeL2Function::getReference( - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, const ngraph::Shape& shape, const ngraph::op::EpsMode& epsMode, - const NormalizeL2ExpectedValues& expectedValues) { - const auto input = std::make_shared(expectedValues.precision, shape); - std::shared_ptr parent = input; + const std::vector& axes, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationAfter) { + const auto input = std::make_shared(inputPrecision, shape); - if (!expectedValues.subtractValues.empty()) { - const std::shared_ptr convert = std::make_shared(parent, precision); - parent = convert; + const auto deqBefore = makeDequantization(input, dequantizationBefore); - const std::shared_ptr subtract = std::make_shared>( - std::vector{ element::f32, element::f32 }, std::vector{element::f32}, - ngraph::op::TemporaryReplaceOutputType(parent, element::f32).get(), - ngraph::op::TemporaryReplaceOutputType(std::make_shared( - precision, - Shape({ expectedValues.subtractValues.size() }), - expectedValues.subtractValues), element::f32).get()); - parent = subtract; - } - - const auto axesNode = std::make_shared(ngraph::element::i64, ngraph::Shape{ expectedValues.axes.size() }, expectedValues.axes); + const auto axesNode = std::make_shared(ngraph::element::i64, ngraph::Shape{ axes.size() }, axes); const auto normalizeL2 = std::make_shared>( std::vector{ element::f32, element::f32 }, std::vector{element::f32}, - ngraph::op::TemporaryReplaceOutputType(parent, element::f32).get(), + ngraph::op::TemporaryReplaceOutputType(deqBefore, element::f32).get(), ngraph::op::TemporaryReplaceOutputType(axesNode, element::f32).get(), 1e-6, epsMode); auto& rtInfo = normalizeL2->get_rt_info(); rtInfo["Variant::std::string"] = std::make_shared>("normalizeL2"); - std::shared_ptr output = normalizeL2; + ngraph::pass::low_precision::NetworkHelper::setOutDataPrecisionForTypeRelaxed(normalizeL2, precisionAfterOperation); - if (!expectedValues.mutliplyValues.empty()) { - const std::shared_ptr multiply = std::make_shared>( - std::vector{ element::f32, element::f32 }, std::vector{element::f32}, - ngraph::op::TemporaryReplaceOutputType(output, element::f32).get(), - ngraph::op::TemporaryReplaceOutputType(std::make_shared( - precision, Shape({ 1, expectedValues.mutliplyValues.size(), 1, 1 }), expectedValues.mutliplyValues), element::f32).get()); - multiply->get_rt_info()["Variant::std::string"] = std::make_shared>("normalizeL2"); - output = multiply; - } - output->set_friendly_name("output"); + const auto deqAfter = makeDequantization(normalizeL2, dequantizationAfter); - ngraph::ResultVector results = { std::make_shared(output) }; + deqAfter->set_friendly_name("output"); + + ngraph::ResultVector results = { std::make_shared(deqAfter) }; const auto function = std::make_shared(results, ngraph::ParameterVector{ input }, "NormalizeL2Transformation"); return function; diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp index 447a1855eed..dcb574c3aa8 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/split_function.cpp @@ -68,17 +68,21 @@ std::shared_ptr SplitFunction::getOriginal( std::shared_ptr SplitFunction::getReference( const ngraph::Shape& inputShape, - const ngraph::element::Type precision, + const ngraph::element::Type inputPrecision, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, + const ngraph::element::Type precisionAfterOperation, const std::vector& dequantizationAfter, const int64_t splitedAxis, const size_t numSplit) { const std::shared_ptr input = std::make_shared( - precision, + inputPrecision, ngraph::Shape(inputShape)); + const auto deqBefore = makeDequantization(input, dequantizationBefore); + std::shared_ptr split; const auto constant = std::make_shared(element::i64, Shape{ }, splitedAxis); - split = std::make_shared(input, constant, numSplit); + split = std::make_shared(deqBefore, constant, numSplit); ngraph::ResultVector results; for (size_t i = 0; i < numSplit; ++i) { diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp new file mode 100644 index 00000000000..835f1b87c6f --- /dev/null +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/subtract_function.cpp @@ -0,0 +1,51 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "lpt_ngraph_functions/subtract_function.hpp" +#include "low_precision/network_helper.hpp" + +#include +#include "lpt_ngraph_functions/common/builders.hpp" +#include "ngraph_functions/subgraph_builders.hpp" + +using namespace ngraph::pass::low_precision; + +namespace ngraph { +namespace builder { +namespace subgraph { + std::shared_ptr SubtractFunction::getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape) { + const float k = 50.f; + + const auto input = std::make_shared(precision, ngraph::Shape(inputShape)); + const auto fakeQuantizeOnActivations = ngraph::builder::makeFakeQuantize( + input, precision, 256ul, { 1ul }, + { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); + + const auto weights = ngraph::opset1::Constant::create( + precision, + ngraph::Shape{ inputShape[1], inputShape[1], 1, 1 }, + std::vector(inputShape[1] * inputShape[1], 1)); + + const auto convolution = std::make_shared( + fakeQuantizeOnActivations == nullptr ? input : fakeQuantizeOnActivations, + ngraph::builder::makeFakeQuantize(weights, precision, 256ul, { 1ul }, { -128.f / k }, { 127.f / k }, { -128.f / k }, { 127.f / k }), + ngraph::Strides{ 1, 1 }, + ngraph::CoordinateDiff{ 0, 0 }, + ngraph::CoordinateDiff{ 0, 0 }, + ngraph::Strides{ 1, 1 }); + + ngraph::ResultVector results{ std::make_shared(convolution) }; + std::shared_ptr function = std::make_shared( + results, + ngraph::ParameterVector{ input }, + "SubtractTransformation"); + + return function; + } + +} // namespace subgraph +} // namespace builder +} // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp new file mode 100644 index 00000000000..6f0a85a2cbc --- /dev/null +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/transpose_after_mat_mul_function.cpp @@ -0,0 +1,48 @@ +// Copyright (C) 2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "lpt_ngraph_functions/transpose_after_mat_mul_function.hpp" +#include "low_precision/network_helper.hpp" + +#include +#include "lpt_ngraph_functions/common/builders.hpp" +#include "ngraph_functions/subgraph_builders.hpp" + +using namespace ngraph::pass::low_precision; + +namespace ngraph { +namespace builder { +namespace subgraph { + std::shared_ptr TransposeAfterMatMulFunction::getOriginal( + const ngraph::element::Type precision, + const ngraph::Shape& inputShape) { + const auto input1 = std::make_shared(precision, inputShape); + input1->set_friendly_name("input1"); + + const auto input2 = std::make_shared(precision, inputShape); + input2->set_friendly_name("input2"); + + const float k = 50.f; + const auto fakeQuantize1 = ngraph::builder::makeFakeQuantize(input1, precision, 256ul, { 1ul }, { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); + input2->set_friendly_name("fakeQuantize1"); + const auto fakeQuantize2 = ngraph::builder::makeFakeQuantize(input2, precision, 256ul, { 1ul }, { 0.f }, { 255.f / k }, { 0.f }, { 255.f / k }); + input2->set_friendly_name("fakeQuantize2"); + const auto matMul = std::make_shared(fakeQuantize1, fakeQuantize2, false, false); + input2->set_friendly_name("matMul"); + const auto transpose = std::make_shared( + matMul, + ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 4ul }, { 0, 2, 1, 3 })); + transpose->set_friendly_name("transpose"); + + ngraph::ResultVector results{ std::make_shared(transpose) }; + std::shared_ptr function = std::make_shared( + results, + ngraph::ParameterVector{ input1, input2 }, + "TransposeAfterMatMulFunction"); + + return function; + } +} // namespace subgraph +} // namespace builder +} // namespace ngraph diff --git a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp index 0349e0d1c54..7f47115f55c 100644 --- a/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp +++ b/inference-engine/tests/ngraph_helpers/lpt_ngraph_functions/src/variadic_split_function.cpp @@ -70,17 +70,21 @@ std::shared_ptr VariadicSplitFunction::getOriginal( std::shared_ptr VariadicSplitFunction::getReference( const ngraph::Shape& inputShape, + const ngraph::element::Type inputPrecision, + const ngraph::builder::subgraph::DequantizationOperations& dequantizationBefore, const ngraph::element::Type precisionAfterOperation, const std::vector& dequantizationAfter, const int64_t splitedAxis, const std::vector& splitLengths) { const std::shared_ptr input = std::make_shared( - precisionAfterOperation, + inputPrecision, ngraph::Shape(inputShape)); + const auto deqBefore = makeDequantization(input, dequantizationBefore); + const auto constantAxis = std::make_shared(element::i64, Shape{ }, splitedAxis); const auto constantLengths = std::make_shared(element::i64, Shape{ splitLengths.size() }, splitLengths); - const std::shared_ptr variadicSplit = std::make_shared(input, constantAxis, constantLengths); + const auto variadicSplit = std::make_shared(deqBefore, constantAxis, constantLengths); ngraph::ResultVector results; for (size_t i = 0; i < splitLengths.size(); ++i) {