From cb61ad46bdfecfd17c87669950e2cef3593d365c Mon Sep 17 00:00:00 2001 From: Oleg Pipikin Date: Thu, 12 Oct 2023 20:27:55 +0200 Subject: [PATCH] Refactor CumSumLayerTest, DeformablePSROIPoolingLayerTest, DepthToSpaceLayerTest (#19870) * Refactor CumSumLayerTest * Refactor DeformablePSROIPoolingLayerTest * Refactor DepthToSpaceLayerTest --- .../single_layer_tests/cum_sum.cpp | 74 ++++++------ .../deformable_psroi_pooling.cpp | 36 +++--- .../single_layer_tests/depth_to_space.cpp | 55 +++++---- .../single_layer_tests/roi_pooling.cpp | 9 +- .../dynamic/roi_pooling.cpp | 9 +- .../include/single_op_tests/cum_sum.hpp | 15 +++ .../deformable_psroi_pooling.hpp | 15 +++ .../single_op_tests/depth_to_space.hpp | 15 +++ .../shared_test_classes/single_op/cum_sum.hpp | 33 ++++++ .../single_op/deformable_psroi_pooling.hpp | 39 +++++++ .../single_op/depth_to_space.hpp | 33 ++++++ .../src/base/utils/generate_inputs.cpp | 22 ++++ .../src/single_op/cum_sum.cpp | 54 +++++++++ .../single_op/deformable_psroi_pooling.cpp | 110 ++++++++++++++++++ .../src/single_op/depth_to_space.cpp | 72 ++++++++++++ .../include/common_test_utils/data_utils.hpp | 52 ++------- .../common_test_utils/src/data_utils.cpp | 82 +++++++++++++ 17 files changed, 600 insertions(+), 125 deletions(-) create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/cum_sum.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/deformable_psroi_pooling.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/depth_to_space.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/cum_sum.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/deformable_psroi_pooling.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/depth_to_space.hpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/cum_sum.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/deformable_psroi_pooling.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/depth_to_space.cpp diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/cum_sum.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/cum_sum.cpp index f55650c696bc2a..19440f5ae88fe7 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/cum_sum.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/cum_sum.cpp @@ -4,27 +4,28 @@ #include -#include "single_layer_tests/cum_sum.hpp" +#include "single_op_tests/cum_sum.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; - -const std::vector> shapes = { - {16}, - {9, 15}, - {16, 10, 12}, - {5, 14, 5, 7}, - {7, 8, 6, 7, 13}, - {2, 3, 4, 2, 3, 5}, - {4, 3, 6, 2, 3, 4, 5, 2, 3, 4}, +namespace { +using ov::test::CumSumLayerTest; + +const std::vector> shapes_static = { + {{16}}, + {{9, 15}}, + {{16, 10, 12}}, + {{5, 14, 5, 7}}, + {{7, 8, 6, 7, 13}}, + {{2, 3, 4, 2, 3, 5}}, + {{4, 3, 6, 2, 3, 4, 5, 2, 3, 4}}, }; -const std::vector inputPrecision = { - InferenceEngine::Precision::I8, - InferenceEngine::Precision::U8, - InferenceEngine::Precision::I16, - InferenceEngine::Precision::I32, - InferenceEngine::Precision::FP32 +const std::vector model_types = { + ov::element::i8, + ov::element::u8, + ov::element::i16, + ov::element::i32, + ov::element::f32 }; const std::vector axes = { 0, 1, 2, 3, 4, 5, 6}; @@ -34,8 +35,8 @@ const std::vector exclusive = {true, false}; const std::vector reverse = {true, false}; const auto testCasesNegativeAxis = ::testing::Combine( - ::testing::Values(std::vector{4, 16, 3, 6, 5, 2}), - ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(ov::test::static_shapes_to_test_representation({{4, 16, 3, 6, 5, 2}})), + ::testing::Values(ov::element::f32), ::testing::ValuesIn(negativeAxes), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -43,8 +44,8 @@ const auto testCasesNegativeAxis = ::testing::Combine( ); const auto testCasesAxis_0 = ::testing::Combine( - ::testing::ValuesIn(shapes), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes_static)), + ::testing::ValuesIn(model_types), ::testing::Values(axes[0]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -52,8 +53,9 @@ const auto testCasesAxis_0 = ::testing::Combine( ); const auto testCasesAxis_1 = ::testing::Combine( - ::testing::ValuesIn(std::vector>(shapes.begin() + 1, shapes.end())), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation( + std::vector>(shapes_static.begin() + 1, shapes_static.end()))), + ::testing::ValuesIn(model_types), ::testing::Values(axes[1]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -61,8 +63,9 @@ const auto testCasesAxis_1 = ::testing::Combine( ); const auto testCasesAxis_2 = ::testing::Combine( - ::testing::ValuesIn(std::vector>(shapes.begin() + 2, shapes.end())), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation( + std::vector>(shapes_static.begin() + 2, shapes_static.end()))), + ::testing::ValuesIn(model_types), ::testing::Values(axes[2]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -70,8 +73,9 @@ const auto testCasesAxis_2 = ::testing::Combine( ); const auto testCasesAxis_3 = ::testing::Combine( - ::testing::ValuesIn(std::vector>(shapes.begin() + 3, shapes.end())), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation( + std::vector>(shapes_static.begin() + 3, shapes_static.end()))), + ::testing::ValuesIn(model_types), ::testing::Values(axes[3]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -79,8 +83,9 @@ const auto testCasesAxis_3 = ::testing::Combine( ); const auto testCasesAxis_4 = ::testing::Combine( - ::testing::ValuesIn(std::vector>(shapes.begin() + 4, shapes.end())), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation( + std::vector>(shapes_static.begin() + 4, shapes_static.end()))), + ::testing::ValuesIn(model_types), ::testing::Values(axes[4]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -88,8 +93,9 @@ const auto testCasesAxis_4 = ::testing::Combine( ); const auto testCasesAxis_5 = ::testing::Combine( - ::testing::ValuesIn(std::vector>(shapes.begin() + 5, shapes.end())), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation( + std::vector>(shapes_static.begin() + 5, shapes_static.end()))), + ::testing::ValuesIn(model_types), ::testing::Values(axes[5]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -97,8 +103,9 @@ const auto testCasesAxis_5 = ::testing::Combine( ); const auto testCasesAxis_6 = ::testing::Combine( - ::testing::ValuesIn(std::vector>(shapes.begin() + 6, shapes.end())), - ::testing::ValuesIn(inputPrecision), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation( + std::vector>(shapes_static.begin() + 6, shapes_static.end()))), + ::testing::ValuesIn(model_types), ::testing::Values(axes[6]), ::testing::ValuesIn(exclusive), ::testing::ValuesIn(reverse), @@ -113,3 +120,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_3, CumSumLayerTest, testCasesAxi INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_4, CumSumLayerTest, testCasesAxis_4, CumSumLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_5, CumSumLayerTest, testCasesAxis_5, CumSumLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_6, CumSumLayerTest, testCasesAxis_6, CumSumLayerTest::getTestCaseName); +} // namespace \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp index e277e417c645f6..785aba8c1a1ef8 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/deformable_psroi_pooling.cpp @@ -4,17 +4,21 @@ #include -#include "single_layer_tests/deformable_psroi_pooling.hpp" +#include "single_op_tests/deformable_psroi_pooling.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; - namespace { +using ov::test::DeformablePSROIPoolingLayerTest; + + std::vector> shapes_static { + //dataShape, roisShape, offsetsShape + {{3, 8, 16, 16}, {10, 5}}, + {{1, 8, 67, 32}, {10, 5}}, + {{3, 8, 16, 16}, {10, 5}, {10, 2, 2, 2}}, + {{1, 8, 67, 32}, {10, 5}, {10, 2, 2, 2}}, + }; + const auto deformablePSROIParams = ::testing::Combine( - ::testing::ValuesIn(std::vector>{{3, 8, 16, 16}, {1, 8, 67, 32}}), // data input shape - ::testing::Values(std::vector{10, 5}), // rois input shape - // Empty offsets shape means test without optional third input - ::testing::ValuesIn(std::vector>{{}, {10, 2, 2, 2}}), // offsets input shape ::testing::Values(2), // output_dim ::testing::Values(2), // group_size ::testing::ValuesIn(std::vector{1.0f, 0.5f, 0.0625f}), // spatial scale @@ -24,17 +28,20 @@ namespace { const auto deformablePSROICases_test_params = ::testing::Combine( deformablePSROIParams, - ::testing::Values(InferenceEngine::Precision::FP32), // Net precision - ::testing::Values(ov::test::utils::DEVICE_CPU)); // Device name + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes_static)), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params, DeformablePSROIPoolingLayerTest::getTestCaseName); + std::vector> shapes_advanced_static { + //dataShape, roisShape, offsetsShape + {{2, 441, 63, 38}, {30, 5}, {30, 2, 3, 3}} + }; + const auto deformablePSROIParams_advanced = ::testing::Combine( - ::testing::ValuesIn(std::vector>{{2, 441, 63, 38}}), // data input shape - ::testing::Values(std::vector{30, 5}), // rois input shape - ::testing::Values(std::vector{30, 2, 3, 3}), // offsets input shape ::testing::Values(49), // output_dim ::testing::Values(3), // group_size ::testing::ValuesIn(std::vector{0.0625}), // spatial scale @@ -44,8 +51,9 @@ namespace { const auto deformablePSROICases_test_params_advanced = ::testing::Combine( deformablePSROIParams_advanced, - ::testing::Values(InferenceEngine::Precision::FP32), // Net precision - ::testing::Values(ov::test::utils::DEVICE_CPU)); // Device name + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes_advanced_static)), + ::testing::Values(ov::element::f32), + ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling_advanced, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params_advanced, DeformablePSROIPoolingLayerTest::getTestCaseName); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/depth_to_space.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/depth_to_space.cpp index aca6f2e621de51..5e84ede53312b5 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/depth_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/depth_to_space.cpp @@ -2,20 +2,17 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include - -#include "single_layer_tests/depth_to_space.hpp" +#include "single_op_tests/depth_to_space.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; -using namespace ngraph::opset3; - namespace { -const std::vector inputPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::U8, - InferenceEngine::Precision::I16, +using ov::test::DepthToSpaceLayerTest; +using ov::op::v0::DepthToSpace; + +const std::vector model_types = { + ov::element::f32, + ov::element::u8, + ov::element::i16, }; const std::vector modes = { @@ -23,14 +20,22 @@ const std::vector modes = { DepthToSpace::DepthToSpaceMode::DEPTH_FIRST }; -const std::vector> inputShapesBS2 = { - {1, 4, 1, 1}, {1, 4, 2, 2}, {1, 4, 3, 3}, {2, 32, 3, 3}, {2, 16, 5, 4}, - {1, 8, 1, 1, 1}, {1, 8, 2, 2, 2}, {1, 8, 3, 3, 3}, {2, 32, 3, 3, 3}, {2, 16, 5, 4, 6} +const std::vector> input_shapes_bs2_static = { + {{1, 4, 1, 1}}, + {{1, 4, 2, 2}}, + {{1, 4, 3, 3}}, + {{2, 32, 3, 3}}, + {{2, 16, 5, 4}}, + {{1, 8, 1, 1, 1}}, + {{1, 8, 2, 2, 2}}, + {{1, 8, 3, 3, 3}}, + {{2, 32, 3, 3, 3}}, + {{2, 16, 5, 4, 6}} }; const auto DepthToSpaceBS2 = ::testing::Combine( - ::testing::ValuesIn(inputShapesBS2), - ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_bs2_static)), + ::testing::ValuesIn(model_types), ::testing::ValuesIn(modes), ::testing::Values(1, 2), ::testing::Values(ov::test::utils::DEVICE_CPU) @@ -38,14 +43,22 @@ const auto DepthToSpaceBS2 = ::testing::Combine( INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpaceBS2, DepthToSpaceLayerTest, DepthToSpaceBS2, DepthToSpaceLayerTest::getTestCaseName); -const std::vector> inputShapesBS3 = { - {1, 9, 1, 1}, {1, 9, 2, 2}, {1, 9, 3, 3}, {2, 36, 3, 3}, {2, 27, 5, 4}, - {1, 27, 1, 1, 1}, {1, 27, 2, 2, 2}, {1, 27, 3, 3, 3}, {2, 108, 3, 3, 3}, {2, 54, 5, 4, 6} +const std::vector> input_shapes_bs3_static = { + {{1, 9, 1, 1}}, + {{1, 9, 2, 2}}, + {{1, 9, 3, 3}}, + {{2, 36, 3, 3}}, + {{2, 27, 5, 4}}, + {{1, 27, 1, 1, 1}}, + {{1, 27, 2, 2, 2}}, + {{1, 27, 3, 3, 3}}, + {{2, 108, 3, 3, 3}}, + {{2, 54, 5, 4, 6}} }; const auto DepthToSpaceBS3 = ::testing::Combine( - ::testing::ValuesIn(inputShapesBS3), - ::testing::ValuesIn(inputPrecisions), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_bs3_static)), + ::testing::ValuesIn(model_types), ::testing::ValuesIn(modes), ::testing::Values(1, 3), ::testing::Values(ov::test::utils::DEVICE_CPU) diff --git a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp index f8c2235f02cb09..c5d3047452a122 100644 --- a/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/single_layer_tests/roi_pooling.cpp @@ -155,12 +155,9 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode); - break; - } - case ngraph::element::bf16: { - ov::test::utils::fill_data_roi(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode); + case ov::element::f32: + case ov::element::bf16: { + ov::test::utils::fill_data_roi(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode); break; } default: diff --git a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/roi_pooling.cpp b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/roi_pooling.cpp index eee9451c206413..34ac60f2752c08 100644 --- a/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/roi_pooling.cpp +++ b/src/plugins/intel_gpu/tests/functional/single_layer_tests/dynamic/roi_pooling.cpp @@ -148,12 +148,9 @@ class ROIPoolingLayerGPUTest : public testing::WithParamInterface(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode); - break; - } - case ngraph::element::bf16: { - ov::test::utils::fill_data_roi(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode); + case ov::element::f32: + case ov::element::bf16: { + ov::test::utils::fill_data_roi(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode); break; } default: diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/cum_sum.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/cum_sum.hpp new file mode 100644 index 00000000000000..0d7c57a9341eef --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/cum_sum.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/cum_sum.hpp" + +namespace ov { +namespace test { +TEST_P(CumSumLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/deformable_psroi_pooling.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/deformable_psroi_pooling.hpp new file mode 100644 index 00000000000000..65063df0f5e545 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/deformable_psroi_pooling.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/deformable_psroi_pooling.hpp" + +namespace ov { +namespace test { +TEST_P(DeformablePSROIPoolingLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/depth_to_space.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/depth_to_space.hpp new file mode 100644 index 00000000000000..a7f0552d6028a6 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/depth_to_space.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/depth_to_space.hpp" + +namespace ov { +namespace test { +TEST_P(DepthToSpaceLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/cum_sum.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/cum_sum.hpp new file mode 100644 index 00000000000000..035bff4de8c67e --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/cum_sum.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { + +typedef std::tuple< + std::vector, // Input shapes + ov::element::Type, // Model type + int64_t, // Axis + bool, // Exclusive + bool, // Reverse + std::string> cumSumParams; // Device name + +class CumSumLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/deformable_psroi_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/deformable_psroi_pooling.hpp new file mode 100644 index 00000000000000..b3cc9ea739a779 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/deformable_psroi_pooling.hpp @@ -0,0 +1,39 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using deformablePSROISpecificParams = std::tuple< + int64_t, // output_dim + int64_t, // group_size + float, // spatial_scale + std::vector, // spatial_bins_x_y + float, // trans_std + int64_t>; // part_size + +using deformablePSROILayerTestParams = std::tuple< + deformablePSROISpecificParams, + std::vector, // data input shape + ov::element::Type, // Net type + std::string>; // Device name + +class DeformablePSROIPoolingLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/depth_to_space.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/depth_to_space.hpp new file mode 100644 index 00000000000000..40a7632aaa5098 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/depth_to_space.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "openvino/op/depth_to_space.hpp" + +namespace ov { +namespace test { +using depthToSpaceParamsTuple = typename std::tuple< + std::vector, // Input shape + ov::element::Type, // Model type + ov::op::v0::DepthToSpace::DepthToSpaceMode, // Mode + std::size_t, // Block size + std::string>; // Device name> + +class DepthToSpaceLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); + +protected: + void SetUp() override; +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp index e738e73d879d6e..139678a602fd21 100644 --- a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp +++ b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp @@ -855,6 +855,28 @@ ov::runtime::Tensor generate(const std::shared_ptr& nod return generate(std::dynamic_pointer_cast(node), port, elemType, targetShape); } +ov::runtime::Tensor generate(const + std::shared_ptr& node, + size_t port, + const ov::element::Type& elemType, + const ov::Shape& targetShape) { + if (port == 1) { + ov::Tensor tensor(elemType, targetShape); + auto data_input_shape = node->input(0).get_shape(); + const auto batch_distrib = data_input_shape[0] - 1; + const auto height = data_input_shape[2] / node->get_spatial_scale(); + const auto width = data_input_shape[3] / node->get_spatial_scale(); + + ov::test::utils::fill_data_roi(tensor, batch_distrib, height, width, 1.0f, true); + return tensor; + } else if (port == 2) { + ov::Tensor tensor(elemType, targetShape); + ov::test::utils::fill_tensor_random(tensor, 1.8, -0.9); + return tensor; + } + return generate(std::static_pointer_cast(node), port, elemType, targetShape); +} + ov::runtime::Tensor generate(const std::shared_ptr& node, size_t port, diff --git a/src/tests/functional/shared_test_classes/src/single_op/cum_sum.cpp b/src/tests/functional/shared_test_classes/src/single_op/cum_sum.cpp new file mode 100644 index 00000000000000..7adccf0aaff1aa --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/cum_sum.cpp @@ -0,0 +1,54 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/cum_sum.hpp" + +namespace ov { +namespace test { +std::string CumSumLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + ov::element::Type model_type; + int64_t axis; + bool exclusive, reverse; + std::string targetDevice; + std::tie(shapes, model_type, axis, exclusive, reverse, targetDevice) = obj.param; + + std::ostringstream result; + result << "IS=("; + for (size_t i = 0lu; i < shapes.size(); i++) { + result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : ""); + } + result << ")_TS="; + for (size_t i = 0lu; i < shapes.front().second.size(); i++) { + result << "{"; + for (size_t j = 0lu; j < shapes.size(); j++) { + result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : ""); + } + result << "}_"; + } + result << "Precision=" << model_type.get_type_name() << "_"; + result << "Axis=" << axis << "_"; + result << "Exclusive=" << (exclusive ? "TRUE" : "FALSE") << "_"; + result << "Reverse=" << (reverse ? "TRUE" : "FALSE") << "_"; + result << "TargetDevice=" << targetDevice; + return result.str(); +} + +void CumSumLayerTest::SetUp() { + std::vector shapes; + ov::element::Type model_type; + bool exclusive, reverse; + int64_t axis; + std::tie(shapes, model_type, axis, exclusive, reverse, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + const auto param = std::make_shared(model_type, inputDynamicShapes.front()); + const auto axis_node = std::make_shared(ov::element::Type_t::i64, ov::Shape{}, std::vector{axis}); + const auto cum_sum = std::make_shared(param, axis_node, exclusive, reverse); + + auto result = std::make_shared(cum_sum); + function = std::make_shared(result, ov::ParameterVector{param}, "cumsum"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/deformable_psroi_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_op/deformable_psroi_pooling.cpp new file mode 100644 index 00000000000000..42722c8d4dad01 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/deformable_psroi_pooling.cpp @@ -0,0 +1,110 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/deformable_psroi_pooling.hpp" + +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/deformable_psroi_pooling.hpp" + +namespace ov { +namespace test { + +std::string DeformablePSROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + ov::element::Type model_type; + int64_t outputDim; + int64_t groupSize; + float spatialScale; + std::vector spatialBinsXY; + float trans_std; + int64_t part_size; + std::string target_device; + deformablePSROISpecificParams opParams; + + std::tie(opParams, shapes, model_type, target_device) = obj.param; + std::tie(outputDim, groupSize, spatialScale, spatialBinsXY, + trans_std, part_size) = opParams; + + std::ostringstream result; + result << "IS=("; + for (size_t i = 0lu; i < shapes.size(); i++) { + result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : ""); + } + result << ")_TS="; + for (size_t i = 0lu; i < shapes.front().second.size(); i++) { + result << "{"; + for (size_t j = 0lu; j < shapes.size(); j++) { + result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : ""); + } + result << "}_"; + } + result << "out_dim=" << outputDim << "_"; + result << "group_size=" << groupSize << "_"; + result << "scale=" << spatialScale << "_"; + result << "bins_x=" << spatialBinsXY[0] << "_"; + result << "bins_y=" << spatialBinsXY[1] << "_"; + result << "trans_std=" << trans_std << "_"; + result << "part_size=" << part_size << "_"; + result << "prec=" << model_type.get_type_name() << "_"; + result << "dev=" << target_device; + return result.str(); +} + +void DeformablePSROIPoolingLayerTest::SetUp() { + std::vector shapes; + ov::element::Type model_type; + int64_t outputDim; + int64_t groupSize; + std::string mode = "bilinear_deformable"; + std::vector spatialBinsXY; + float trans_std, spatial_scale; + int64_t part_size; + deformablePSROISpecificParams opParams; + + std::tie(opParams, shapes, model_type, targetDevice) = this->GetParam(); + std::tie(outputDim, groupSize, spatial_scale, spatialBinsXY, trans_std, part_size) = opParams; + init_input_shapes(shapes); + + ov::ParameterVector params; + std::shared_ptr defomablePSROIPooling; + + if (2 == inputDynamicShapes.size()) { // Test without optional third input (offsets) + params = ov::ParameterVector{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1])}; + + defomablePSROIPooling = std::make_shared(params[0], + params[1], + outputDim, + spatial_scale, + groupSize, + mode, + spatialBinsXY[0], + spatialBinsXY[1], + trans_std, + part_size); + } else { + params = ov::ParameterVector{std::make_shared(model_type, inputDynamicShapes[0]), + std::make_shared(model_type, inputDynamicShapes[1]), + std::make_shared(model_type, inputDynamicShapes[2])}; + + defomablePSROIPooling = std::make_shared(params[0], + params[1], + params[2], + outputDim, + spatial_scale, + groupSize, + mode, + spatialBinsXY[0], + spatialBinsXY[1], + trans_std, + part_size); + } + + auto result = std::make_shared(defomablePSROIPooling); + function = std::make_shared(result, params, "deformable_psroi_pooling"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/depth_to_space.cpp b/src/tests/functional/shared_test_classes/src/single_op/depth_to_space.cpp new file mode 100644 index 00000000000000..d4f45a617a8747 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/depth_to_space.cpp @@ -0,0 +1,72 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/depth_to_space.hpp" + +#include "openvino/op/parameter.hpp" +#include "openvino/op/constant.hpp" +#include "openvino/op/result.hpp" +#include "openvino/op/depth_to_space.hpp" + +namespace ov { +namespace test { +using ov::op::v0::DepthToSpace; + +static inline std::string DepthToSpaceModeToString(const DepthToSpace::DepthToSpaceMode& mode) { + static std::map names = { + {DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, "BLOCKS_FIRST"}, + {DepthToSpace::DepthToSpaceMode::DEPTH_FIRST, "DEPTH_FIRST"}, + }; + + auto i = names.find(mode); + if (i != names.end()) + return i->second; + else + throw std::runtime_error("Unsupported DepthToSpaceMode"); +} + +std::string DepthToSpaceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { + std::vector shapes; + DepthToSpace::DepthToSpaceMode mode; + std::size_t block_size; + ov::element::Type model_type; + std::string device_name; + std::tie(shapes, model_type, mode, block_size, device_name) = obj.param; + + std::ostringstream result; + result << "IS=("; + for (size_t i = 0lu; i < shapes.size(); i++) { + result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : ""); + } + result << ")_TS="; + for (size_t i = 0lu; i < shapes.front().second.size(); i++) { + result << "{"; + for (size_t j = 0lu; j < shapes.size(); j++) { + result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : ""); + } + result << "}_"; + } + result << "inPrc=" << model_type.get_type_name() << "_"; + result << "M=" << DepthToSpaceModeToString(mode) << "_"; + result << "BS=" << block_size << "_"; + result << "targetDevice=" << device_name << "_"; + return result.str(); +} + +void DepthToSpaceLayerTest::SetUp() { + std::vector shapes; + DepthToSpace::DepthToSpaceMode mode; + std::size_t block_size; + ov::element::Type model_type; + std::tie(shapes, model_type, mode, block_size, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + auto param = std::make_shared(model_type, inputDynamicShapes.front()); + auto d2s = std::make_shared(param, mode, block_size); + auto result = std::make_shared(d2s); + + function = std::make_shared(result, ov::ParameterVector{param}, "DepthToSpace"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp index 55994c7f6b90ae..4d2e5006eeb72d 100644 --- a/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp +++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/data_utils.hpp @@ -158,52 +158,14 @@ inline void fill_data_roi(InferenceEngine::Blob::Ptr& blob, fill_roi_raw_ptr(data, blob->size(), range, height, width, omega, is_roi_max_mode, seed); } -template -inline void fill_data_roi(ov::runtime::Tensor& tensor, - const uint32_t range, - const int height, - const int width, - const float omega, - const bool is_roi_max_mode, - const int seed = 1) { - using T = typename InferenceEngine::PrecisionTrait::value_type; - auto* data = static_cast(tensor.data()); - std::default_random_engine random(seed); - std::uniform_int_distribution distribution(0, range); +void fill_data_roi(ov::runtime::Tensor& tensor, + const uint32_t range, + const int height, + const int width, + const float omega, + const bool is_roi_max_mode, + const int seed = 1); - const int max_y = (is_roi_max_mode) ? (height - 1) : 1; - const int max_x = (is_roi_max_mode) ? (width - 1) : 1; - - float center_h = (max_y) / 2.0f; - float center_w = (max_x) / 2.0f; - - for (size_t i = 0; i < tensor.get_size(); i += 5) { - data[i] = static_cast(distribution(random)); - const float x0 = (center_w + width * 0.3f * sin(static_cast(i + 1) * omega)); - const float x1 = (center_w + width * 0.3f * sin(static_cast(i + 3) * omega)); - data[i + 1] = static_cast(is_roi_max_mode ? std::floor(x0) : x0); - data[i + 3] = static_cast(is_roi_max_mode ? std::floor(x1) : x1); - if (data[i + 3] < data[i + 1]) { - std::swap(data[i + 1], data[i + 3]); - } - if (data[i + 1] < 0) - data[i + 1] = 0; - if (data[i + 3] > max_x) - data[i + 3] = static_cast(max_x); - - const float y0 = (center_h + height * 0.3f * sin(static_cast(i + 2) * omega)); - const float y1 = (center_h + height * 0.3f * sin(static_cast(i + 4) * omega)); - data[i + 2] = static_cast(is_roi_max_mode ? std::floor(y0) : y0); - data[i + 4] = static_cast(is_roi_max_mode ? std::floor(y1) : y1); - if (data[i + 4] < data[i + 2]) { - std::swap(data[i + 2], data[i + 4]); - } - if (data[i + 2] < 0) - data[i + 2] = 0; - if (data[i + 4] > max_y) - data[i + 4] = static_cast(max_y); - } -} OPENVINO_SUPPRESS_DEPRECATED_END template diff --git a/src/tests/test_utils/common_test_utils/src/data_utils.cpp b/src/tests/test_utils/common_test_utils/src/data_utils.cpp index 9991b976b467f6..ed956e7f860fd4 100644 --- a/src/tests/test_utils/common_test_utils/src/data_utils.cpp +++ b/src/tests/test_utils/common_test_utils/src/data_utils.cpp @@ -250,6 +250,88 @@ size_t byte_size(const InferenceEngine::TensorDesc& tdesc) { } OPENVINO_SUPPRESS_DEPRECATED_END +template +inline void fill_data_roi_impl(ov::runtime::Tensor& tensor, + const uint32_t range, + const int height, + const int width, + const float omega, + const bool is_roi_max_mode, + const int seed = 1) { + using T = typename ov::fundamental_type_for; + auto* data = static_cast(tensor.data()); + std::default_random_engine random(seed); + std::uniform_int_distribution distribution(0, range); + + const int max_y = (is_roi_max_mode) ? (height - 1) : 1; + const int max_x = (is_roi_max_mode) ? (width - 1) : 1; + + float center_h = (max_y) / 2.0f; + float center_w = (max_x) / 2.0f; + + for (size_t i = 0; i < tensor.get_size(); i += 5) { + data[i] = static_cast(distribution(random)); + const float x0 = (center_w + width * 0.3f * sin(static_cast(i + 1) * omega)); + const float x1 = (center_w + width * 0.3f * sin(static_cast(i + 3) * omega)); + data[i + 1] = static_cast(is_roi_max_mode ? std::floor(x0) : x0); + data[i + 3] = static_cast(is_roi_max_mode ? std::floor(x1) : x1); + if (data[i + 3] < data[i + 1]) { + std::swap(data[i + 1], data[i + 3]); + } + if (data[i + 1] < 0) + data[i + 1] = 0; + if (data[i + 3] > max_x) + data[i + 3] = static_cast(max_x); + + const float y0 = (center_h + height * 0.3f * sin(static_cast(i + 2) * omega)); + const float y1 = (center_h + height * 0.3f * sin(static_cast(i + 4) * omega)); + data[i + 2] = static_cast(is_roi_max_mode ? std::floor(y0) : y0); + data[i + 4] = static_cast(is_roi_max_mode ? std::floor(y1) : y1); + if (data[i + 4] < data[i + 2]) { + std::swap(data[i + 2], data[i + 4]); + } + if (data[i + 2] < 0) + data[i + 2] = 0; + if (data[i + 4] > max_y) + data[i + 4] = static_cast(max_y); + } +} + +void fill_data_roi(ov::runtime::Tensor& tensor, + const uint32_t range, + const int height, + const int width, + const float omega, + const bool is_roi_max_mode, + const int seed) { +#define CASE(X) \ + case X: \ + fill_data_roi_impl(tensor, range, height, width, omega, is_roi_max_mode, seed); \ + break; + + auto element_type = tensor.get_element_type(); + switch (element_type) { + CASE(ov::element::f64) + CASE(ov::element::f32) + CASE(ov::element::f16) + CASE(ov::element::bf16) + CASE(ov::element::u1) + CASE(ov::element::u4) + CASE(ov::element::u8) + CASE(ov::element::u32) + CASE(ov::element::u16) + CASE(ov::element::u64) + CASE(ov::element::i4) + CASE(ov::element::i8) + CASE(ov::element::i16) + CASE(ov::element::i32) + CASE(ov::element::i64) + default: + OPENVINO_THROW("Wrong precision specified: ", element_type); + } +#undef CASE +} + void fill_data_with_broadcast(ov::Tensor& tensor, ov::Tensor& values) { constexpr size_t MAX_N_DIMS = 7; // Suppose it's enough