diff --git a/src/plugins/intel_cpu/src/node.cpp b/src/plugins/intel_cpu/src/node.cpp index 72b77f4215b..f80ed309383 100644 --- a/src/plugins/intel_cpu/src/node.cpp +++ b/src/plugins/intel_cpu/src/node.cpp @@ -1043,28 +1043,27 @@ void Node::initOptimalPrimitiveDescriptor() { IE_THROW() << "Preferable primitive descriptor is not set."; auto config = selected_pd->getConfig(); - if (isDynamicNode()) { - // it is assumed that the nodes will define dense tensors on output edges - // if it is not the case the implementation must redefine this behaviour - for (size_t i = 0; i < config.outConfs.size(); i++) { - auto outMemDesc = config.outConfs[i].getMemDesc(); - if (outMemDesc && (outMemDesc->getType() & Blocked)) { - config.outConfs[i].setMemDesc(std::dynamic_pointer_cast(outMemDesc), BLOCKED_DESC_FULL_MASK); - } - } - } else { - for (size_t i = 0; i < config.inConfs.size(); i++) { + for (size_t i = 0; i < config.inConfs.size(); i++) { + if (!isDynamicNode() || config.inConfs[i].getMemDesc()->isDefined()) { auto inpPortDesc = getConsistentInputDesc(config, i); DEBUG_LOG(getName(), ": input PortDesc before: ", *inpPortDesc->getMemDesc()); config.inConfs[i].setMemDesc(inpPortDesc->getMemDesc()); DEBUG_LOG(getName(), ": input PortDesc after: ", *config.inConfs[i].getMemDesc()); } + } - for (size_t i = 0; i < config.outConfs.size(); i++) { + for (size_t i = 0; i < config.outConfs.size(); i++) { + auto outMemDesc = config.outConfs[i].getMemDesc(); + if (!isDynamicNode() || outMemDesc->isDefined()) { auto outPortDesc = getConsistentOutputDesc(config, i); DEBUG_LOG(getName(), ": output PortDesc before: ", *outPortDesc->getMemDesc()); config.outConfs[i].setMemDesc(outPortDesc->getMemDesc()); - DEBUG_LOG(getName(), ": output PortDesc after: ", *config.outConfs[i].getMemDesc()); + } else { + // it is assumed that the nodes will define dense tensors on output edges + // if it is not the case the implementation must redefine this behaviour + if (outMemDesc->getType() & Blocked) { + config.outConfs[i].setMemDesc(std::dynamic_pointer_cast(outMemDesc), BLOCKED_DESC_FULL_MASK); + } } } diff --git a/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp b/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp index 29dce9760ac..fe825800f34 100644 --- a/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/matrix_nms.cpp @@ -3,6 +3,7 @@ // #include "matrix_nms.h" +#include "ov_ops/nms_static_shape_ie.hpp" #include #include @@ -57,6 +58,9 @@ MatrixNms::MatrixNms(const std::shared_ptr& op, const GraphContext m_errorPrefix = "MatrixNMS layer with name '" + getName() + "' "; + if (one_of(op->get_type_info(), ov::op::internal::NmsStaticShapeIE::get_type_info_static())) + m_outStaticShape = true; + if (getOriginalInputsNumber() != 2) IE_THROW() << m_errorPrefix << "has incorrect number of input edges: " << getOriginalInputsNumber(); @@ -370,7 +374,8 @@ void MatrixNms::execute(dnnl::stream strm) { auto selectedIndicesMemPtr = getChildEdgesAtPort(NMS_SELECTED_INDICES)[0]->getMemoryPtr(); auto validOutputsMemPtr = getChildEdgesAtPort(NMS_VALID_OUTPUTS)[0]->getMemoryPtr(); - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS + // NMS-alike nodes are always transformed to NMSIEInternal node in case of legacy api, for compatibility. + // And on the other hand in case of api 2.0, keep them internal dynamic for better performance and functionality. if (isDynamicNode()) { size_t totalBox = std::accumulate(m_numPerBatch.begin(), m_numPerBatch.end(), size_t(0)); redefineOutputMemory({{totalBox, 6}, {totalBox, 1}, {m_numBatches}}); @@ -396,8 +401,8 @@ void MatrixNms::execute(dnnl::stream strm) { selectedBase[4] = m_filteredBoxes[originalIndex].box.x2; selectedBase[5] = m_filteredBoxes[originalIndex].box.y2; } - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS - if (!isDynamicNode()) { + + if (m_outStaticShape) { std::fill_n(selectedOutputs + (outputOffset + real_boxes) * 6, (m_maxBoxesPerBatch - real_boxes) * 6, -1.f); std::fill_n(selectedIndices + (outputOffset + real_boxes), m_maxBoxesPerBatch - real_boxes, -1); outputOffset += m_maxBoxesPerBatch; diff --git a/src/plugins/intel_cpu/src/nodes/matrix_nms.h b/src/plugins/intel_cpu/src/nodes/matrix_nms.h index 58b9c9aa94f..bcb0bcac6eb 100644 --- a/src/plugins/intel_cpu/src/nodes/matrix_nms.h +++ b/src/plugins/intel_cpu/src/nodes/matrix_nms.h @@ -66,6 +66,8 @@ private: float m_postThreshold; bool m_normalized; + bool m_outStaticShape = false; + struct Rectangle { Rectangle(float x_left, float y_left, float x_right, float y_right) : x1 {x_left}, y1 {y_left}, x2 {x_right}, y2 {y_right} {} diff --git a/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp b/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp index 54c95b2114c..805740ca4ed 100644 --- a/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp +++ b/src/plugins/intel_cpu/src/nodes/multiclass_nms.cpp @@ -50,6 +50,9 @@ MultiClassNms::MultiClassNms(const std::shared_ptr& op, const GraphCon } m_errorPrefix = "MultiClassNms layer with name '" + getName() + "' "; + if (one_of(op->get_type_info(), ov::op::internal::MulticlassNmsIEInternal::get_type_info_static())) + m_outStaticShape = true; + if (getOriginalInputsNumber() != 2 && getOriginalInputsNumber() != 3) IE_THROW() << m_errorPrefix << "has incorrect number of input edges: " << getOriginalInputsNumber(); @@ -321,8 +324,7 @@ void MultiClassNms::execute(dnnl::stream strm) { m_selected_num[m_filtBoxes[idx].batch_index]++; } - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS - if (isDynamicNode()) { + if (!m_outStaticShape) { size_t totalBox = std::accumulate(m_selected_num.begin(), m_selected_num.end(), size_t(0)); redefineOutputMemory({{totalBox, 6}, {totalBox, 1}, {m_numBatches}}); } @@ -371,8 +373,8 @@ void MultiClassNms::execute(dnnl::stream strm) { selected_base[5] = curboxes[4 * box_info.box_index + 3]; } } - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS - if (!isDynamicNode()) { + + if (m_outStaticShape) { std::fill_n(selected_outputs + (output_offset + real_boxes) * 6, (selectedBoxesNum_perBatch - real_boxes) * 6, -1.f); std::fill_n(selected_indices + (output_offset + real_boxes), selectedBoxesNum_perBatch - real_boxes, -1); output_offset += selectedBoxesNum_perBatch; diff --git a/src/plugins/intel_cpu/src/nodes/multiclass_nms.hpp b/src/plugins/intel_cpu/src/nodes/multiclass_nms.hpp index e044204537c..6383cf29986 100644 --- a/src/plugins/intel_cpu/src/nodes/multiclass_nms.hpp +++ b/src/plugins/intel_cpu/src/nodes/multiclass_nms.hpp @@ -65,6 +65,8 @@ private: float m_nmsEta = 0.0f; bool m_normalized = true; + bool m_outStaticShape = false; + std::string m_errorPrefix; std::vector> m_numFiltBox; // number of rois after nms for each class in each image diff --git a/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp b/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp index 67400590ce4..48fbea67c15 100644 --- a/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp +++ b/src/plugins/intel_cpu/src/nodes/non_max_suppression.cpp @@ -554,7 +554,6 @@ private: bool NonMaxSuppression::isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { try { - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS using NonMaxSuppressionV9 = ngraph::op::v9::NonMaxSuppression; if (!one_of(op->get_type_info(), NonMaxSuppressionV9::get_type_info_static(), ov::op::internal::NonMaxSuppressionIEInternal::get_type_info_static())) { @@ -584,6 +583,8 @@ NonMaxSuppression::NonMaxSuppression(const std::shared_ptr& op, co } errorPrefix = "NMS layer with name '" + op->get_friendly_name() + "' "; + if (one_of(op->get_type_info(), ov::op::internal::NonMaxSuppressionIEInternal::get_type_info_static())) + m_outStaticShape = true; if (getOriginalInputsNumber() < 2 || getOriginalInputsNumber() > 6) IE_THROW() << errorPrefix << "has incorrect number of input edges: " << getOriginalInputsNumber(); @@ -594,7 +595,6 @@ NonMaxSuppression::NonMaxSuppression(const std::shared_ptr& op, co if (const auto nms9 = std::dynamic_pointer_cast(op)) { boxEncodingType = static_cast(nms9->get_box_encoding()); sortResultDescending = nms9->get_sort_result_descending(); - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS } else if (const auto nmsIe = std::dynamic_pointer_cast(op)) { boxEncodingType = nmsIe->m_center_point_box ? NMSBoxEncodeType::CENTER : NMSBoxEncodeType::CORNER; sortResultDescending = nmsIe->m_sort_result_descending; @@ -795,8 +795,7 @@ void NonMaxSuppression::execute(dnnl::stream strm) { auto scoresMemPtr = getChildEdgesAtPort(NMS_SELECTEDSCORES)[0]->getMemoryPtr(); const size_t validOutputs = std::min(filtBoxes.size(), maxNumberOfBoxes); - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS - if (isDynamicNode()) { + if (!m_outStaticShape) { VectorDims newDims{validOutputs, 3}; redefineOutputMemory({newDims, newDims, {1}}); } @@ -819,8 +818,7 @@ void NonMaxSuppression::execute(dnnl::stream strm) { selectedScoresPtr += selectedIndicesStride; } - // TODO [DS NMS]: remove when nodes from models where nms is not last node in model supports DS - if (!isDynamicNode()) { + if (m_outStaticShape) { std::fill(selectedIndicesPtr, selectedIndicesPtr + (maxNumberOfBoxes - idx) * selectedIndicesStride, -1); std::fill(selectedScoresPtr, selectedScoresPtr + (maxNumberOfBoxes - idx) * selectedIndicesStride, -1.f); } diff --git a/src/plugins/intel_cpu/src/nodes/non_max_suppression.h b/src/plugins/intel_cpu/src/nodes/non_max_suppression.h index 031196d9d37..a0666f66b63 100644 --- a/src/plugins/intel_cpu/src/nodes/non_max_suppression.h +++ b/src/plugins/intel_cpu/src/nodes/non_max_suppression.h @@ -136,6 +136,8 @@ private: // control placeholder for NMS in new opset. bool isSoftSuppressedByIOU = false; + bool m_outStaticShape = false; + std::string errorPrefix; std::vector> numFiltBox; diff --git a/src/plugins/intel_cpu/src/transformation_pipeline.cpp b/src/plugins/intel_cpu/src/transformation_pipeline.cpp index 582248ab472..174a10cd6d0 100644 --- a/src/plugins/intel_cpu/src/transformation_pipeline.cpp +++ b/src/plugins/intel_cpu/src/transformation_pipeline.cpp @@ -358,23 +358,14 @@ void Transformations::PreLpt(const std::vector& defaultPrecis return node->input_value(0).get_partial_shape().rank().get_length() <= 5; }); - if (!isLegacyApi) { - auto nmsCallback = [](const_node_ptr &node) -> bool { - for (size_t i = 0; i < node->get_output_size(); i++) { - const auto outputs = node->get_output_target_inputs(i); - for (const auto &out : outputs) { - if (!ov::op::util::is_output(out.get_node())) { - return false; - } - } - } - return true; - }; - - pass_config->set_callback(nmsCallback); - pass_config->set_callback(nmsCallback); - pass_config->set_callback(nmsCallback); - } + // NMS-alike nodes are always transformed to NMSIEInternal node in case of legacy api, for compatibility. + // And on the other hand in case of api 2.0, keep them internal dynamic for better performance and functionality. + auto nmsCallback = [isLegacyApi](const_node_ptr &node) -> bool { + return isLegacyApi ? false : true; + }; + pass_config->set_callback(nmsCallback); + pass_config->set_callback(nmsCallback); + pass_config->set_callback(nmsCallback); // List of enabled/disabled transformations diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp index 7530d6a08f9..c4c42cf5b6d 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/matrix_nms.cpp @@ -48,6 +48,8 @@ const std::vector normalized = {true, false}; const std::vector decayFunction = {op::v8::MatrixNms::DecayFunction::GAUSSIAN, op::v8::MatrixNms::DecayFunction::LINEAR}; +const std::vector outStaticShape = {false}; // always be false for cpu plugin with ov2.0. + const auto nmsParamsStatic = ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inStaticShapeParams)), ::testing::Combine(::testing::Values(ov::element::f32), ::testing::Values(ov::element::i32), @@ -59,6 +61,7 @@ const auto nmsParamsStatic = ::testing::Combine(::testing::ValuesIn(ov::test::st ::testing::ValuesIn(backgroudClass), ::testing::ValuesIn(normalized), ::testing::ValuesIn(decayFunction), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_CPU) ); @@ -73,6 +76,7 @@ const auto nmsParamsDynamic = ::testing::Combine(::testing::ValuesIn(inDynamicSh ::testing::ValuesIn(backgroudClass), ::testing::ValuesIn(normalized), ::testing::ValuesIn(decayFunction), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_CPU) ); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp index af65e2ca2d2..6956d33e79f 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/multiclass_nms.cpp @@ -88,6 +88,8 @@ const std::vector sortResDesc = {true, false}; const std::vector nmsEta = {0.6f, 1.0f}; const std::vector normalized = {true, false}; +const std::vector outStaticShape = {false}; // only be false for cpu plugin with ov2.0. + const auto nmsParamsStatic_smoke1 = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inStaticShapeParams1)), ::testing::Combine(::testing::Values(ov::element::f32), @@ -101,6 +103,7 @@ const auto nmsParamsStatic_smoke1 = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)); const auto nmsParamsDynamic_smoke1 = ::testing::Combine( @@ -116,6 +119,7 @@ const auto nmsParamsDynamic_smoke1 = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P(smoke_MulticlassNmsLayerTest_static1, MulticlassNmsLayerTest, nmsParamsStatic_smoke1, MulticlassNmsLayerTest::getTestCaseName); @@ -134,6 +138,7 @@ const auto nmsParamsStatic_smoke2 = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)); const auto nmsParamsDynamic_smoke2 = ::testing::Combine( @@ -149,6 +154,7 @@ const auto nmsParamsDynamic_smoke2 = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P(smoke_MulticlassNmsLayerTest_static2, MulticlassNmsLayerTest, nmsParamsStatic_smoke2, MulticlassNmsLayerTest::getTestCaseName); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 3b1aaa55cd1..acbd2310908 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -157,10 +157,7 @@ std::vector disabledTestPatterns() { R"(.*CompileModelCacheTestBase.*CompareWithRefImpl.*Nms.*)", // Issue: 76980 R"(.*smoke_Auto_BehaviorTests.*InferDynamicNetwork/.*)", - // enable after other plugins support nms9 as setup with nms5 in - // tests/functional/shared_test_classes/include/shared_test_classes/single_layer/non_max_suppression.hpp - // is shared across plugins - // passed local test and cpu has specific test cases with nms9 to cover + // Issue: 105838 R"(smoke_NmsLayerTest.*)", // Issue: 95590 R"(.*CachingSupportCase.*CompileModelCacheTestBase.*(TIwithLSTMcell1|MatMulBias|2InputSubtract)_(u|i).*)", diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/matrix_nms.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/matrix_nms.cpp index edecb942091..b1a606a248c 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/matrix_nms.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/matrix_nms.cpp @@ -30,6 +30,8 @@ const std::vector normalized = {true, false}; const std::vector decayFunction = {op::v8::MatrixNms::DecayFunction::GAUSSIAN, op::v8::MatrixNms::DecayFunction::LINEAR}; +const std::vector outStaticShape = {true}; // only be true as gpu plugin not support nms with internal dynamic yet. + const auto nmsParamsStatic = ::testing::Combine(::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inStaticShapeParams)), ::testing::Values(inputPrecisions), @@ -40,6 +42,7 @@ const auto nmsParamsStatic = ::testing::ValuesIn(backgroudClass), ::testing::ValuesIn(normalized), ::testing::ValuesIn(decayFunction), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_MatrixNmsLayerTest_static, diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/multiclass_nms.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/multiclass_nms.cpp index a7cff946b1f..63de2b7dc00 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/multiclass_nms.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/single_layer_tests/multiclass_nms.cpp @@ -41,6 +41,8 @@ const std::vector sortResDesc = {true, false}; const std::vector nmsEta = {0.6f, 1.0f}; const std::vector normalized = {true, false}; +const std::vector outStaticShape = {true}; // only be true as gpu plugin not support nms with internal dynamic yet. + const auto params_v9_2Inputs = ::testing::Combine( ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes2Inputs)), ::testing::Combine(::testing::Values(ov::element::f32), @@ -54,6 +56,7 @@ const auto params_v9_2Inputs = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)); @@ -75,6 +78,7 @@ const auto params_v9_3Inputs = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)); INSTANTIATE_TEST_SUITE_P(smoke_MulticlassNmsLayerTest_v9_3inputs, @@ -95,6 +99,7 @@ const auto params_v8 = ::testing::Combine( ::testing::ValuesIn(outType), ::testing::ValuesIn(sortResultType), ::testing::Combine(::testing::ValuesIn(sortResDesc), ::testing::ValuesIn(normalized)), + ::testing::ValuesIn(outStaticShape), ::testing::Values(CommonTestUtils::DEVICE_GPU)); diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp index e525a716246..03e68e4a2c0 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/matrix_nms.hpp @@ -36,6 +36,7 @@ using NmsParams = std::tuple, int, // Background class id bool, // If boxes are normalized ngraph::op::v8::MatrixNms::DecayFunction, // Decay function + bool, // make output shape static std::string>; // Device name class MatrixNmsLayerTest : public testing::WithParamInterface, diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp index 516d9490fcf..a425db3ced0 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/multiclass_nms.hpp @@ -38,6 +38,7 @@ using MulticlassNmsParams = std::tuple, ngraph::element::Type, // Output type ngraph::op::util::MulticlassNmsBase::SortResultType, // SortResultType InputboolVar, // Sort result across batch, normalized + bool, // make output shape static std::string>; class MulticlassNmsLayerTest : public testing::WithParamInterface, diff --git a/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp b/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp index 9c7498662e9..995574a7263 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/matrix_nms.cpp @@ -27,9 +27,10 @@ std::string MatrixNmsLayerTest::getTestCaseName(const testing::TestParamInfo(nms); - function = std::make_shared(result, params, "MatrixNMS"); - } else { - auto nms_0_identity = std::make_shared(nms->output(0), opset5::Constant::create(element::f32, Shape{1}, {1})); - auto nms_1_identity = std::make_shared(nms->output(1), opset5::Constant::create(m_attrs.output_type, Shape{1}, {1})); - auto nms_2_identity = std::make_shared(nms->output(2), opset5::Constant::create(m_attrs.output_type, Shape{1}, {1})); - OutputVector results = { - std::make_shared(nms_0_identity), - std::make_shared(nms_1_identity), - std::make_shared(nms_2_identity) - }; - function = std::make_shared(results, params, "MatrixNMS"); - } + function = std::make_shared(nms, params, "MatrixNMS"); } } // namespace subgraph diff --git a/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp b/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp index 16fa42c1a4d..82aba72a0bf 100644 --- a/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp +++ b/src/tests/functional/shared_test_classes/src/single_layer/multiclass_nms.cpp @@ -28,9 +28,11 @@ std::string MulticlassNmsLayerTest::getTestCaseName(const testing::TestParamInfo InputfloatVar inFloatVar; InputboolVar inboolVar; + bool outputStatic; + std::string targetDevice; - std::tie(shapes, inPrecisions, nmsTopK, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, targetDevice) = obj.param; + std::tie(shapes, inPrecisions, nmsTopK, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, outputStatic, targetDevice) = obj.param; ElementType paramsPrec, roisnumPrec, maxBoxPrec, thrPrec; std::tie(paramsPrec, roisnumPrec, maxBoxPrec, thrPrec) = inPrecisions; @@ -58,6 +60,7 @@ std::string MulticlassNmsLayerTest::getTestCaseName(const testing::TestParamInfo result << "iouThr=" << iouThr << "_scoreThr=" << scoreThr << "_backgroundClass=" << backgroundClass << "_"; result << "keepTopK=" << keepTopK << "_outType=" << outType << "_"; result << "sortResultType=" << sortResultType << "_sortResCrossBatch=" << sortResCB << "_nmsEta=" << nmsEta << "_normalized=" << normalized << "_"; + result << "outputStatic=" << outputStatic; result << "TargetDevice=" << targetDevice; return result.str(); } @@ -348,18 +351,11 @@ void MulticlassNmsLayerTest::SetUp() { InputfloatVar inFloatVar; InputboolVar inboolVar; - std::tie(shapes, inPrecisions, maxOutBoxesPerClass, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, targetDevice) = - this->GetParam(); + std::tie(shapes, inPrecisions, maxOutBoxesPerClass, inFloatVar, backgroundClass, keepTopK, outType, sortResultType, inboolVar, + m_outStaticShape, targetDevice) = this->GetParam(); init_input_shapes(shapes); - // input is dynamic shape -> output will be dynamic shape - // input is static shape -> output will be static shape - const auto inputDynamicParam = {shapes[0].first, shapes[1].first}; - m_outStaticShape = std::any_of(inputDynamicParam.begin(), inputDynamicParam.end(), [](const ov::PartialShape& shape) { - return shape.rank() == 0; - }); - ElementType paramsPrec, roisnumPrec, maxBoxPrec, thrPrec; std::tie(paramsPrec, roisnumPrec, maxBoxPrec, thrPrec) = inPrecisions; @@ -391,26 +387,7 @@ void MulticlassNmsLayerTest::SetUp() { const auto nms = CreateNmsOp(paramOuts); - if (targetDevice == CommonTestUtils::DEVICE_GPU) { - function = std::make_shared(nms, params, "MulticlassNMS"); - } else if (!m_outStaticShape) { - OutputVector results = { - std::make_shared(nms->output(0)), - std::make_shared(nms->output(1)), - std::make_shared(nms->output(2)) - }; - function = std::make_shared(results, params, "MulticlassNMS"); - } else { - auto nms_0_identity = std::make_shared(nms->output(0), opset5::Constant::create(paramsPrec, Shape {1}, {1})); - auto nms_1_identity = std::make_shared(nms->output(1), opset5::Constant::create(outType, Shape {1}, {1})); - auto nms_2_identity = std::make_shared(nms->output(2), opset5::Constant::create(outType, Shape {1}, {1})); - OutputVector results = { - std::make_shared(nms_0_identity), - std::make_shared(nms_1_identity), - std::make_shared(nms_2_identity) - }; - function = std::make_shared(results, params, "MulticlassNMS"); - } + function = std::make_shared(nms, params, "MulticlassNMS"); } } // namespace subgraph