diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp index 3fdabf89c5d..e9cbb9ce682 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/proposal.cpp @@ -4,44 +4,44 @@ #include -#include "single_layer_tests/proposal.hpp" +#include "single_op_tests/proposal.hpp" #include "common_test_utils/test_constants.hpp" -using namespace ngraph::helpers; -using namespace LayerTestsDefinitions; +using ov::test::ProposalLayerTest; namespace { /* ============= Proposal ============= */ -const std::vector base_size_ = {16}; -const std::vector pre_nms_topn_ = {100}; -const std::vector post_nms_topn_ = {100}; -const std::vector nms_thresh_ = {0.7f}; -const std::vector min_size_ = {1}; -const std::vector ratio_ = {{1.0f, 2.0f}}; -const std::vector scale_ = {{1.2f, 1.5f}}; -const std::vector clip_before_nms_ = {false}; -const std::vector clip_after_nms_ = {false}; +const std::vector base_size = {16}; +const std::vector pre_nms_topn = {100}; +const std::vector post_nms_topn = {100}; +const std::vector nms_thresh = {0.7f}; +const std::vector min_size = {1}; +const std::vector> ratio = {{1.0f, 2.0f}}; +const std::vector> scale = {{1.2f, 1.5f}}; +const std::vector clip_before_nms = {false}; +const std::vector clip_after_nms = {false}; // empty string corresponds to Caffe framework -const std::vector framework_ = {""}; +const std::vector framework = {""}; -const auto proposalParams = ::testing::Combine( - ::testing::ValuesIn(base_size_), - ::testing::ValuesIn(pre_nms_topn_), - ::testing::ValuesIn(post_nms_topn_), - ::testing::ValuesIn(nms_thresh_), - ::testing::ValuesIn(min_size_), - ::testing::ValuesIn(ratio_), - ::testing::ValuesIn(scale_), - ::testing::ValuesIn(clip_before_nms_), - ::testing::ValuesIn(clip_after_nms_), - ::testing::ValuesIn(framework_) +const auto proposal_params = ::testing::Combine( + ::testing::ValuesIn(base_size), + ::testing::ValuesIn(pre_nms_topn), + ::testing::ValuesIn(post_nms_topn), + ::testing::ValuesIn(nms_thresh), + ::testing::ValuesIn(min_size), + ::testing::ValuesIn(ratio), + ::testing::ValuesIn(scale), + ::testing::ValuesIn(clip_before_nms), + ::testing::ValuesIn(clip_after_nms), + ::testing::ValuesIn(framework) ); -INSTANTIATE_TEST_SUITE_P(smoke_Proposal_tests, ProposalLayerTest, +INSTANTIATE_TEST_SUITE_P(proposal_params, ProposalLayerTest, ::testing::Combine( - proposalParams, + proposal_params, + ::testing::Values(ov::element::f16), ::testing::Values(ov::test::utils::DEVICE_CPU)), ProposalLayerTest::getTestCaseName ); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/psroi_pooling.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/psroi_pooling.cpp index 7e8691b3e4e..8ff9c1e04f5 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/psroi_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/psroi_pooling.cpp @@ -4,23 +4,23 @@ #include -#include "single_layer_tests/psroi_pooling.hpp" +#include "single_op_tests/psroi_pooling.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::PSROIPoolingLayerTest; -std::vector spatialScales = {1, 0.625}; +std::vector spatial_scales = {1, 0.625}; const auto PSROICases_average = ::testing::Combine( ::testing::Values(std::vector{3, 8, 16, 16}), ::testing::Values(std::vector{10, 5}), ::testing::Values(2), ::testing::Values(2), - ::testing::ValuesIn(spatialScales), + ::testing::ValuesIn(spatial_scales), ::testing::Values(1), ::testing::Values(1), ::testing::Values("average"), - ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::Values(ov::test::utils::DEVICE_CPU) ); @@ -32,11 +32,11 @@ const auto PSROICases_bilinear = ::testing::Combine( ::testing::Values(std::vector{10, 5}), ::testing::Values(4), ::testing::Values(3), - ::testing::ValuesIn(spatialScales), + ::testing::ValuesIn(spatial_scales), ::testing::Values(4), ::testing::Values(2), ::testing::Values("bilinear"), - ::testing::Values(InferenceEngine::Precision::FP32), + ::testing::Values(ov::element::f32), ::testing::Values(ov::test::utils::DEVICE_CPU) ); diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/proposal.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/proposal.hpp new file mode 100644 index 00000000000..dbdd9641a13 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/proposal.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/proposal.hpp" + +namespace ov { +namespace test { +TEST_P(ProposalLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/psroi_pooling.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/psroi_pooling.hpp new file mode 100644 index 00000000000..a9b57ad3b96 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/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/psroi_pooling.hpp" + +namespace ov { +namespace test { +TEST_P(PSROIPoolingLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/proposal.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/proposal.hpp new file mode 100644 index 00000000000..edb4ec08a6d --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/proposal.hpp @@ -0,0 +1,44 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { + +using proposalSpecificParams = std::tuple< + size_t, // base_size + size_t, // pre_nms_topn + size_t, // post_nms_topn + float, // nms_thresh + size_t, // min_size + std::vector, // ratio + std::vector, // scale + bool, // clip_before_nms + bool, // clip_after_nms + std::string // framework +>; +using proposalLayerTestParamsSet = std::tuple< + proposalSpecificParams, + ov::element::Type, + ov::test::TargetDevice +>; + +class ProposalLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +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/psroi_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/psroi_pooling.hpp new file mode 100644 index 00000000000..401748acb61 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/psroi_pooling.hpp @@ -0,0 +1,43 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "ov_models/builders.hpp" +#include "ov_models/utils/ov_helpers.hpp" + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { + +using psroiParams = std::tuple< + std::vector, // Input shape + std::vector, // Coords shape + size_t, // Output_dim + size_t, // group_size + float, // Spatial scale + size_t, // spatial_bins_x + size_t, // spatial_bins_y + std::string, // Mode + ov::element::Type, // Model type + ov::test::TargetDevice // Device name +>; + +class PSROIPoolingLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +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/single_op/proposal.cpp b/src/tests/functional/shared_test_classes/src/single_op/proposal.cpp new file mode 100644 index 00000000000..1889d22d630 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/proposal.cpp @@ -0,0 +1,139 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/proposal.hpp" + +namespace ov { +namespace test { + +const bool normalize = true; +const size_t feat_stride = 1; +const float box_size_scale = 2.0f; +const float box_coordinate_scale = 2.0f; + +// std::string ProposalLayerTest::SerializeProposalSpecificParams(proposalSpecificParams& params) { +// size_t base_size; +// size_t pre_nms_topn; +// size_t post_nms_topn; +// float nms_thresh; +// size_t min_size; +// std::vector ratio; +// std::vector scale; +// bool clip_before_nms; +// bool clip_after_nms; +// std::string framework; +// std::tie(base_size, pre_nms_topn, +// post_nms_topn, +// nms_thresh, +// min_size, +// ratio, +// scale, +// clip_before_nms, +// clip_after_nms, +// framework) = params; + +// std::ostringstream result; +// result << "base_size=" << base_size << "_"; +// result << "pre_nms_topn=" << pre_nms_topn << "_"; +// result << "post_nms_topn=" << post_nms_topn << "_"; +// result << "nms_thresh=" << nms_thresh << "_"; +// result << "feat_stride=" << feat_stride << "_"; +// result << "min_size=" << min_size << "_"; +// result << "ratio = " << ov::test::utils::vec2str(ratio) << "_"; +// result << "scale = " << ov::test::utils::vec2str(scale) << "_"; +// result << "clip_before_nms=" << clip_before_nms << "_"; +// result << "clip_after_nms=" << clip_after_nms << "_"; +// result << "normalize=" << normalize << "_"; +// result << "box_size_scale=" << box_size_scale << "_"; +// result << "box_coordinate_scale=" << box_coordinate_scale << "_"; +// result << "framework=" << framework << "_"; + +// return result.str(); +// } + +std::string ProposalLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + proposalSpecificParams proposal_params; + ov::element::Type model_type; + std::string target_device; + std::tie(proposal_params, model_type, target_device) = obj.param; + size_t base_size, pre_nms_topn, post_nms_topn, min_size; + float nms_thresh; + std::vector ratio, scale; + bool clip_before_nms, clip_after_nms; + std::string framework; + + std::tie(base_size, pre_nms_topn, post_nms_topn, + nms_thresh, min_size, ratio, scale, + clip_before_nms, clip_after_nms, framework) = proposal_params; + + std::ostringstream result; + result << "base_size=" << base_size << "_"; + result << "pre_nms_topn=" << pre_nms_topn << "_"; + result << "post_nms_topn=" << post_nms_topn << "_"; + result << "nms_thresh=" << nms_thresh << "_"; + result << "feat_stride=" << feat_stride << "_"; + result << "min_size=" << min_size << "_"; + result << "ratio = " << ov::test::utils::vec2str(ratio) << "_"; + result << "scale = " << ov::test::utils::vec2str(scale) << "_"; + result << "clip_before_nms=" << clip_before_nms << "_"; + result << "clip_after_nms=" << clip_after_nms << "_"; + result << "normalize=" << normalize << "_"; + result << "box_size_scale=" << box_size_scale << "_"; + result << "box_coordinate_scale=" << box_coordinate_scale << "_"; + result << "framework=" << framework << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void ProposalLayerTest::SetUp() { + std::vector img_info = {225.0f, 225.0f, 1.0f}; + + proposalSpecificParams proposal_params; + ov::element::Type model_type; + + std::tie(proposal_params, model_type, targetDevice) = this->GetParam(); + size_t base_size, pre_nms_topn, post_nms_topn, min_size; + float nms_thresh; + std::vector ratio, scale; + bool clip_before_nms, clip_after_nms; + std::string framework; + + std::tie(base_size, pre_nms_topn, post_nms_topn, + nms_thresh, min_size, ratio, scale, + clip_before_nms, clip_after_nms, framework) = proposal_params; + + + size_t bottom_w = base_size; + size_t bottom_h = base_size; + size_t num_anchors = ratio.size() * scale.size(); + + ov::Shape scores_shape = {1, 2 * num_anchors, bottom_h, bottom_w}; + ov::Shape boxes_shape = {1, 4 * num_anchors, bottom_h, bottom_w}; + ov::ParameterVector params{std::make_shared(model_type, scores_shape), + std::make_shared(model_type, boxes_shape)}; + + ov::op::v4::Proposal::Attributes attrs; + attrs.base_size = base_size; + attrs.pre_nms_topn = pre_nms_topn; + attrs.post_nms_topn = post_nms_topn; + attrs.nms_thresh = nms_thresh; + attrs.feat_stride = feat_stride; + attrs.min_size = min_size; + attrs.ratio = ratio; + attrs.scale = scale; + attrs.clip_before_nms = clip_before_nms; + attrs.clip_after_nms = clip_after_nms; + attrs.normalize = normalize; + attrs.box_size_scale = box_size_scale; + attrs.box_coordinate_scale = box_coordinate_scale; + attrs.framework = framework; + attrs.infer_probs = true; + + auto image_shape = std::make_shared(ov::element::f32, ov::Shape{3}, img_info); + auto proposal = std::make_shared(params[0], params[1], image_shape, attrs); + function = std::make_shared(proposal->outputs(), params, "proposal"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/psroi_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_op/psroi_pooling.cpp new file mode 100644 index 00000000000..197f875fea8 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/psroi_pooling.cpp @@ -0,0 +1,63 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/psroi_pooling.hpp" + +namespace ov { +namespace test { +std::string PSROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector input_shape; + std::vector coords_shape; + size_t output_dim; + size_t group_size; + float spatial_scale; + size_t spatial_bins_x; + size_t spatial_bins_y; + std::string mode; + ov::element::Type model_type; + std::string target_device; + std::tie(input_shape, coords_shape, output_dim, group_size, spatial_scale, spatial_bins_x, spatial_bins_y, mode, model_type, target_device) = obj.param; + + std::ostringstream result; + + result << "IS=" << ov::test::utils::vec2str(input_shape) << "_"; + result << "coord_shape=" << ov::test::utils::vec2str(coords_shape) << "_"; + result << "out_dim=" << output_dim << "_"; + result << "group_size=" << group_size << "_"; + result << "scale=" << spatial_scale << "_"; + result << "bins_x=" << spatial_bins_x << "_"; + result << "bins_y=" << spatial_bins_y << "_"; + result << "mode=" << mode << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void PSROIPoolingLayerTest::SetUp() { + std::vector input_shape; + std::vector coords_shape; + size_t output_dim; + size_t group_size; + float spatial_scale; + size_t spatial_bins_x; + size_t spatial_bins_y; + std::string mode; + ov::element::Type model_type; + std::tie(input_shape, coords_shape, output_dim, group_size, spatial_scale, + spatial_bins_x, spatial_bins_y, mode, model_type, targetDevice) = this->GetParam(); + + ov::ParameterVector params {std::make_shared(model_type, ov::Shape(input_shape)), + std::make_shared(model_type, ov::Shape(coords_shape))}; + auto psroi_pooling = std::make_shared(params[0], + params[1], + output_dim, + group_size, + spatial_scale, + spatial_bins_x, + spatial_bins_y, + mode); + function = std::make_shared(psroi_pooling->outputs(), params, "psroi_pooling"); +} +} // namespace test +} // namespace ov