diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/invalid_cases/proposal.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/invalid_cases/proposal.cpp index 8e81454e929a20..dbb6dac26440de 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/invalid_cases/proposal.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/invalid_cases/proposal.cpp @@ -2,25 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include "single_layer_tests/invalid_cases/proposal.hpp" -using namespace ngraph::helpers; -using namespace LayerTestsDefinitions; -using namespace BehaviorTestsDefinitions; +#include namespace { +using ov::test::ProposalBehTest; /* ============= 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}; const std::vector> img_info_invalid = {{0.f, 225.f, 1.f}, {225.f, -1.f, 1.f}, {225.f, NAN, 1.f}, @@ -29,27 +27,24 @@ const std::vector> img_info_invalid = {{0.f, 225.f, 1.f}, {225.f, 100.f, INFINITY}}; // empty string corresponds to Caffe 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_) -); - -INSTANTIATE_TEST_SUITE_P(invalid, ProposalBehTest, - ::testing::Combine( - proposalParams, - ::testing::ValuesIn(img_info_invalid), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ProposalBehTest::getTestCaseName -); +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_)); + +INSTANTIATE_TEST_SUITE_P(invalid, + ProposalBehTest, + ::testing::Combine(proposalParams, + ::testing::ValuesIn(img_info_invalid), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ProposalBehTest::getTestCaseName); } // namespace diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/invalid_cases/proposal.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/invalid_cases/proposal.hpp index 282d09f6d51dcc..6495fc2feab8c5 100644 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/invalid_cases/proposal.hpp +++ b/src/tests/functional/plugin/shared/include/single_layer_tests/invalid_cases/proposal.hpp @@ -4,31 +4,21 @@ #pragma once -#include "shared_test_classes/single_layer/proposal.hpp" +#include "shared_test_classes/single_op/proposal.hpp" -namespace BehaviorTestsDefinitions { +namespace ov { +namespace test { +typedef std::tuple, std::string> proposalBehTestParamsSet; -typedef std::tuple< - LayerTestsDefinitions::proposalSpecificParams, - std::vector, - std::string> proposalBehTestParamsSet; - -class ProposalBehTest - : public testing::WithParamInterface, - virtual public LayerTestsUtils::LayerTestsCommon { +class ProposalBehTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { public: static std::string getTestCaseName(testing::TestParamInfo obj); - InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; protected: void SetUp() override; - void Validate() override {}; - void Run() override; - - const LayerTestsDefinitions::normalize_type normalize = true; - const LayerTestsDefinitions::feat_stride_type feat_stride = 1; - const LayerTestsDefinitions::box_size_scale_type box_size_scale = 2.0f; - const LayerTestsDefinitions::box_coordinate_scale_type box_coordinate_scale = 2.0f; + void run() override; }; -} // namespace BehaviorTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/src/single_layer_tests/invalid_cases/proposal.cpp b/src/tests/functional/plugin/shared/src/single_layer_tests/invalid_cases/proposal.cpp index dff6e17d3efd58..d3924f5480965a 100644 --- a/src/tests/functional/plugin/shared/src/single_layer_tests/invalid_cases/proposal.cpp +++ b/src/tests/functional/plugin/shared/src/single_layer_tests/invalid_cases/proposal.cpp @@ -4,34 +4,52 @@ #include "single_layer_tests/invalid_cases/proposal.hpp" -using namespace BehaviorTestsDefinitions; -using namespace LayerTestsDefinitions; +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 ProposalBehTest::getTestCaseName(testing::TestParamInfo obj) { - proposalSpecificParams proposalParams; - std::string targetDevice; + proposalSpecificParams proposal_params; + std::string target_device; std::vector img_info; - std::tie(proposalParams, img_info, targetDevice) = obj.param; - auto proposalPramString = ProposalLayerTest::SerializeProposalSpecificParams(proposalParams); - - std::ostringstream result; - result << "targetDevice=" << targetDevice; - result << "img_info = " << ov::test::utils::vec2str(img_info) << "_"; + std::tie(proposal_params, img_info, target_device) = obj.param; - return proposalPramString + result.str(); -} + 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; -InferenceEngine::Blob::Ptr ProposalBehTest::GenerateInput(const InferenceEngine::InputInfo &info) const { - InferenceEngine::Blob::Ptr blobPtr; - - const std::string name = info.name(); - if (name == "scores") { - blobPtr = FuncTestUtils::createAndFillBlobFloat(info.getTensorDesc(), 1, 0, 1000, 8234231); - } else if (name == "boxes") { - blobPtr = FuncTestUtils::createAndFillBlobFloatNormalDistribution(info.getTensorDesc(), 0.0f, 0.2f, 7235346); - } + 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; - return blobPtr; + 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 << "targetDevice=" << target_device; + result << "img_info = " << ov::test::utils::vec2str(img_info) << "_"; + result << "framework=" << framework << "_"; + return result.str(); } void ProposalBehTest::SetUp() { @@ -39,18 +57,15 @@ void ProposalBehTest::SetUp() { std::vector img_info; std::tie(proposalParams, img_info, targetDevice) = this->GetParam(); - base_size_type base_size; - pre_nms_topn_type pre_nms_topn; - post_nms_topn_type post_nms_topn; - nms_thresh_type nms_thresh; - min_size_type min_size; - ratio_type ratio; - scale_type scale; - clip_before_nms_type clip_before_nms; - clip_after_nms_type clip_after_nms; - framework_type framework; - - std::tie(base_size, pre_nms_topn, + + 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, @@ -64,15 +79,11 @@ void ProposalBehTest::SetUp() { size_t bottom_h = base_size; size_t num_anchors = ratio.size() * scale.size(); - std::vector scoresShape = {1, 2 * num_anchors, bottom_h, bottom_w}; - std::vector boxesShape = {1, 4 * num_anchors, bottom_h, bottom_w}; - std::vector imageInfoShape = {3}; + ov::Shape scores_shape = {1, 2 * num_anchors, bottom_h, bottom_w}; + ov::Shape boxes_shape = {1, 4 * num_anchors, bottom_h, bottom_w}; - auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(InferenceEngine::Precision::FP16); - ov::ParameterVector params{std::make_shared(ngPrc, ov::Shape(scoresShape)), - std::make_shared(ngPrc, ov::Shape(boxesShape))}; - params[0]->set_friendly_name("scores"); - params[1]->set_friendly_name("boxes"); + ov::ParameterVector params{std::make_shared(ov::element::f16, scores_shape), + std::make_shared(ov::element::f16, boxes_shape)}; ov::op::v0::Proposal::Attributes attrs; attrs.base_size = base_size; @@ -95,18 +106,24 @@ void ProposalBehTest::SetUp() { auto proposal = std::make_shared(params[0], params[1], image_shape, attrs); - ngraph::ResultVector results{std::make_shared(proposal)}; - function = std::make_shared(results, params, "proposal"); + ov::ResultVector results{std::make_shared(proposal)}; + function = std::make_shared(results, params, "proposal"); } - -void ProposalBehTest::Run() { - LoadNetwork(); - GenerateInputs(); - Infer(); +void ProposalBehTest::run() { + std::vector input_shapes; + for (const auto& param : function->get_parameters()) + input_shapes.emplace_back(param->get_shape()); + init_input_shapes(ov::test::static_shapes_to_test_representation(input_shapes)); + + compile_model(); + for (const auto& targetStaticShapeVec : targetStaticShapes) { + generate_inputs(targetStaticShapeVec); + validate(); + } } -TEST_P(ProposalBehTest, CompareWithRefs) { - SKIP_IF_CURRENT_TEST_IS_DISABLED() - - ASSERT_THROW(Run(), InferenceEngine::Exception); +TEST_P(ProposalBehTest, Inference) { + ASSERT_THROW(run(), ov::Exception); } +} // 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 index edb4ec08a6d771..bbfa09747f31cd 100644 --- 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 @@ -4,39 +4,35 @@ #pragma once -#include +#include #include +#include #include -#include -#include "shared_test_classes/base/ov_subgraph.hpp" #include "common_test_utils/test_enums.hpp" +#include "shared_test_classes/base/ov_subgraph.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 ->; +using proposalSpecificParams = std::tuple, // ratio + std::vector, // scale + bool, // clip_before_nms + bool, // clip_after_nms + std::string // framework + >; +using proposalLayerTestParamsSet = std::tuple; class ProposalLayerTest : public testing::WithParamInterface, - virtual public ov::test::SubgraphBaseStaticTest { + virtual public ov::test::SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo& obj); + protected: void SetUp() override; };