[CPU] Disable ConvertNMSToNMSIEInternal (#16128)

This commit is contained in:
cecilia peng authored and GitHub committed 2023-03-27 11:22:53 +04:00
1 parent 64e9dc32cd
commit a1b8a6a941
17 files changed
+77 -103

No files matched your search

+12 -13
View File
@@ -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<BlockedMemoryDesc>(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<BlockedMemoryDesc>(outMemDesc), BLOCKED_DESC_FULL_MASK);
}
}
}
@@ -3,6 +3,7 @@
//
#include "matrix_nms.h"
#include "ov_ops/nms_static_shape_ie.hpp"
#include <algorithm>
#include <chrono>
@@ -57,6 +58,9 @@ MatrixNms::MatrixNms(const std::shared_ptr<ngraph::Node>& op, const GraphContext
m_errorPrefix = "MatrixNMS layer with name '" + getName() + "' ";
if (one_of(op->get_type_info(), ov::op::internal::NmsStaticShapeIE<ngraph::op::v8::MatrixNms>::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;
@@ -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} {}
@@ -50,6 +50,9 @@ MultiClassNms::MultiClassNms(const std::shared_ptr<ov::Node>& 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;
@@ -65,6 +65,8 @@ private:
float m_nmsEta = 0.0f;
bool m_normalized = true;
bool m_outStaticShape = false;
std::string m_errorPrefix;
std::vector<std::vector<size_t>> m_numFiltBox; // number of rois after nms for each class in each image
@@ -554,7 +554,6 @@ private:
bool NonMaxSuppression::isSupportedOperation(const std::shared_ptr<const ngraph::Node>& 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<ngraph::Node>& 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<ngraph::Node>& op, co
if (const auto nms9 = std::dynamic_pointer_cast<const ngraph::op::v9::NonMaxSuppression>(op)) {
boxEncodingType = static_cast<NMSBoxEncodeType>(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<const ov::op::internal::NonMaxSuppressionIEInternal>(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);
}
@@ -136,6 +136,8 @@ private:
// control placeholder for NMS in new opset.
bool isSoftSuppressedByIOU = false;
bool m_outStaticShape = false;
std::string errorPrefix;
std::vector<std::vector<size_t>> numFiltBox;
@@ -358,23 +358,14 @@ void Transformations::PreLpt(const std::vector<ov::element::Type>& 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<ov::pass::ConvertNMS9ToNMSIEInternal>(nmsCallback);
pass_config->set_callback<ov::pass::ConvertMulticlassNmsToMulticlassNmsIE>(nmsCallback);
pass_config->set_callback<ov::pass::ConvertMatrixNmsToMatrixNmsIE>(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<ov::pass::ConvertNMS9ToNMSIEInternal>(nmsCallback);
pass_config->set_callback<ov::pass::ConvertMulticlassNmsToMulticlassNmsIE>(nmsCallback);
pass_config->set_callback<ov::pass::ConvertMatrixNmsToMatrixNmsIE>(nmsCallback);
// List of enabled/disabled transformations
@@ -48,6 +48,8 @@ const std::vector<bool> normalized = {true, false};
const std::vector<op::v8::MatrixNms::DecayFunction> decayFunction = {op::v8::MatrixNms::DecayFunction::GAUSSIAN,
op::v8::MatrixNms::DecayFunction::LINEAR};
const std::vector<bool> 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)
);
@@ -88,6 +88,8 @@ const std::vector<bool> sortResDesc = {true, false};
const std::vector<float> nmsEta = {0.6f, 1.0f};
const std::vector<bool> normalized = {true, false};
const std::vector<bool> 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);
@@ -157,10 +157,7 @@ std::vector<std::string> 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).*)",
@@ -30,6 +30,8 @@ const std::vector<bool> normalized = {true, false};
const std::vector<op::v8::MatrixNms::DecayFunction> decayFunction = {op::v8::MatrixNms::DecayFunction::GAUSSIAN,
op::v8::MatrixNms::DecayFunction::LINEAR};
const std::vector<bool> 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,
@@ -41,6 +41,8 @@ const std::vector<bool> sortResDesc = {true, false};
const std::vector<float> nmsEta = {0.6f, 1.0f};
const std::vector<bool> normalized = {true, false};
const std::vector<bool> 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));
@@ -36,6 +36,7 @@ using NmsParams = std::tuple<std::vector<InputShape>,
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<NmsParams>,
@@ -38,6 +38,7 @@ using MulticlassNmsParams = std::tuple<std::vector<InputShape>,
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<MulticlassNmsParams>,
@@ -27,9 +27,10 @@ std::string MatrixNmsLayerTest::getTestCaseName(const testing::TestParamInfo<Nms
TopKParams topKParams;
ThresholdParams thresholdParams;
bool normalized;
bool outStaticShape;
std::string targetDevice;
std::tie(shapes, inPrecisions, sortResultType, outType, topKParams, thresholdParams,
backgroudClass, normalized, decayFunction, targetDevice) = obj.param;
backgroudClass, normalized, decayFunction, outStaticShape, targetDevice) = obj.param;
ElementType paramsPrec, maxBoxPrec, thrPrec;
std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions;
@@ -57,7 +58,7 @@ std::string MatrixNmsLayerTest::getTestCaseName(const testing::TestParamInfo<Nms
result << "outType=" << outType << "_nmsTopK=" << nmsTopK << "_keepTopK=" << keepTopK << "_";
result << "backgroudClass=" << backgroudClass << "_decayFunction=" << decayFunction << "_";
result << "score_threshold=" << score_threshold << "_gaussian_sigma=" << gaussian_sigma << "_";
result << "post_threshold=" << post_threshold << "_TargetDevice=" << targetDevice;
result << "post_threshold=" << post_threshold << "_outStaticShape=" << outStaticShape <<"_TargetDevice=" << targetDevice;
return result.str();
}
@@ -305,20 +306,13 @@ void MatrixNmsLayerTest::SetUp() {
ThresholdParams thresholdParams;
std::tie(shapes, inPrecisions, m_attrs.sort_result_type, m_attrs.output_type, topKParams, thresholdParams,
m_attrs.background_class, m_attrs.normalized, m_attrs.decay_function, targetDevice) = this->GetParam();
m_attrs.background_class, m_attrs.normalized, m_attrs.decay_function, m_outStaticShape, targetDevice) = this->GetParam();
std::tie(m_attrs.nms_top_k, m_attrs.keep_top_k) = topKParams;
std::tie(m_attrs.score_threshold, m_attrs.gaussian_sigma, m_attrs.post_threshold) = thresholdParams;
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, maxBoxPrec, thrPrec;
std::tie(paramsPrec, maxBoxPrec, thrPrec) = inPrecisions;
const auto params = ngraph::builder::makeDynamicParams(paramsPrec, inputDynamicShapes);
@@ -326,22 +320,7 @@ void MatrixNmsLayerTest::SetUp() {
ngraph::helpers::convert2OutputVector(ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params));
auto nms = std::make_shared<opset8::MatrixNms>(paramOuts[0], paramOuts[1], m_attrs);
if (targetDevice == CommonTestUtils::DEVICE_GPU) {
function = std::make_shared<Function>(nms, params, "MatrixNMS");
} else if (!m_outStaticShape) {
auto result = std::make_shared<opset5::Result>(nms);
function = std::make_shared<Function>(result, params, "MatrixNMS");
} else {
auto nms_0_identity = std::make_shared<opset5::Multiply>(nms->output(0), opset5::Constant::create(element::f32, Shape{1}, {1}));
auto nms_1_identity = std::make_shared<opset5::Multiply>(nms->output(1), opset5::Constant::create(m_attrs.output_type, Shape{1}, {1}));
auto nms_2_identity = std::make_shared<opset5::Multiply>(nms->output(2), opset5::Constant::create(m_attrs.output_type, Shape{1}, {1}));
OutputVector results = {
std::make_shared<opset5::Result>(nms_0_identity),
std::make_shared<opset5::Result>(nms_1_identity),
std::make_shared<opset5::Result>(nms_2_identity)
};
function = std::make_shared<Function>(results, params, "MatrixNMS");
}
function = std::make_shared<Function>(nms, params, "MatrixNMS");
}
} // namespace subgraph
@@ -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<Function>(nms, params, "MulticlassNMS");
} else if (!m_outStaticShape) {
OutputVector results = {
std::make_shared<opset5::Result>(nms->output(0)),
std::make_shared<opset5::Result>(nms->output(1)),
std::make_shared<opset5::Result>(nms->output(2))
};
function = std::make_shared<Function>(results, params, "MulticlassNMS");
} else {
auto nms_0_identity = std::make_shared<opset5::Multiply>(nms->output(0), opset5::Constant::create(paramsPrec, Shape {1}, {1}));
auto nms_1_identity = std::make_shared<opset5::Multiply>(nms->output(1), opset5::Constant::create(outType, Shape {1}, {1}));
auto nms_2_identity = std::make_shared<opset5::Multiply>(nms->output(2), opset5::Constant::create(outType, Shape {1}, {1}));
OutputVector results = {
std::make_shared<opset5::Result>(nms_0_identity),
std::make_shared<opset5::Result>(nms_1_identity),
std::make_shared<opset5::Result>(nms_2_identity)
};
function = std::make_shared<Function>(results, params, "MulticlassNMS");
}
function = std::make_shared<Function>(nms, params, "MulticlassNMS");
}
} // namespace subgraph