From b7cc01b8e2f3f3d39d0f640ea837b0e7de66a493 Mon Sep 17 00:00:00 2001 From: Katarzyna Mitrus Date: Mon, 12 Jul 2021 15:28:24 +0200 Subject: [PATCH] NormalizeL2 - reference implementation revision (#6349) * Update SLT to generate input with 0 and eps sensitive treshold * Fix normalize_l2 reference to enable empty axes case * Simplify empty axes case * Moved backend tests from fused_op * Update SLT treshold * Enable SLT for empty axes case * More single layer tests * Backend tests refactor * Add helper function to for normalize_l2 backend tests * Rewrite NormalizeL2 backend tests to use test case and common helper function * Update layer tests * Cleanup unit-tests manifest * Add more backend tests * Update comments * Fix applying eps in MKLDNN normalize * Add 5D tests * Backend tests refactor * Remove duplicated tests * Upate IE tests manifest * Add 5D SLT * SLT cleanup * Update skipped SLT for CPU * Add NormalizeL2 to verified ops * Skip GPU SLT for empty axes case * Update SLT epsilon values * Revert mkldnn_normalize changes * Update tests and issue nubmers * Remove reudndant axes copy from reference --- .../single_layer_tests/normalize_l2.cpp | 152 ++- .../skip_tests_config.cpp | 9 +- .../skip_tests_config.cpp | 5 +- .../single_layer/normalize_l2.hpp | 2 +- .../src/single_layer/normalize_l2.cpp | 15 +- .../layer_tests_summary/utils/constants.py | 1 + .../ngraph/runtime/reference/normalize_l2.hpp | 18 +- ngraph/test/backend/fused_op.in.cpp | 216 ---- ngraph/test/backend/normalize_l2.in.cpp | 969 +++++++++++++++--- ngraph/test/runtime/ie/unit_test.manifest | 63 +- 10 files changed, 1053 insertions(+), 397 deletions(-) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp index 843609102e4..15b5b453642 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/normalize_l2.cpp @@ -14,30 +14,162 @@ const std::vector netPrecisions = { InferenceEngine::Precision::FP16 }; -const std::vector> axes = { - {}, - {1}, -}; -const std::vector eps = {1e-7f, 1e-6f, 1e-5f, 1e-4f}; +const std::vector eps = {1e-12f, 1e-6f, 1e-3f, 0.1, 100}; const std::vector epsMode = { ngraph::op::EpsMode::ADD, ngraph::op::EpsMode::MAX, }; -const auto normL2params = testing::Combine( - testing::ValuesIn(axes), +/* ============= 1D ============= */ +// [SKIPPED][CPU] Unsupported rank, Issue: 35627 +const std::vector> axes_1D = { + {}, + {0} +}; + +const auto normL2params_1D = testing::Combine( + testing::ValuesIn(axes_1D), testing::ValuesIn(eps), testing::ValuesIn(epsMode), - testing::ValuesIn(std::vector>({{1, 3, 10, 5}, {1, 5, 3}})), + testing::ValuesIn(std::vector>({{5}})), testing::ValuesIn(netPrecisions), testing::Values(CommonTestUtils::DEVICE_CPU) ); INSTANTIATE_TEST_SUITE_P( - NormalizeL2, + smoke_NormalizeL2_1D, NormalizeL2LayerTest, - normL2params, + normL2params_1D, + NormalizeL2LayerTest::getTestCaseName +); + +/* ============= 2D ============= */ +const std::vector> axes_2D = { + {}, + {1}, + + // [CPU] Unsupported axes, Issue: 59791 + // {0}, + // {0, 1}, +}; + +const auto normL2params_2D = testing::Combine( + testing::ValuesIn(axes_2D), + testing::ValuesIn(eps), + testing::ValuesIn(epsMode), + testing::ValuesIn(std::vector>({{5, 3}})), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_CPU) +); + +INSTANTIATE_TEST_SUITE_P( + smoke_NormalizeL2_2D, + NormalizeL2LayerTest, + normL2params_2D, + NormalizeL2LayerTest::getTestCaseName +); + +/* ============= 3D ============= */ +const std::vector> axes_3D = { + {}, + {1}, + {1, 2}, + + // [CPU] Unsorted axes, Issue: 59794 + // {2, 1}, + + // [CPU] Unsupported axes, Issue: 59791 + // {0}, + // {2}, + // {0, 1}, + // {0, 1, 2} +}; + +const auto normL2params_3D = testing::Combine( + testing::ValuesIn(axes_3D), + testing::ValuesIn(eps), + testing::ValuesIn(epsMode), + testing::ValuesIn(std::vector>({{2, 5, 3}})), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_CPU) +); + +INSTANTIATE_TEST_SUITE_P( + smoke_NormalizeL2_3D, + NormalizeL2LayerTest, + normL2params_3D, + NormalizeL2LayerTest::getTestCaseName +); + +/* ============= 4D ============= */ +const std::vector> axes_4D = { + {}, + {1}, + {1, 2, 3}, + + // [CPU] Unsorted axes, Issue: 59794 + // {3, 1, 2}, + + // [CPU] Unsupported axes, Issue: 59791 + // {0}, + // {2}, + // {3}, + // {0, 1}, + // {1, 2}, + // {2, 3}, + // {0, 1, 2, 3} +}; + +const auto normL2params_4D = testing::Combine( + testing::ValuesIn(axes_4D), + testing::ValuesIn(eps), + testing::ValuesIn(epsMode), + testing::ValuesIn(std::vector>({{2, 3, 10, 5}})), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_CPU) +); + +INSTANTIATE_TEST_SUITE_P( + smoke_NormalizeL2_4D, + NormalizeL2LayerTest, + normL2params_4D, + NormalizeL2LayerTest::getTestCaseName +); + +/* ============= 5D ============= */ +// [SKIPPED][CPU] Unsupported rank, Issue: 35627 +const std::vector> axes_5D = { + {}, + {0}, + {1}, + {2}, + {3}, + {4}, + {0, 1}, + {1, 2}, + {2, 3}, + {3, 4}, + {1, 2, 3}, + {2, 3, 4}, + {4, 3, 2}, + {1, 2, 3, 4}, + {0, 1, 2, 3} +}; + +const auto normL2params_5D = testing::Combine( + testing::ValuesIn(axes_5D), + testing::ValuesIn(eps), + testing::ValuesIn(epsMode), + testing::ValuesIn(std::vector>({{2, 2, 3, 10, 5}})), + testing::ValuesIn(netPrecisions), + testing::Values(CommonTestUtils::DEVICE_CPU) +); + +INSTANTIATE_TEST_SUITE_P( + smoke_NormalizeL2_5D, + NormalizeL2LayerTest, + normL2params_5D, NormalizeL2LayerTest::getTestCaseName ); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index cbae9c59b25..b188455a24c 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -51,14 +51,17 @@ std::vector disabledTestPatterns() { R"(.*ConvolutionLayerCPUTest.*BF16.*_inFmts=(ndhwc|nhwc).*)", // TODO: 56827. Sporadic test failures R"(.*smoke_Conv.+_FP32.ConvolutionLayerCPUTest\.CompareWithRefs.IS=\(1\.67.+\).*inFmts=n.+c.*_primitive=jit_avx2.*)", - - // incorrect reference implementation - R"(.*NormalizeL2LayerTest.*axes=\(\).*)", // lpt transformation produce the same names for MatMul and Multiply R"(.*MatMulTransformation.*)", // incorrect jit_uni_planar_convolution with dilation = {1, 2, 1} and output channel 1 R"(.*smoke_Convolution3D.*D=\(1.2.1\)_O=1.*)", + // TODO: Issue: 35627. CPU Normalize supports from 2D to 4D blobs + R"(.*NormalizeL2_1D.*)", + R"(.*NormalizeL2_5D.*)", + // Issue: 59788. mkldnn_normalize_nchw applies eps after sqrt for across_spatial + R"(.*NormalizeL2_.*axes=\(1.2.*_eps=100.*)", + // Unsupported operation of type: NormalizeL2 name : Doesn't support reduction axes: (2.2) R"(.*BF16NetworkRestore1.*)", R"(.*MobileNet_ssd_with_branching.*)", diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 5863309efe4..bbf9fe9b7e8 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -55,6 +55,9 @@ std::vector disabledTestPatterns() { // TODO: Issue: 54194 R"(.*ActivationLayerTest.*SoftPlus.*)", // need to implement Export / Import - R"(.*IEClassImportExportTestP.*)" + R"(.*IEClassImportExportTestP.*)", + + // TODO: Issue: 59586, NormalizeL2 output mismatch for empty axes case + R"(.*NormalizeL2LayerTest.*axes=\(\).*)" }; } diff --git a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp index 833f6ef0591..c0740d48f40 100644 --- a/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp +++ b/inference-engine/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/normalize_l2.hpp @@ -29,7 +29,7 @@ public: protected: void SetUp() override; + InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; }; } // namespace LayerTestsDefinitions - diff --git a/inference-engine/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp b/inference-engine/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp index 58fd09d41d1..a7816e39571 100644 --- a/inference-engine/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp +++ b/inference-engine/tests/functional/shared_test_classes/src/single_layer/normalize_l2.cpp @@ -25,6 +25,17 @@ std::string NormalizeL2LayerTest::getTestCaseName(testing::TestParamInfo axes; @@ -34,7 +45,9 @@ void NormalizeL2LayerTest::SetUp() { std::tie(axes, eps, epsMode, inputShape, netPrecision, targetDevice) = this->GetParam(); auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); - auto norm = ngraph::builder::makeNormalizeL2(params[0], axes, eps, epsMode); + auto data_input = params[0]; + data_input->set_friendly_name("data"); + auto norm = ngraph::builder::makeNormalizeL2(data_input, axes, eps, epsMode); ngraph::ResultVector results{std::make_shared(norm)}; function = std::make_shared(results, params, "NormalizeL2"); } 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 3241dfd7013..8f39adb29b7 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 @@ -62,6 +62,7 @@ VERIFIED_OP_REFERENCES = [ 'NonMaxSuppression-4', 'NonMaxSuppression-5', 'NonZero-3', + 'NormalizeL2-1', 'PriorBox-1', 'Proposal-1', 'Proposal-4', diff --git a/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp b/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp index c32ec70488e..866f8798287 100644 --- a/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp +++ b/ngraph/core/reference/include/ngraph/runtime/reference/normalize_l2.hpp @@ -22,27 +22,31 @@ namespace ngraph float eps, op::EpsMode eps_mode) { - AxisSet axes = reduction_axes; if (reduction_axes.empty()) { - std::vector axes_vec(data_shape.size()); - std::iota(axes_vec.begin(), axes_vec.end(), 0); - axes = AxisSet(axes_vec); + // When axes is an empty list, then each `data` element is divided by itself + // resulting value 1 for all non-zero elements + for (size_t i = 0; i < shape_size(data_shape); ++i) + { + out[i] = data[i] == 0 ? 0 : 1; + } + return; } + std::vector sqr_data(shape_size(data_shape)); - for (size_t i = 0; i < shape_size(data_shape); i++) + for (size_t i = 0; i < shape_size(data_shape); ++i) { sqr_data[i] = data[i] * data[i]; } Shape reduce_shape = data_shape; - for (auto axis : axes) + for (auto axis : reduction_axes) { reduce_shape[axis] = 1; } std::vector sum_data(shape_size(reduce_shape)); - sum(sqr_data.data(), sum_data.data(), data_shape, axes); + sum(sqr_data.data(), sum_data.data(), data_shape, reduction_axes); autobroadcast_binop(data, sum_data.data(), out, diff --git a/ngraph/test/backend/fused_op.in.cpp b/ngraph/test/backend/fused_op.in.cpp index 4899bd2a3e7..3f3c557401e 100644 --- a/ngraph/test/backend/fused_op.in.cpp +++ b/ngraph/test/backend/fused_op.in.cpp @@ -78,222 +78,6 @@ NGRAPH_TEST(${BACKEND_NAME}, hardsigmoid) test_case.run(); } -// TODO: Issue: 37521 -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_chw_4d) -{ - Shape data_shape{1, 2, 3, 4}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{3}, vector{1, 2, 3}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.01428571f, 0.02857143f, 0.04285714f, 0.05714286f, 0.07142857f, 0.08571429f, - 0.1f, 0.11428571f, 0.12857144f, 0.14285715f, 0.15714286f, 0.17142858f, - 0.18571429f, 0.2f, 0.21428572f, 0.22857143f, 0.24285714f, 0.25714287f, - 0.27142859f, 0.2857143f, 0.30000001f, 0.31428573f, 0.32857144f, 0.34285715f}); - - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_empty_axes_input) -{ - Shape data_shape{1, 2, 3, 4}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{0}, vector{}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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, - vector{0.01428571, 0.02857143, 0.04285714, 0.05714286, 0.07142857, 0.08571429, - 0.1, 0.11428571, 0.12857144, 0.14285715, 0.15714286, 0.17142858, - - 0.18571429, 0.2, 0.21428572, 0.22857143, 0.24285714, 0.25714287, - 0.27142859, 0.2857143, 0.3, 0.31428573, 0.32857144, 0.34285715}); - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_h_4d) -{ - Shape data_shape{1, 2, 3, 4}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{1}, vector{1}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.43145549f, 0.44721359f, - 0.99705452f, 0.98994946f, 0.98058069f, 0.97014254f, 0.95936549f, 0.94868332f, - 0.93834311f, 0.92847669f, 0.91914505f, 0.91036648f, 0.90213418f, 0.89442718f}); - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_1axis_5d) -{ - Shape data_shape{1, 2, 2, 2, 3}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{1}, vector{1}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.43145549f, 0.44721359f, - 0.99705452f, 0.98994946f, 0.98058069f, 0.97014254f, 0.95936549f, 0.94868332f, - 0.93834311f, 0.92847669f, 0.91914505f, 0.91036648f, 0.90213418f, 0.89442718f}); - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_123axes_5d) -{ - Shape data_shape{1, 2, 2, 2, 3}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{3}, vector{1, 2, 3}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.02638899f, 0.04956816f, 0.070014f, 0.10555596f, 0.1239204f, 0.140028f, - 0.18472293f, 0.19827265f, 0.210042f, 0.26388991f, 0.27262488f, 0.280056f, - 0.34305686f, 0.34697714f, 0.35007f, 0.42222384f, 0.42132938f, 0.420084f, - 0.50139081f, 0.49568161f, 0.49009803f, 0.58055776f, 0.57003385f, 0.560112f}); - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_c_2x2_shape) -{ - Shape data_shape{2, 2}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{}, vector{1}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.44721353f, 0.89442706f, 0.60000002f, 0.80000001f}); - - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_c_2x4_shape) -{ - Shape data_shape{2, 4}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{}, vector{1}); - float eps{1e-6f}; - auto eps_mode = op::EpsMode::ADD; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.18257418f, - 0.36514837f, - 0.54772252f, - 0.73029673f, - 0.37904903f, - 0.45485884f, - 0.53066862f, - 0.60647845f}); - - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - -NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_chw_4d_max_bias) -{ - Shape data_shape{1, 2, 3, 4}; - auto data = make_shared(element::f32, data_shape); - const auto axes = make_shared(element::i64, Shape{3}, vector{1, 2, 3}); - float eps{5000}; - auto eps_mode = op::EpsMode::MAX; - - auto normalize = make_shared(data, axes, eps, eps_mode); - auto function = make_shared(NodeVector{normalize}, 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.01414214f, 0.02828427f, 0.04242641f, 0.05656854f, 0.07071068f, 0.08485281f, - 0.09899495f, 0.11313709f, 0.12727922f, 0.14142136f, 0.15556349f, 0.16970563f, - 0.18384777f, 0.1979899f, 0.21213204f, 0.22627418f, 0.2404163f, 0.25455844f, - 0.26870057f, 0.28284273f, 0.29698485f, 0.31112698f, 0.32526913f, 0.33941126f}); - - test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 1); -} - NGRAPH_TEST(${BACKEND_NAME}, mvn_mean_normalization) { Shape data_shape{1, 2, 5}; diff --git a/ngraph/test/backend/normalize_l2.in.cpp b/ngraph/test/backend/normalize_l2.in.cpp index 863476280e6..e94ff8d4f65 100644 --- a/ngraph/test/backend/normalize_l2.in.cpp +++ b/ngraph/test/backend/normalize_l2.in.cpp @@ -14,8 +14,10 @@ #include "ngraph/ngraph.hpp" #include "util/all_close.hpp" #include "util/all_close_f.hpp" +#include "util/engine/test_engines.hpp" #include "util/ndarray.hpp" #include "util/random.hpp" +#include "util/test_case.hpp" #include "util/test_control.hpp" #include "util/test_tools.hpp" @@ -24,190 +26,865 @@ using namespace ngraph; static string s_manifest = "${MANIFEST}"; -// ----------------------- eps_mode = ngraph::op::EpsMode::ADD ----------------------- // +using TestEngine = test::ENGINE_CLASS_NAME(${BACKEND_NAME}); -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_all_mode_add) +static void normalize_l2_results_test(std::vector& data, + Shape& data_shape, + std::vector& axes, + ngraph::op::EpsMode eps_mode, + float eps, + std::vector& expected_output) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{2}, vector{0, 1}); - float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::ADD), - ParameterVector{A}); + auto data_input = std::make_shared(element::f32, data_shape); + const auto axes_input = std::make_shared(element::i32, Shape{axes.size()}, axes); - auto backend = runtime::Backend::create("${BACKEND_NAME}"); + auto normalize = std::make_shared(data_input, axes_input, eps, eps_mode); + auto function = std::make_shared(normalize, ParameterVector{data_input}); - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); + auto test_case = test::TestCase(function); + test_case.add_input(data); + test_case.add_expected_output(data_shape, expected_output); - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.18257418, 0.36514837, 0.5477226, 0.73029673}), - read_vector(result))); + test_case.run(DEFAULT_FLOAT_TOLERANCE_BITS + 4); } -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_none_mode_add) +// 1D +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_1D_axes_empty_add) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{0}, vector{}); + std::vector data{0, 3, 0, 8}; + Shape data_shape{4}; + std::vector axes{}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::ADD), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0, 1, 0, 1}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.18257418, 0.36514837, 0.5477226, 0.73029673}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_zero_mode_add) +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_1D_axes_empty_max) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{}, vector{0}); + std::vector data{0, 3, 0, 8}; + Shape data_shape{4}; + std::vector axes{}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::ADD), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0, 1, 0, 1}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.31622776, 0.4472136, 0.94868326, 0.8944272}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_one_mode_add) +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_1D_axes_0_add) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{}, vector{1}); + std::vector data{1, 2, 3, 4}; + Shape data_shape{4}; + std::vector axes{0}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::ADD), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0.18257418, 0.36514837, 0.5477226, 0.73029673}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.4472136, 0.8944272, 0.6, 0.8}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } -// ----------------------- eps_mode = ngraph::op::EpsMode::MAX ----------------------- // - -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_all_mode_max) +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_1D_axes_0_max) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{2}, vector{0, 1}); + std::vector data{1, 2, 3, 4}; + Shape data_shape{4}; + std::vector axes{0}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::ADD), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0.18257418, 0.36514837, 0.5477226, 0.73029673}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.18257419, 0.36514837, 0.54772256, 0.73029674}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_none_mode_max) +// 2D +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_empty_add) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{0}, vector{}); + std::vector data{0, 3, 0, 8}; + Shape data_shape{2, 2}; + std::vector axes{}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::MAX), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0, 1, 0, 1}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.18257419, 0.36514837, 0.54772256, 0.7302967}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_zero_mode_max) +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_empty_max) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{}, vector{0}); + std::vector data{0, 3, 0, 8}; + Shape data_shape{2, 2}; + std::vector axes{}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::MAX), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0, 1, 0, 1}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.31622777, 0.4472136, 0.9486833, 0.89442719}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } -NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_one_mode_max) +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_0_add) { - Shape shape{2, 2}; - auto A = make_shared(element::f32, shape); - auto axes = make_shared(element::i64, Shape{}, vector{1}); + std::vector data{1, 2, 3, 4}; + Shape data_shape{2, 2}; + std::vector axes{0}; float eps = 1e-7; - auto f = make_shared( - make_shared(A, axes, eps, ngraph::op::EpsMode::MAX), - ParameterVector{A}); + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0.31622776, 0.4472136, 0.94868326, 0.8944272}; - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - auto a = backend->create_tensor(element::f32, shape); - copy_data(a, vector{1, 2, 3, 4}); - auto result = backend->create_tensor(element::f32, shape); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {a}); - EXPECT_TRUE(test::all_close_f((vector{0.4472136, 0.89442719, 0.6, 0.8}), - read_vector(result))); + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_0_max) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{2, 2}; + std::vector axes{0}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0.31622777, 0.4472136, 0.9486833, 0.89442719}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_1_add) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{2, 2}; + std::vector axes{1}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0.4472136, 0.8944272, 0.6, 0.8}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_1_max) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{2, 2}; + std::vector axes{1}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0.4472136, 0.89442719, 0.6, 0.8}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_01_add) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{2, 2}; + std::vector axes{0, 1}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0.18257418, 0.36514837, 0.5477226, 0.73029673}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_2D_axes_01_max) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{2, 2}; + std::vector axes{0, 1}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0.18257419, 0.36514837, 0.54772256, 0.73029674}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +// 3D + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_3D_axes_1_add) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{1, 2, 2}; + std::vector axes{1}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0.31622776, 0.4472136, 0.94868326, 0.8944272}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_3D_axes_1_max) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{1, 2, 2}; + std::vector axes{1}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0.31622776, 0.4472136, 0.94868326, 0.8944272}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_3D_axes_2_add) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{1, 2, 2}; + std::vector axes{2}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{0.4472136, 0.8944272, 0.6, 0.8}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_3D_axes_2_max) +{ + std::vector data{1, 2, 3, 4}; + Shape data_shape{1, 2, 2}; + std::vector axes{2}; + float eps = 1e-7; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{0.4472136, 0.8944272, 0.6, 0.8}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +// 4D + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_empty_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 1); + std::vector axes{}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output(shape_size(data_shape), 1); + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_empty_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 1); + std::vector axes{}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output(shape_size(data_shape), 1); + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_0_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{0}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.03996804, 0.07669649, 0.11043153, 0.14142135, 0.1699069, 0.19611612, + 0.22026087, 0.2425356, 0.26311737, 0.2821663, 0.2998266, 0.31622776, 0.331486, + 0.34570533, 0.35897905, 0.37139067, 0.38301498, 0.3939193, 0.40416384, 0.41380292, + 0.42288542, 0.43145543, 0.43955287, 0.99999994, 0.9992009, 0.9970544, 0.9938838, + 0.98994946, 0.98546, 0.9805806, 0.97544104, 0.9701424, 0.96476364, 0.9593654, + 0.95399374, 0.9486833, 0.9434601, 0.93834305, 0.93334556, 0.9284767, 0.923742, + 0.919145, 0.91468656, 0.9103665, 0.90618306, 0.90213406, 0.8982167}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_0_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{0}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0399648, 0.0766909, 0.110424, 0.141413, 0.169897, 0.196106, 0.22025, + 0.242524, 0.263106, 0.282155, 0.299815, 0.316217, 0.331475, 0.345695, 0.358969, + 0.371381, 0.383005, 0.39391, 0.404155, 0.413794, 0.422877, 0.431447, 0.439545, + 0.999913, 0.999121, 0.996981, 0.993816, 0.989888, 0.985403, 0.980528, 0.975393, + 0.970098, 0.964723, 0.959327, 0.953958, 0.94865, 0.94343, 0.938315, 0.933319, + 0.928452, 0.923719, 0.919123, 0.914666, 0.910347, 0.906165, 0.902117, 0.8982}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_1_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.07669649, 0.14142135, 0.19611612, 0.2425356, 0.2821663, 0.31622776, + 0.34570533, 0.37139067, 0.3939193, 0.41380292, 0.43145543, 0.99999994, 0.9970544, + 0.98994946, 0.9805806, 0.9701424, 0.9593654, 0.9486833, 0.93834305, 0.9284767, + 0.919145, 0.9103665, 0.90213406, 0.5547002, 0.55985737, 0.56468385, 0.5692099, + 0.57346237, 0.57746464, 0.58123815, 0.5848015, 0.58817166, 0.59136367, 0.59439105, + 0.5972662, 0.83205026, 0.82858896, 0.8253072, 0.8221921, 0.8192319, 0.81641555, + 0.8137334, 0.8111763, 0.808736, 0.80640495, 0.8041761, 0.8020432}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_1_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0., 0.07667395, 0.14138602, 0.19607423, 0.24249104, 0.28212142, 0.31618387, + 0.3456632, 0.37135068, 0.3938816, 0.41376755, 0.43142232, 0.9996529, 0.9967614, + 0.9897021, 0.9803712, 0.96996415, 0.9592128, 0.94855154, 0.93822867, 0.9283767, + 0.9190571, 0.9102886, 0.9020648, 0.5546854, 0.55984336, 0.56467056, 0.56919736, + 0.5734503, 0.57745326, 0.58122724, 0.5847912, 0.58816177, 0.59135413, 0.594382, + 0.59725744, 0.8320281, 0.8285682, 0.82528776, 0.82217395, 0.8192147, 0.8163994, + 0.8137182, 0.81116194, 0.8087224, 0.806392, 0.8041638, 0.8020314}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_2_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.09667365, 0.16903085, 0.22423053, 0.4472136, 0.48336822, 0.50709254, + 0.52320457, 0.8944272, 0.8700628, 0.8451542, 0.8221786, 0.42426404, 0.4335743, + 0.4418361, 0.4492145, 0.5656854, 0.5669818, 0.56807494, 0.569005, 0.7071067, + 0.70038927, 0.6943139, 0.68879557, 0.49153918, 0.4945891, 0.49743116, 0.5000857, + 0.57346237, 0.5737234, 0.57395905, 0.5741725, 0.65538555, 0.6528576, 0.6504869, + 0.6482592, 0.51789176, 0.5193782, 0.52079225, 0.5221394, 0.5754353, 0.5755272, + 0.57561255, 0.5756921, 0.63297886, 0.6316762, 0.6304327, 0.62924486}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_2_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0966285, 0.168971, 0.224168, 0.446934, 0.483143, 0.506912, 0.523058, + 0.893869, 0.869657, 0.844853, 0.821949, 0.424238, 0.43355, 0.441814, 0.449194, + 0.56565, 0.56695, 0.568047, 0.56898, 0.707063, 0.70035, 0.694279, 0.688765, + 0.491529, 0.494579, 0.497422, 0.500077, 0.57345, 0.573712, 0.573949, 0.574163, + 0.655372, 0.652845, 0.650475, 0.648248, 0.517886, 0.519373, 0.520787, 0.522135, + 0.575429, 0.575521, 0.575607, 0.575687, 0.632972, 0.63167, 0.630427, 0.629239}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_3_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.26726124, 0.5345225, 0.8017837, 0.3563483, 0.44543537, 0.5345225, + 0.62360954, 0.41816667, 0.4704375, 0.52270836, 0.5749792, 0.44292808, 0.47983873, + 0.5167494, 0.5536601, 0.45621273, 0.484726, 0.5132393, 0.54175264, 0.4644887, + 0.4877131, 0.5109376, 0.534162, 0.47013652, 0.48972553, 0.50931454, 0.5289036, + 0.47423577, 0.49117276, 0.50810975, 0.5250467, 0.47734618, 0.49226326, 0.50718033, + 0.5220974, 0.4797868, 0.49311423, 0.50644165, 0.5197691, 0.48175293, 0.49379677, + 0.5058406, 0.51788443, 0.48337057, 0.49435627, 0.50534195, 0.5163277}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_3_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.266312, 0.532624, 0.798935, 0.356207, 0.445259, 0.534311, 0.623362, + 0.41811, 0.470373, 0.522637, 0.574901, 0.442898, 0.479806, 0.516714, 0.553622, + 0.456194, 0.484706, 0.513219, 0.541731, 0.464476, 0.4877, 0.510924, 0.534148, + 0.470128, 0.489716, 0.509305, 0.528893, 0.474229, 0.491166, 0.508102, 0.525039, + 0.477341, 0.492258, 0.507175, 0.522092, 0.479783, 0.49311, 0.506437, 0.519764, + 0.481749, 0.493793, 0.505837, 0.517881, 0.483368, 0.494353, 0.505339, 0.516325}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_23_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2, 3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.04445542, 0.08891085, 0.13336627, 0.1778217, 0.22227712, 0.26673254, + 0.31118798, 0.3556434, 0.4000988, 0.44455424, 0.48900968, 0.19420628, 0.21039014, + 0.226574, 0.24275786, 0.2589417, 0.27512556, 0.29130942, 0.30749327, 0.32367712, + 0.339861, 0.35604486, 0.3722287, 0.23326269, 0.24298197, 0.25270125, 0.26242054, + 0.2721398, 0.28185907, 0.29157835, 0.30129763, 0.31101692, 0.3207362, 0.33045548, + 0.34017476, 0.24955511, 0.2564872, 0.26341927, 0.27035138, 0.27728346, 0.28421554, + 0.29114762, 0.2980797, 0.3050118, 0.3119439, 0.31887597, 0.32580805}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_23_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2, 3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0., 0.04445103, 0.08890206, 0.1333531, 0.17780413, 0.22225516, 0.2667062, + 0.31115723, 0.35560825, 0.40005928, 0.4445103, 0.48896134, 0.19420375, 0.2103874, + 0.22657104, 0.24275468, 0.2589383, 0.275122, 0.29130563, 0.30748928, 0.32367292, + 0.33985656, 0.3560402, 0.37222385, 0.2332616, 0.24298084, 0.25270006, 0.2624193, + 0.27213854, 0.2818578, 0.291577, 0.30129623, 0.3110155, 0.3207347, 0.33045393, + 0.34017318, 0.2495545, 0.25648656, 0.26341864, 0.27035072, 0.27728277, 0.28421485, + 0.29114693, 0.29807898, 0.30501106, 0.3119431, 0.3188752, 0.32580727}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_123_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1, 2, 3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.01520748, 0.03041495, 0.04562243, 0.06082991, 0.07603738, 0.09124486, + 0.10645234, 0.12165982, 0.13686728, 0.15207477, 0.16728225, 0.18248972, 0.19769719, + 0.21290468, 0.22811216, 0.24331963, 0.2585271, 0.27373457, 0.28894207, 0.30414954, + 0.319357, 0.3345645, 0.34977198, 0.13544846, 0.14109215, 0.14673583, 0.15237951, + 0.15802321, 0.16366689, 0.16931057, 0.17495427, 0.18059795, 0.18624163, 0.19188532, + 0.197529, 0.20317268, 0.20881638, 0.21446006, 0.22010374, 0.22574744, 0.23139112, + 0.2370348, 0.2426785, 0.24832217, 0.25396585, 0.25960955, 0.26525325}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_123_big_eps_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1, 2, 3}; + float eps = 100; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.01520748, 0.03041495, 0.04562243, 0.06082991, 0.07603738, 0.09124486, + 0.10645234, 0.12165982, 0.13686728, 0.15207477, 0.16728225, 0.18248972, 0.19769719, + 0.21290468, 0.22811216, 0.24331963, 0.2585271, 0.27373457, 0.28894207, 0.30414954, + 0.319357, 0.3345645, 0.34977198, 0.13544846, 0.14109215, 0.14673583, 0.15237951, + 0.15802321, 0.16366689, 0.16931057, 0.17495427, 0.18059795, 0.18624163, 0.19188532, + 0.197529, 0.20317268, 0.20881638, 0.21446006, 0.22010374, 0.22574744, 0.23139112, + 0.2370348, 0.2426785, 0.24832217, 0.25396585, 0.25960955, 0.26525325}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_123_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1, 2, 3}; + float eps = 1e-9; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0152075, 0.030415, 0.0456224, 0.0608299, 0.0760374, 0.0912449, 0.106452, + 0.12166, 0.136867, 0.152075, 0.167282, 0.18249, 0.197697, 0.212905, 0.228112, + 0.24332, 0.258527, 0.273735, 0.288942, 0.30415, 0.319357, 0.334565, 0.349772, + 0.135448, 0.141092, 0.146736, 0.15238, 0.158023, 0.163667, 0.169311, 0.174954, + 0.180598, 0.186242, 0.191885, 0.197529, 0.203173, 0.208816, 0.21446, 0.220104, + 0.225747, 0.231391, 0.237035, 0.242678, 0.248322, 0.253966, 0.25961, 0.265253}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_123_big_eps_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1, 2, 3}; + float eps = 0.5; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0152066, 0.0304132, 0.0456198, 0.0608264, 0.076033, 0.0912396, 0.106446, + 0.121653, 0.136859, 0.152066, 0.167273, 0.182479, 0.197686, 0.212892, 0.228099, + 0.243306, 0.258512, 0.273719, 0.288925, 0.304132, 0.319339, 0.334545, 0.349752, + 0.135447, 0.141091, 0.146735, 0.152378, 0.158022, 0.163666, 0.169309, 0.174953, + 0.180597, 0.18624, 0.191884, 0.197527, 0.203171, 0.208815, 0.214458, 0.220102, + 0.225746, 0.231389, 0.237033, 0.242677, 0.24832, 0.253964, 0.259607, 0.265251}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_unsorted_312_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3, 1, 2}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.01520748, 0.03041495, 0.04562243, 0.06082991, 0.07603738, 0.09124486, + 0.10645234, 0.12165982, 0.13686728, 0.15207477, 0.16728225, 0.18248972, 0.19769719, + 0.21290468, 0.22811216, 0.24331963, 0.2585271, 0.27373457, 0.28894207, 0.30414954, + 0.319357, 0.3345645, 0.34977198, 0.13544846, 0.14109215, 0.14673583, 0.15237951, + 0.15802321, 0.16366689, 0.16931057, 0.17495427, 0.18059795, 0.18624163, 0.19188532, + 0.197529, 0.20317268, 0.20881638, 0.21446006, 0.22010374, 0.22574744, 0.23139112, + 0.2370348, 0.2426785, 0.24832217, 0.25396585, 0.25960955, 0.26525325}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_unsorted_312_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3, 1, 2}; + float eps = 1e-9; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0152075, 0.030415, 0.0456224, 0.0608299, 0.0760374, 0.0912449, 0.106452, + 0.12166, 0.136867, 0.152075, 0.167282, 0.18249, 0.197697, 0.212905, 0.228112, + 0.24332, 0.258527, 0.273735, 0.288942, 0.30415, 0.319357, 0.334565, 0.349772, + 0.135448, 0.141092, 0.146736, 0.15238, 0.158023, 0.163667, 0.169311, 0.174954, + 0.180598, 0.186242, 0.191885, 0.197529, 0.203173, 0.208816, 0.21446, 0.220104, + 0.225747, 0.231391, 0.237035, 0.242678, 0.248322, 0.253966, 0.25961, 0.265253}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_0123_max) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{0, 1, 2, 3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.00529108, 0.01058216, 0.01587324, 0.02116432, 0.02645539, 0.03174648, + 0.03703756, 0.04232863, 0.04761971, 0.05291079, 0.05820187, 0.06349295, 0.06878403, + 0.07407511, 0.07936618, 0.08465727, 0.08994835, 0.09523942, 0.10053051, 0.10582158, + 0.11111266, 0.11640374, 0.12169482, 0.12698591, 0.13227698, 0.13756806, 0.14285913, + 0.14815022, 0.1534413, 0.15873237, 0.16402346, 0.16931453, 0.17460561, 0.1798967, + 0.18518777, 0.19047885, 0.19576994, 0.20106101, 0.20635208, 0.21164316, 0.21693425, + 0.22222532, 0.2275164, 0.23280749, 0.23809856, 0.24338964, 0.24868073}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_4D_axes_0123_add) +{ + Shape data_shape{2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{0, 1, 2, 3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0., 0.00529108, 0.01058216, 0.01587324, 0.02116432, 0.02645539, 0.03174648, + 0.03703756, 0.04232863, 0.04761971, 0.05291079, 0.05820187, 0.06349295, 0.06878403, + 0.07407511, 0.07936618, 0.08465727, 0.08994835, 0.09523942, 0.10053051, 0.10582158, + 0.11111266, 0.11640374, 0.12169482, 0.12698591, 0.13227698, 0.13756806, 0.14285913, + 0.14815022, 0.1534413, 0.15873237, 0.16402346, 0.16931453, 0.17460561, 0.1798967, + 0.18518777, 0.19047885, 0.19576994, 0.20106101, 0.20635208, 0.21164316, 0.21693425, + 0.22222532, 0.2275164, 0.23280749, 0.23809856, 0.24338964, 0.24868073}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_empty_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 1); + std::vector axes{}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output(shape_size(data_shape), 1); + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_empty_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 1); + std::vector axes{}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output(shape_size(data_shape), 1); + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_1_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.03996804, 0.07669649, 0.11043153, 0.14142135, 0.1699069, 0.19611612, + 0.22026087, 0.2425356, 0.26311737, 0.2821663, 0.2998266, 0.31622776, 0.331486, + 0.34570533, 0.35897905, 0.37139067, 0.38301498, 0.3939193, 0.40416384, 0.41380292, + 0.42288542, 0.43145543, 0.43955287, 0.99999994, 0.9992009, 0.9970544, 0.9938838, + 0.98994946, 0.98546, 0.9805806, 0.97544104, 0.9701424, 0.96476364, 0.9593654, + 0.95399374, 0.9486833, 0.9434601, 0.93834305, 0.93334556, 0.9284767, 0.923742, + 0.919145, 0.91468656, 0.9103665, 0.90618306, 0.90213406, 0.8982167}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_1_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{1}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0399648, 0.0766909, 0.110424, 0.141413, 0.169897, 0.196106, 0.22025, + 0.242524, 0.263106, 0.282155, 0.299815, 0.316217, 0.331475, 0.345695, 0.358969, + 0.371381, 0.383005, 0.39391, 0.404155, 0.413794, 0.422877, 0.431447, 0.439545, + 0.999913, 0.999121, 0.996981, 0.993816, 0.989888, 0.985403, 0.980528, 0.975393, + 0.970098, 0.964723, 0.959327, 0.953958, 0.94865, 0.94343, 0.938315, 0.933319, + 0.928452, 0.923719, 0.919123, 0.914666, 0.910347, 0.906165, 0.902117, 0.8982}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_2_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.07669649, 0.14142135, 0.19611612, 0.2425356, 0.2821663, 0.31622776, + 0.34570533, 0.37139067, 0.3939193, 0.41380292, 0.43145543, 0.99999994, 0.9970544, + 0.98994946, 0.9805806, 0.9701424, 0.9593654, 0.9486833, 0.93834305, 0.9284767, + 0.919145, 0.9103665, 0.90213406, 0.5547002, 0.55985737, 0.56468385, 0.5692099, + 0.57346237, 0.57746464, 0.58123815, 0.5848015, 0.58817166, 0.59136367, 0.59439105, + 0.5972662, 0.83205026, 0.82858896, 0.8253072, 0.8221921, 0.8192319, 0.81641555, + 0.8137334, 0.8111763, 0.808736, 0.80640495, 0.8041761, 0.8020432}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_2_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0., 0.07667395, 0.14138602, 0.19607423, 0.24249104, 0.28212142, 0.31618387, + 0.3456632, 0.37135068, 0.3938816, 0.41376755, 0.43142232, 0.9996529, 0.9967614, + 0.9897021, 0.9803712, 0.96996415, 0.9592128, 0.94855154, 0.93822867, 0.9283767, + 0.9190571, 0.9102886, 0.9020648, 0.5546854, 0.55984336, 0.56467056, 0.56919736, + 0.5734503, 0.57745326, 0.58122724, 0.5847912, 0.58816177, 0.59135413, 0.594382, + 0.59725744, 0.8320281, 0.8285682, 0.82528776, 0.82217395, 0.8192147, 0.8163994, + 0.8137182, 0.81116194, 0.8087224, 0.806392, 0.8041638, 0.8020314}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_3_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.09667365, 0.16903085, 0.22423053, 0.4472136, 0.48336822, 0.50709254, + 0.52320457, 0.8944272, 0.8700628, 0.8451542, 0.8221786, 0.42426404, 0.4335743, + 0.4418361, 0.4492145, 0.5656854, 0.5669818, 0.56807494, 0.569005, 0.7071067, + 0.70038927, 0.6943139, 0.68879557, 0.49153918, 0.4945891, 0.49743116, 0.5000857, + 0.57346237, 0.5737234, 0.57395905, 0.5741725, 0.65538555, 0.6528576, 0.6504869, + 0.6482592, 0.51789176, 0.5193782, 0.52079225, 0.5221394, 0.5754353, 0.5755272, + 0.57561255, 0.5756921, 0.63297886, 0.6316762, 0.6304327, 0.62924486}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_3_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.0966285, 0.168971, 0.224168, 0.446934, 0.483143, 0.506912, 0.523058, + 0.893869, 0.869657, 0.844853, 0.821949, 0.424238, 0.43355, 0.441814, 0.449194, + 0.56565, 0.56695, 0.568047, 0.56898, 0.707063, 0.70035, 0.694279, 0.688765, + 0.491529, 0.494579, 0.497422, 0.500077, 0.57345, 0.573712, 0.573949, 0.574163, + 0.655372, 0.652845, 0.650475, 0.648248, 0.517886, 0.519373, 0.520787, 0.522135, + 0.575429, 0.575521, 0.575607, 0.575687, 0.632972, 0.63167, 0.630427, 0.629239}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_4_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{4}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.26726124, 0.5345225, 0.8017837, 0.3563483, 0.44543537, 0.5345225, + 0.62360954, 0.41816667, 0.4704375, 0.52270836, 0.5749792, 0.44292808, 0.47983873, + 0.5167494, 0.5536601, 0.45621273, 0.484726, 0.5132393, 0.54175264, 0.4644887, + 0.4877131, 0.5109376, 0.534162, 0.47013652, 0.48972553, 0.50931454, 0.5289036, + 0.47423577, 0.49117276, 0.50810975, 0.5250467, 0.47734618, 0.49226326, 0.50718033, + 0.5220974, 0.4797868, 0.49311423, 0.50644165, 0.5197691, 0.48175293, 0.49379677, + 0.5058406, 0.51788443, 0.48337057, 0.49435627, 0.50534195, 0.5163277}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_4_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{4}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0, 0.266312, 0.532624, 0.798935, 0.356207, 0.445259, 0.534311, 0.623362, + 0.41811, 0.470373, 0.522637, 0.574901, 0.442898, 0.479806, 0.516714, 0.553622, + 0.456194, 0.484706, 0.513219, 0.541731, 0.464476, 0.4877, 0.510924, 0.534148, + 0.470128, 0.489716, 0.509305, 0.528893, 0.474229, 0.491166, 0.508102, 0.525039, + 0.477341, 0.492258, 0.507175, 0.522092, 0.479783, 0.49311, 0.506437, 0.519764, + 0.481749, 0.493793, 0.505837, 0.517881, 0.483368, 0.494353, 0.505339, 0.516325}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_34_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3, 4}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.04445542, 0.08891085, 0.13336627, 0.1778217, 0.22227712, 0.26673254, + 0.31118798, 0.3556434, 0.4000988, 0.44455424, 0.48900968, 0.19420628, 0.21039014, + 0.226574, 0.24275786, 0.2589417, 0.27512556, 0.29130942, 0.30749327, 0.32367712, + 0.339861, 0.35604486, 0.3722287, 0.23326269, 0.24298197, 0.25270125, 0.26242054, + 0.2721398, 0.28185907, 0.29157835, 0.30129763, 0.31101692, 0.3207362, 0.33045548, + 0.34017476, 0.24955511, 0.2564872, 0.26341927, 0.27035138, 0.27728346, 0.28421554, + 0.29114762, 0.2980797, 0.3050118, 0.3119439, 0.31887597, 0.32580805}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_34_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{3, 4}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0., 0.04445103, 0.08890206, 0.1333531, 0.17780413, 0.22225516, 0.2667062, + 0.31115723, 0.35560825, 0.40005928, 0.4445103, 0.48896134, 0.19420375, 0.2103874, + 0.22657104, 0.24275468, 0.2589383, 0.275122, 0.29130563, 0.30748928, 0.32367292, + 0.33985656, 0.3560402, 0.37222385, 0.2332616, 0.24298084, 0.25270006, 0.2624193, + 0.27213854, 0.2818578, 0.291577, 0.30129623, 0.3110155, 0.3207347, 0.33045393, + 0.34017318, 0.2495545, 0.25648656, 0.26341864, 0.27035072, 0.27728277, 0.28421485, + 0.29114693, 0.29807898, 0.30501106, 0.3119431, 0.3188752, 0.32580727}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_234_max) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2, 3, 4}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::MAX; + std::vector expected_output{ + 0., 0.01520748, 0.03041495, 0.04562243, 0.06082991, 0.07603738, 0.09124486, + 0.10645234, 0.12165982, 0.13686728, 0.15207477, 0.16728225, 0.18248972, 0.19769719, + 0.21290468, 0.22811216, 0.24331963, 0.2585271, 0.27373457, 0.28894207, 0.30414954, + 0.319357, 0.3345645, 0.34977198, 0.13544846, 0.14109215, 0.14673583, 0.15237951, + 0.15802321, 0.16366689, 0.16931057, 0.17495427, 0.18059795, 0.18624163, 0.19188532, + 0.197529, 0.20317268, 0.20881638, 0.21446006, 0.22010374, 0.22574744, 0.23139112, + 0.2370348, 0.2426785, 0.24832217, 0.25396585, 0.25960955, 0.26525325}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); +} + +NGRAPH_TEST(${BACKEND_NAME}, normalize_l2_5D_axes_234_add) +{ + Shape data_shape{1, 2, 2, 3, 4}; + std::vector data(shape_size(data_shape)); + iota(begin(data), end(data), 0); + std::vector axes{2, 3, 4}; + float eps = 0.1; + auto eps_mode = ngraph::op::EpsMode::ADD; + std::vector expected_output{ + 0., 0.0152073, 0.0304146, 0.0456219, 0.0608292, 0.07603651, 0.0912438, + 0.10645111, 0.12165841, 0.1368657, 0.15207301, 0.16728032, 0.1824876, 0.19769491, + 0.21290222, 0.22810951, 0.24331681, 0.25852412, 0.2737314, 0.28893873, 0.30414602, + 0.3193533, 0.33456063, 0.34976792, 0.13544825, 0.14109191, 0.1467356, 0.15237927, + 0.15802296, 0.16366662, 0.1693103, 0.17495398, 0.18059766, 0.18624133, 0.19188501, + 0.19752869, 0.20317237, 0.20881604, 0.21445972, 0.2201034, 0.22574706, 0.23139074, + 0.23703443, 0.2426781, 0.24832177, 0.25396547, 0.25960913, 0.2652528}; + + normalize_l2_results_test(data, data_shape, axes, eps_mode, eps, expected_output); } diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 842ee31ccf7..fd6a5df50ce 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -339,13 +339,7 @@ max_matrix_to_scalar_zero_by_zero max_3d_eliminate_zero_dim lrn_across_empty lrn_2d_across_empty -normalize_across_empty_axes_input -normalize_l2_all_mode_add -normalize_l2_none_mode_add -normalize_l2_zero_mode_add -normalize_l2_all_mode_max -normalize_l2_none_mode_max -normalize_l2_zero_mode_max + squeeze_default_axes dynamic_abc broadcast_v1 @@ -426,7 +420,6 @@ lrn_across_all_dims elu elu_negative_alpha max_pool_2d_1channel_1image_overpadded -normalize_across_chw_4d_max_bias grn_2d_with_bias erf divide_adjoint_stability @@ -676,10 +669,6 @@ conv_bias_bprop_2d # Cannot cast ngraph node ConvolutionBiasAdd to CNNLayer! conv_bias_add_2d -# [Validation] Argument must have rank >= 2 and <= 4 (argument shape: {1,2,2,2,3}) -normalize_across_1axis_5d -normalize_across_123axes_5d - # Unsupported operator detected in the graph. gemm gemm_C @@ -917,6 +906,56 @@ non_zero non_zero_all_1s non_zero_all_0s +# NormalizeL2 - output mismatch, +# mkldnn_normalize_nchw applies eps after sqrt for across_spatial +# Issue: 59586 +IE_CPU.normalize_l2_4D_axes_123_big_eps_max +IE_CPU.normalize_l2_4D_axes_123_big_eps_add + +# NomalizeL2 - unsorted axes are not supported, +# message: "Doesn't support reduction axes: (3.1.2)" +# Issue: 59794 +IE_CPU.normalize_l2_4D_axes_unsorted_312_max +IE_CPU.normalize_l2_4D_axes_unsorted_312_add + +# NormalizeL2 - Plugins support normalize over "channel" dimension +# or "channel + all spatial" dimensions for 2D, 3D or 4D cases +# Issue: 35627, 59791 +normalize_l2_1D_axes_empty_add +normalize_l2_1D_axes_empty_max +normalize_l2_1D_axes_0_add +normalize_l2_1D_axes_0_max +normalize_l2_2D_axes_0_add +normalize_l2_2D_axes_0_max +normalize_l2_2D_axes_01_add +normalize_l2_2D_axes_01_max +normalize_l2_3D_axes_2_add +normalize_l2_3D_axes_2_max +normalize_l2_4D_axes_0_max +normalize_l2_4D_axes_0_add +normalize_l2_4D_axes_2_max +normalize_l2_4D_axes_2_add +normalize_l2_4D_axes_3_max +normalize_l2_4D_axes_3_add +normalize_l2_4D_axes_23_max +normalize_l2_4D_axes_23_add +normalize_l2_4D_axes_0123_max +normalize_l2_4D_axes_0123_add +normalize_l2_5D_axes_empty_max +normalize_l2_5D_axes_empty_add +normalize_l2_5D_axes_1_max +normalize_l2_5D_axes_1_add +normalize_l2_5D_axes_2_max +normalize_l2_5D_axes_2_add +normalize_l2_5D_axes_3_max +normalize_l2_5D_axes_3_add +normalize_l2_5D_axes_4_max +normalize_l2_5D_axes_4_add +normalize_l2_5D_axes_34_max +normalize_l2_5D_axes_34_add +normalize_l2_5D_axes_234_max +normalize_l2_5D_axes_234_add + # (Constant W, R inputs are required) Ticket: 49207 # W, R inputs as Parameter, default clip value # Operation has a form that is not supported.