From 22bd6ff0494dfa7a33d7db068186b1e21a2f0783 Mon Sep 17 00:00:00 2001 From: Andrei Gorbachev Date: Fri, 15 Mar 2024 11:46:26 +0000 Subject: [PATCH] [GPU] Refactor (#23472) ### Details: - *experimental_detectron_prior_grid_generator* ### Tickets: - *CSV-131562* --- ...imental_detectron_prior_grid_generator.cpp | 71 ++++------- ...imental_detectron_prior_grid_generator.hpp | 19 --- ...imental_detectron_prior_grid_generator.hpp | 37 ------ ...imental_detectron_prior_grid_generator.cpp | 111 ------------------ 4 files changed, 20 insertions(+), 218 deletions(-) delete mode 100644 src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp delete mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp delete mode 100644 src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp index b181d2f0c97..42184673eea 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/experimental_detectron_prior_grid_generator.cpp @@ -2,73 +2,42 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include +#include "single_op_tests/experimental_detectron_prior_grid_generator.hpp" namespace { +using ov::test::ExperimentalDetectronPriorGridGeneratorLayerTest; -const std::initializer_list params{ - // flatten = true (output tensor is 2D) - {{true, 0, 0, 4.0f, 4.0f}, - ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 4, 5}, {1, 3, 100, 200}})}, +std::vector> shapes = { + ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 4, 5}, {1, 3, 100, 200}}), + ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 3, 7}, {1, 3, 100, 200}}), // task #72587 - //{ - // {true, 3, 6, 64.0f, 64.0f}, // ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 100, 100}, {1, 3, 100, 200}}) - //}, - //// flatten = false (output tensor is 4D) - {{false, 0, 0, 8.0f, 8.0f}, - ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 3, 7}, {1, 3, 100, 200}})}, - // task #72587 - //{ - // {false, 5, 3, 32.0f, 32.0f}, // ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 100, 100}, {1, 3, 100, 200}}) - //}, }; -template -std::vector>> getInputTensors() { - std::vector>> tensors{ - {"test#1", - {ov::test::utils::create_tensor( - ov::element::from(), - {3, 4}, - std::vector{-24.5, -12.5, 24.5, 12.5, -16.5, -16.5, 16.5, 16.5, -12.5, -24.5, 12.5, 24.5})}}, - {"test#2", - {ov::test::utils::create_tensor( - ov::element::from(), - {3, 4}, - std::vector{-44.5, -24.5, 44.5, 24.5, -32.5, -32.5, 32.5, 32.5, -24.5, -44.5, 24.5, 44.5})}}, - {"test#3", - {ov::test::utils::create_tensor( - ov::element::from(), - {3, 4}, - std:: - vector{-364.5, -184.5, 364.5, 184.5, -256.5, -256.5, 256.5, 256.5, -180.5, -360.5, 180.5, 360.5})}}, - {"test#4", - {ov::test::utils::create_tensor( - ov::element::from(), - {3, 4}, - std::vector{-180.5, -88.5, 180.5, 88.5, -128.5, -128.5, 128.5, 128.5, -92.5, -184.5, 92.5, 184.5})}}}; - return tensors; -} - -using ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorLayerTest; +std::vector attributes = { + // flatten = true (output tensor is 2D) + {true, 0, 0, 4.0f, 4.0f}, + // flatten = false (output tensor is 4D) + {false, 0, 0, 8.0f, 8.0f}, + // task #72587 + // {true, 3, 6, 64.0f, 64.0f}, + // {false, 5, 3, 32.0f, 32.0f}, +}; INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f32, ExperimentalDetectronPriorGridGeneratorLayerTest, - testing::Combine(testing::ValuesIn(params), - testing::ValuesIn(getInputTensors()), - testing::ValuesIn({ov::element::Type_t::f32}), + testing::Combine(testing::ValuesIn(shapes), + testing::ValuesIn(attributes), + testing::Values(ov::element::f32), testing::Values(ov::test::utils::DEVICE_GPU)), ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f16, ExperimentalDetectronPriorGridGeneratorLayerTest, - testing::Combine(testing::ValuesIn(params), - testing::ValuesIn(getInputTensors()), - testing::ValuesIn({ov::element::Type_t::f16}), + testing::Combine(testing::ValuesIn(shapes), + testing::ValuesIn(attributes), + testing::Values(ov::element::f16), testing::Values(ov::test::utils::DEVICE_GPU)), ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName); } // namespace \ No newline at end of file diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp deleted file mode 100644 index 1c76687bb29..00000000000 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/experimental_detectron_prior_grid_generator.hpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include - -namespace ov { -namespace test { -namespace subgraph { - -TEST_P(ExperimentalDetectronPriorGridGeneratorLayerTest, ExperimentalDetectronPriorGridGeneratorLayerTests) { - run(); -} - -} // namespace subgraph -} // namespace test -} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp deleted file mode 100644 index d4c9e2e4b48..00000000000 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "common_test_utils/common_utils.hpp" -#include "shared_test_classes/base/ov_subgraph.hpp" - -namespace ov { -namespace test { -namespace subgraph { - -class ExperimentalDetectronPriorGridGeneratorTestParam { -public: - ov::op::v6::ExperimentalDetectronPriorGridGenerator::Attributes attributes; - std::vector inputShapes; -}; - -typedef std::tuple< - ExperimentalDetectronPriorGridGeneratorTestParam, - std::pair>, - ElementType, // Network precision - std::string // Device name>; -> ExperimentalDetectronPriorGridGeneratorTestParams; - -class ExperimentalDetectronPriorGridGeneratorLayerTest : - public testing::WithParamInterface, - virtual public SubgraphBaseTest { -protected: - void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; - -public: - static std::string getTestCaseName(const testing::TestParamInfo& obj); -}; -} // namespace subgraph -} // namespace test -} // namespace ov \ No newline at end of file diff --git a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp b/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp deleted file mode 100644 index c6761893701..00000000000 --- a/src/tests/functional/shared_test_classes/src/single_layer/experimental_detectron_prior_grid_generator.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2018-2024 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include "shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp" -#include "common_test_utils/data_utils.hpp" -#include - -namespace ov { -namespace test { -namespace subgraph { - -namespace { -std::ostream& operator <<( - std::ostream& ss, - const ov::op::v6::ExperimentalDetectronPriorGridGenerator::Attributes& attributes) { - ss << "flatten=" << attributes.flatten << "_"; - ss << "h=" << attributes.h << "_"; - ss << "w=" << attributes.w << "_"; - ss << "stride_x=" << attributes.stride_x << "_"; - ss << "stride_y=" << attributes.stride_y; - return ss; -} -} // namespace - -std::string ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName( - const testing::TestParamInfo& obj) { - ExperimentalDetectronPriorGridGeneratorTestParam param; - std::pair> inputTensors; - ElementType netPrecision; - std::string targetName; - std::tie(param, inputTensors, netPrecision, targetName) = obj.param; - - std::ostringstream result; - using ov::test::operator<<; - result << "priors=" << param.inputShapes[0] << "_"; - result << "feature_map=" << param.inputShapes[1] << "_"; - result << "im_data=" << param.inputShapes[2] << "_"; - - using ov::test::subgraph::operator<<; - result << "attributes=" << param.attributes << "_"; - result << "priorValues=" << inputTensors.first << "_"; - result << "netPRC=" << netPrecision << "_"; - result << "trgDev=" << targetName; - return result.str(); -} - -void ExperimentalDetectronPriorGridGeneratorLayerTest::SetUp() { - ExperimentalDetectronPriorGridGeneratorTestParam param; - std::pair> inputTensors; - ElementType netPrecision; - std::string targetName; - std::tie(param, inputTensors, netPrecision, targetName) = this->GetParam(); - - inType = outType = netPrecision; - targetDevice = targetName; - - init_input_shapes(param.inputShapes); - - ov::ParameterVector params; - for (auto&& shape : inputDynamicShapes) - params.push_back(std::make_shared(netPrecision, shape)); - - auto experimentalDetectron = std::make_shared( - params[0], // priors - params[1], // feature_map - params[2], // im_data - param.attributes); - function = std::make_shared( - ov::OutputVector{experimentalDetectron->output(0)}, - "ExperimentalDetectronPriorGridGenerator"); -} - -namespace { -template -ov::Tensor generateTensorByShape(const Shape &shape) { - return ov::test::utils::create_tensor( - ov::element::from(), - shape, - std::vector(0., shape_size(shape))); -} -} - -void ExperimentalDetectronPriorGridGeneratorLayerTest::generate_inputs(const std::vector& targetInputStaticShapes) { - auto inputTensors = std::get<1>(GetParam()); - auto netPrecision = std::get<2>(GetParam()); - - inputs.clear(); - const auto& funcInputs = function->inputs(); - - auto i = 0ul; - for (; i < inputTensors.second.size(); ++i) { - if (targetInputStaticShapes[i] != inputTensors.second[i].get_shape()) { - OPENVINO_THROW("input shape is different from tensor shape"); - } - - inputs.insert({funcInputs[i].get_node_shared_ptr(), inputTensors.second[i]}); - } - for (auto j = i; j < funcInputs.size(); ++j) { - ov::Tensor inputTensor = (netPrecision == element::f16) - ? generateTensorByShape(targetInputStaticShapes[j]) - : generateTensorByShape( - targetInputStaticShapes[j]); - - inputs.insert({funcInputs[j].get_node_shared_ptr(), inputTensor}); - } -} - -} // namespace subgraph -} // namespace test -} // namespace ov \ No newline at end of file