From 515c8dd307a9089a9fe44216692b75feee4c4615 Mon Sep 17 00:00:00 2001 From: mitruska Date: Tue, 13 Jul 2021 17:45:27 +0200 Subject: [PATCH 01/11] Add GRN shared single layer test instance for CPU --- .../single_layer_tests/grn.cpp | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp new file mode 100644 index 00000000000000..57e2fc4134ef2f --- /dev/null +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp @@ -0,0 +1,36 @@ +// Copyright (C) 2020-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include "single_layer_tests/grn.hpp" +#include "common_test_utils/test_constants.hpp" + +using namespace LayerTestsDefinitions; +using namespace ngraph::helpers; + +namespace { +const std::vector netPrecisions = { + InferenceEngine::Precision::FP32, + InferenceEngine::Precision::FP16 +}; + +const auto basicCases = ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + // input shapes + ::testing::Values(std::vector{16, 24}, + std::vector{3, 16, 24}, + std::vector{1, 3, 30, 30}, + std::vector{2, 16, 15, 20}), + // bias + ::testing::Values(0.33f, 1.1f), + ::testing::Values(CommonTestUtils::DEVICE_CPU)); + +INSTANTIATE_TEST_CASE_P(smoke_Grn_Basic, GrnLayerTest, + basicCases, + GrnLayerTest::getTestCaseName); +} // namespace From c74920090bc4ba86a96cb0a5d7ae94c48ae27269 Mon Sep 17 00:00:00 2001 From: mitruska Date: Wed, 14 Jul 2021 15:39:49 +0200 Subject: [PATCH 02/11] Remove GRN backend tests from fused_op.in --- ngraph/test/backend/fused_op.in.cpp | 56 ----------------------------- 1 file changed, 56 deletions(-) diff --git a/ngraph/test/backend/fused_op.in.cpp b/ngraph/test/backend/fused_op.in.cpp index 3f3c557401e32a..9eab2a77e55ae5 100644 --- a/ngraph/test/backend/fused_op.in.cpp +++ b/ngraph/test/backend/fused_op.in.cpp @@ -221,62 +221,6 @@ NGRAPH_TEST(${BACKEND_NAME}, mvn_mean_variance_normalization_not_shared_across_c test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, grn_4d) -{ - const Shape data_shape{1, 2, 3, 4}; - const auto data = make_shared(element::f32, data_shape); - float bias{1e-6f}; - - const auto grn = make_shared(data, bias); - const auto function = make_shared(NodeVector{grn}, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - vector input_data(shape_size(data_shape)); - iota(begin(input_data), end(input_data), 1); - - test_case.add_input(input_data); - - test_case.add_expected_output( - data_shape, {0.0766965f, 0.14142136f, 0.19611613f, 0.24253564f, 0.28216633f, 0.31622776f, - 0.34570536f, 0.37139067f, 0.39391932f, 0.41380295f, 0.4314555f, 0.4472136f, - 0.9970545f, 0.98994946f, 0.9805807f, 0.97014254f, 0.9593655f, 0.9486833f, - 0.9383431f, 0.9284767f, 0.91914505f, 0.9103665f, 0.9021342f, 0.8944272f}); - test_case.run(); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_grn_2d_with_bias) -{ - const Shape data_shape{3, 4}; - const auto data = make_shared(element::f32, data_shape); - float bias{2.25f}; - - const auto grn = make_shared(data, bias); - const auto function = make_shared(NodeVector{grn}, ParameterVector{data}); - - auto test_case = test::TestCase(function); - - vector input_data(shape_size(data_shape)); - iota(begin(input_data), end(input_data), 1); - - test_case.add_input(input_data); - - test_case.add_expected_output(data_shape, - {0.5547002f, - 0.8f, - 0.8944272f, - 0.9363292f, - 0.95782626f, - 0.9701425f, - 0.9778024f, - 0.98287225f, - 0.9863939f, - 0.9889363f, - 0.9908301f, - 0.99227786f}); - test_case.run(); -} - // TODO: Issue: 37534 NGRAPH_TEST(${BACKEND_NAME}, DISABLED_squared_difference) { From 66e0c7756830ecf11ace3261d51b1c504bf7baa9 Mon Sep 17 00:00:00 2001 From: mitruska Date: Wed, 14 Jul 2021 16:10:52 +0200 Subject: [PATCH 03/11] Init GRN new template reference tests --- .../tests/functional/op_reference/grn.cpp | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 docs/template_plugin/tests/functional/op_reference/grn.cpp diff --git a/docs/template_plugin/tests/functional/op_reference/grn.cpp b/docs/template_plugin/tests/functional/op_reference/grn.cpp new file mode 100644 index 00000000000000..02e0a1ea99489f --- /dev/null +++ b/docs/template_plugin/tests/functional/op_reference/grn.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include +#include +#include +#include +#include + +#include "base_reference_test.hpp" + +using namespace ngraph; +using namespace InferenceEngine; + +struct GrnParams { + template + GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, + const std::vector& iValues, const std::vector& oValues, size_t iSize = 0, size_t oSize = 0) + : bias(bias), pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues, iSize)), refData(CreateBlob(oType, oValues, oSize)) {} + float bias; + ngraph::PartialShape pshape; + ngraph::element::Type inType; + ngraph::element::Type outType; + InferenceEngine::Blob::Ptr inputData; + InferenceEngine::Blob::Ptr refData; +}; + +class ReferenceGrnLayerTest : public testing::TestWithParam, public CommonReferenceTest { +public: + void SetUp() override { + auto params = GetParam(); + function = CreateFunction(params.bias, params.pshape, params.inType); + inputData = {params.inputData}; + refOutData = {params.refData}; + } + static std::string getTestCaseName(const testing::TestParamInfo& obj) { + auto param = obj.param; + std::ostringstream result; + result << "bias=" << param.bias << "_"; + result << "shape=" << param.pshape << "_"; + result << "iType=" << param.inType << "_"; + result << "oType=" << param.outType; + return result.str(); + } + +private: + static std::shared_ptr CreateFunction(float bias, const PartialShape& input_shape, const element::Type& input_type) { + const auto in = std::make_shared(input_type, input_shape); + const auto grn = std::make_shared(in, bias); + return std::make_shared(NodeVector {grn}, ParameterVector {in}); + } +}; + +TEST_P(ReferenceGrnLayerTest, CompareWithHardcodedRefs) { + Exec(); +} + +INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, + ::testing::Values(GrnParams(1e-6f, ngraph::PartialShape {1, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0766965f, 0.14142136f, 0.19611613f, 0.24253564f, 0.28216633f, 0.31622776f, + 0.34570536f, 0.37139067f, 0.39391932f, 0.41380295f, 0.4314555f, 0.4472136f, + 0.9970545f, 0.98994946f, 0.9805807f, 0.97014254f, 0.9593655f, 0.9486833f, + 0.9383431f, 0.9284767f, 0.91914505f, 0.9103665f, 0.9021342f, 0.8944272f})), + ReferenceGrnLayerTest::getTestCaseName); From bc226046e65973806747cfad4215c7eb49f95737 Mon Sep 17 00:00:00 2001 From: mitruska Date: Wed, 14 Jul 2021 17:39:07 +0200 Subject: [PATCH 04/11] Add more bias values to GRN single layer tests --- .../cpu/shared_tests_instances/single_layer_tests/grn.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp index 57e2fc4134ef2f..8324b4a90b7c94 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp @@ -27,7 +27,7 @@ const auto basicCases = ::testing::Combine( std::vector{1, 3, 30, 30}, std::vector{2, 16, 15, 20}), // bias - ::testing::Values(0.33f, 1.1f), + ::testing::Values(1e-6f, 0.33f, 1.1f, 2.25f, 100.25f), ::testing::Values(CommonTestUtils::DEVICE_CPU)); INSTANTIATE_TEST_CASE_P(smoke_Grn_Basic, GrnLayerTest, From 35a82e5bf87d81fc1e682a1c26582895312adf2a Mon Sep 17 00:00:00 2001 From: mitruska Date: Wed, 14 Jul 2021 17:40:55 +0200 Subject: [PATCH 05/11] Add more GRN template reference test cases --- .../tests/functional/op_reference/grn.cpp | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/grn.cpp b/docs/template_plugin/tests/functional/op_reference/grn.cpp index 02e0a1ea99489f..6fd835f6e393fa 100644 --- a/docs/template_plugin/tests/functional/op_reference/grn.cpp +++ b/docs/template_plugin/tests/functional/op_reference/grn.cpp @@ -58,11 +58,45 @@ TEST_P(ReferenceGrnLayerTest, CompareWithHardcodedRefs) { Exec(); } -INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, - ::testing::Values(GrnParams(1e-6f, ngraph::PartialShape {1, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, - std::vector {0.0766965f, 0.14142136f, 0.19611613f, 0.24253564f, 0.28216633f, 0.31622776f, - 0.34570536f, 0.37139067f, 0.39391932f, 0.41380295f, 0.4314555f, 0.4472136f, - 0.9970545f, 0.98994946f, 0.9805807f, 0.97014254f, 0.9593655f, 0.9486833f, - 0.9383431f, 0.9284767f, 0.91914505f, 0.9103665f, 0.9021342f, 0.8944272f})), - ReferenceGrnLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P( + smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, + ::testing::Values( + // bias 1e-6 // 2D // 3D // 4D + GrnParams(1e-6, ngraph::PartialShape {3, 4}, ngraph::element::f32, ngraph::element::f32, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, + std::vector {0.182574, 0.365148, 0.547723, 0.730297, 0.379049, 0.454859, 0.530669, 0.606478, 0.426162, 0.473514, 0.520865, 0.568217}), + GrnParams(1e-6, ngraph::PartialShape {2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522, 0.870063, 0.845154, 0.822179, 0.801784, + 0.433574, 0.441836, 0.449215, 0.455842, 0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}), + GrnParams(1e-6, ngraph::PartialShape {1, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, + 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}), + GrnParams(1e-6, ngraph::PartialShape {2, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, + std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, + 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427, + 0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172, 0.591364, 0.594391, 0.597266, 0.6, + 0.828589, 0.825307, 0.822192, 0.819232, 0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}), + // bias 100.25 // 2D // 3D // 4D + GrnParams(100.25, ngraph::PartialShape {3, 4}, ngraph::element::f32, ngraph::element::f32, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, + std::vector {0.0876216, 0.175243, 0.262865, 0.350486, 0.301923, 0.362308, 0.422693, 0.483077, 0.385076, 0.427863, 0.470649, 0.513435}), + GrnParams(100.25, ngraph::PartialShape {2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273, 0.625166, 0.645161, 0.658258, 0.66641, + 0.41125, 0.421303, 0.430287, 0.438356, 0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}), + GrnParams(100.25, ngraph::PartialShape {1, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, + 0.360795, 0.38229, 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283, + 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}), + GrnParams(100.25, ngraph::PartialShape {2, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, + std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, + 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, + 0.841854, 0.841037, 0.839701, 0.837989, 0.546293, 0.551788, 0.556938, 0.561772, 0.566319, 0.570601, + 0.574641, 0.578458, 0.582069, 0.585489, 0.588734, 0.591816, 0.808514, 0.80646, 0.804466, 0.802532, + 0.800658, 0.798842, 0.797083, 0.795379, 0.79373, 0.792133, 0.790586, 0.789088})), + ReferenceGrnLayerTest::getTestCaseName); From 3a049202684cf84d7528d2e43f83a59d9b3c8602 Mon Sep 17 00:00:00 2001 From: mitruska Date: Thu, 15 Jul 2021 09:23:32 +0200 Subject: [PATCH 06/11] Remove unused parameter from GrnParams --- docs/template_plugin/tests/functional/op_reference/grn.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/grn.cpp b/docs/template_plugin/tests/functional/op_reference/grn.cpp index 6fd835f6e393fa..1198cb2b67b225 100644 --- a/docs/template_plugin/tests/functional/op_reference/grn.cpp +++ b/docs/template_plugin/tests/functional/op_reference/grn.cpp @@ -18,8 +18,8 @@ using namespace InferenceEngine; struct GrnParams { template GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, - const std::vector& iValues, const std::vector& oValues, size_t iSize = 0, size_t oSize = 0) - : bias(bias), pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues, iSize)), refData(CreateBlob(oType, oValues, oSize)) {} + const std::vector& iValues, const std::vector& oValues) + : bias(bias), pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(oType, oValues)) {} float bias; ngraph::PartialShape pshape; ngraph::element::Type inType; From bd9009f1b707174cf54b58b321ec4faf9fc6f11e Mon Sep 17 00:00:00 2001 From: mitruska Date: Thu, 15 Jul 2021 12:46:44 +0200 Subject: [PATCH 07/11] Refactor GRN template referene tests and add more types --- .../tests/functional/op_reference/grn.cpp | 102 ++++++++++-------- 1 file changed, 58 insertions(+), 44 deletions(-) diff --git a/docs/template_plugin/tests/functional/op_reference/grn.cpp b/docs/template_plugin/tests/functional/op_reference/grn.cpp index 1198cb2b67b225..2a1b9099062f47 100644 --- a/docs/template_plugin/tests/functional/op_reference/grn.cpp +++ b/docs/template_plugin/tests/functional/op_reference/grn.cpp @@ -16,10 +16,10 @@ using namespace ngraph; using namespace InferenceEngine; struct GrnParams { - template - GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const ngraph::element::Type& oType, - const std::vector& iValues, const std::vector& oValues) - : bias(bias), pshape(shape), inType(iType), outType(oType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(oType, oValues)) {} + template + GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const std::vector& iValues, + const std::vector& oValues) + : bias(bias), pshape(shape), inType(iType), outType(iType), inputData(CreateBlob(iType, iValues)), refData(CreateBlob(iType, oValues)) {} float bias; ngraph::PartialShape pshape; ngraph::element::Type inType; @@ -58,45 +58,59 @@ TEST_P(ReferenceGrnLayerTest, CompareWithHardcodedRefs) { Exec(); } -INSTANTIATE_TEST_SUITE_P( - smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, - ::testing::Values( +template +std::vector generateGrnParams(const ngraph::element::Type& type) { + using T = typename element_type_traits::value_type; + std::vector grnParams { // bias 1e-6 // 2D // 3D // 4D - GrnParams(1e-6, ngraph::PartialShape {3, 4}, ngraph::element::f32, ngraph::element::f32, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, - std::vector {0.182574, 0.365148, 0.547723, 0.730297, 0.379049, 0.454859, 0.530669, 0.606478, 0.426162, 0.473514, 0.520865, 0.568217}), - GrnParams(1e-6, ngraph::PartialShape {2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, - std::vector {0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522, 0.870063, 0.845154, 0.822179, 0.801784, - 0.433574, 0.441836, 0.449215, 0.455842, 0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}), - GrnParams(1e-6, ngraph::PartialShape {1, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, - std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, - 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}), - GrnParams(1e-6, ngraph::PartialShape {2, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, - std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, - 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427, - 0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172, 0.591364, 0.594391, 0.597266, 0.6, - 0.828589, 0.825307, 0.822192, 0.819232, 0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}), + GrnParams(1e-6, ngraph::PartialShape {3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, + std::vector {0.182574, 0.365148, 0.547723, 0.730297, 0.379049, 0.454859, 0.530669, 0.606478, 0.426162, 0.473514, 0.520865, 0.568217}), + GrnParams(1e-6, ngraph::PartialShape {2, 3, 4}, type, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0966737, 0.169031, 0.224231, 0.267261, 0.483368, 0.507093, 0.523205, 0.534522, 0.870063, 0.845154, 0.822179, 0.801784, + 0.433574, 0.441836, 0.449215, 0.455842, 0.566982, 0.568075, 0.569005, 0.569803, 0.700389, 0.694314, 0.688796, 0.683763}), + GrnParams(1e-6, ngraph::PartialShape {1, 2, 3, 4}, type, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, + 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427}), + GrnParams(1e-6, ngraph::PartialShape {2, 2, 3, 4}, type, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, + std::vector {0.0766965, 0.141421, 0.196116, 0.242536, 0.282166, 0.316228, 0.345705, 0.371391, 0.393919, 0.413803, 0.431455, 0.447214, + 0.997055, 0.989949, 0.980581, 0.970143, 0.959365, 0.948683, 0.938343, 0.928477, 0.919145, 0.910366, 0.902134, 0.894427, + 0.559857, 0.564684, 0.56921, 0.573462, 0.577465, 0.581238, 0.584802, 0.588172, 0.591364, 0.594391, 0.597266, 0.6, + 0.828589, 0.825307, 0.822192, 0.819232, 0.816416, 0.813733, 0.811176, 0.808736, 0.806405, 0.804176, 0.802043, 0.8}), // bias 100.25 // 2D // 3D // 4D - GrnParams(100.25, ngraph::PartialShape {3, 4}, ngraph::element::f32, ngraph::element::f32, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, - std::vector {0.0876216, 0.175243, 0.262865, 0.350486, 0.301923, 0.362308, 0.422693, 0.483077, 0.385076, 0.427863, 0.470649, 0.513435}), - GrnParams(100.25, ngraph::PartialShape {2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, - std::vector {0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273, 0.625166, 0.645161, 0.658258, 0.66641, - 0.41125, 0.421303, 0.430287, 0.438356, 0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}), - GrnParams(100.25, ngraph::PartialShape {1, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, - std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, - 0.360795, 0.38229, 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283, - 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}), - GrnParams(100.25, ngraph::PartialShape {2, 2, 3, 4}, ngraph::element::f32, ngraph::element::f32, - std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, - std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, - 0.401596, 0.418994, 0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, - 0.841854, 0.841037, 0.839701, 0.837989, 0.546293, 0.551788, 0.556938, 0.561772, 0.566319, 0.570601, - 0.574641, 0.578458, 0.582069, 0.585489, 0.588734, 0.591816, 0.808514, 0.80646, 0.804466, 0.802532, - 0.800658, 0.798842, 0.797083, 0.795379, 0.79373, 0.792133, 0.790586, 0.789088})), - ReferenceGrnLayerTest::getTestCaseName); + GrnParams(100.25, ngraph::PartialShape {3, 4}, type, std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}, + std::vector {0.0876216, 0.175243, 0.262865, 0.350486, 0.301923, 0.362308, 0.422693, 0.483077, 0.385076, 0.427863, 0.470649, 0.513435}), + GrnParams(100.25, ngraph::PartialShape {2, 3, 4}, type, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0694629, 0.129032, 0.179525, 0.222137, 0.347314, 0.387097, 0.418891, 0.444273, 0.625166, 0.645161, 0.658258, 0.66641, + 0.41125, 0.421303, 0.430287, 0.438356, 0.537789, 0.541675, 0.54503, 0.547945, 0.664327, 0.662047, 0.659774, 0.657534}), + GrnParams(100.25, ngraph::PartialShape {1, 2, 3, 4}, type, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24}, + std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994, + 0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989f}), + GrnParams(100.25, ngraph::PartialShape {2, 2, 3, 4}, type, + std::vector {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48}, + std::vector {0.0608299, 0.115422, 0.164091, 0.207321, 0.245662, 0.279675, 0.309889, 0.336786, 0.360795, 0.38229, 0.401596, 0.418994, + 0.790789, 0.807954, 0.820457, 0.829283, 0.835252, 0.839026, 0.841128, 0.841965, 0.841854, 0.841037, 0.839701, 0.837989, + 0.546293, 0.551788, 0.556938, 0.561772, 0.566319, 0.570601, 0.574641, 0.578458, 0.582069, 0.585489, 0.588734, 0.591816, + 0.808514, 0.80646, 0.804466, 0.802532, 0.800658, 0.798842, 0.797083, 0.795379, 0.79373, 0.792133, 0.790586, 0.789088})}; + return grnParams; +} + +std::vector generateGrnCombinedParams() { + const std::vector> grnTypeParams {generateGrnParams(ngraph::element::bf16), + generateGrnParams(ngraph::element::f16), + generateGrnParams(ngraph::element::f32)}; + std::vector combinedParams; + std::for_each(grnTypeParams.begin(), grnTypeParams.end(), [&](std::vector params) { + combinedParams.insert(combinedParams.end(), params.begin(), params.end()); + }); + return combinedParams; +} + +INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, ::testing::ValuesIn(generateGrnCombinedParams()), + ReferenceGrnLayerTest::getTestCaseName); From afc01fbae8d15a76c5f8838266da8161d3b6dfd6 Mon Sep 17 00:00:00 2001 From: mitruska Date: Thu, 15 Jul 2021 13:12:11 +0200 Subject: [PATCH 08/11] Add anonymous namespace --- docs/template_plugin/tests/functional/op_reference/grn.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/template_plugin/tests/functional/op_reference/grn.cpp b/docs/template_plugin/tests/functional/op_reference/grn.cpp index 2a1b9099062f47..4d003b9b9a2fef 100644 --- a/docs/template_plugin/tests/functional/op_reference/grn.cpp +++ b/docs/template_plugin/tests/functional/op_reference/grn.cpp @@ -15,6 +15,7 @@ using namespace ngraph; using namespace InferenceEngine; +namespace { struct GrnParams { template GrnParams(const float bias, const ngraph::PartialShape& shape, const ngraph::element::Type& iType, const std::vector& iValues, @@ -114,3 +115,4 @@ std::vector generateGrnCombinedParams() { INSTANTIATE_TEST_SUITE_P(smoke_GRN_With_Hardcoded_Refs, ReferenceGrnLayerTest, ::testing::ValuesIn(generateGrnCombinedParams()), ReferenceGrnLayerTest::getTestCaseName); +} // namespace From 7a2c78f3bc489d425af9a2f9b1760a4bbba5bd71 Mon Sep 17 00:00:00 2001 From: mitruska Date: Thu, 15 Jul 2021 13:13:11 +0200 Subject: [PATCH 09/11] Add bf16 type to cpu single layer tests --- .../cpu/shared_tests_instances/single_layer_tests/grn.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp index 8324b4a90b7c94..6870e4f4526851 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/grn.cpp @@ -3,16 +3,17 @@ // #include + #include "single_layer_tests/grn.hpp" #include "common_test_utils/test_constants.hpp" using namespace LayerTestsDefinitions; -using namespace ngraph::helpers; namespace { const std::vector netPrecisions = { + InferenceEngine::Precision::BF16, + InferenceEngine::Precision::FP16, InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 }; const auto basicCases = ::testing::Combine( @@ -30,7 +31,7 @@ const auto basicCases = ::testing::Combine( ::testing::Values(1e-6f, 0.33f, 1.1f, 2.25f, 100.25f), ::testing::Values(CommonTestUtils::DEVICE_CPU)); -INSTANTIATE_TEST_CASE_P(smoke_Grn_Basic, GrnLayerTest, +INSTANTIATE_TEST_CASE_P(smoke_GRN_Basic, GrnLayerTest, basicCases, GrnLayerTest::getTestCaseName); } // namespace From fa821deab1d9a733476a0c95f35be160cdbf185d Mon Sep 17 00:00:00 2001 From: mitruska Date: Thu, 15 Jul 2021 13:13:31 +0200 Subject: [PATCH 10/11] Add Serialization test --- .../serialization/single_layer/grn.cpp | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 inference-engine/tests/functional/inference_engine/serialization/single_layer/grn.cpp diff --git a/inference-engine/tests/functional/inference_engine/serialization/single_layer/grn.cpp b/inference-engine/tests/functional/inference_engine/serialization/single_layer/grn.cpp new file mode 100644 index 00000000000000..e63ce864af07d3 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/serialization/single_layer/grn.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2020-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +#include "shared_test_classes/single_layer/grn.hpp" + +using namespace LayerTestsDefinitions; + +namespace { + TEST_P(GrnLayerTest, Serialize) { + Serialize(); +} + +const std::vector netPrecisions = { + InferenceEngine::Precision::FP32 +}; + +const auto basicCases = ::testing::Combine( + ::testing::ValuesIn(netPrecisions), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), + ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::Values(InferenceEngine::Layout::ANY), + // input shapes + ::testing::Values(std::vector{2, 16, 15, 20}), + // bias + ::testing::Values(1e-6f), + ::testing::Values(CommonTestUtils::DEVICE_CPU)); + +INSTANTIATE_TEST_CASE_P(smoke_GRN_Serialization, GrnLayerTest, + basicCases, + GrnLayerTest::getTestCaseName); +} // namespace From 73a0bc1389121709e6f6338eeae13803208920e5 Mon Sep 17 00:00:00 2001 From: mitruska Date: Thu, 15 Jul 2021 13:13:55 +0200 Subject: [PATCH 11/11] Add GRN to revised ops --- .../functional_test_utils/layer_tests_summary/utils/constants.py | 1 + 1 file changed, 1 insertion(+) diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py index 8f39adb29b7008..7f615c64488a58 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_tests_summary/utils/constants.py @@ -41,6 +41,7 @@ 'GatherElements-6', 'GatherND-5', 'Gelu-7', + 'GRN-1', 'GroupConvolution-1', 'GroupConvolutionBackpropData-1', 'GRUSequence-5',