From fc8df42e7e1367766e54c91b10a88a335501725c Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Tue, 17 Nov 2020 18:34:05 +0300 Subject: [PATCH] Fix NMS5 dynamism issues (#3137) * Fixed ConvertNMS5ToLegacy conversion pass to resolve dynamism as soon as possible; fixed output precision to avoid troubles during convert_precision pass * Added NMS5ToLegacy conversion for cldnn plugin * Fixed NMS3 copy method * Updated NMS5ToLegacy pass to avoid convert precision issues * Updated nGraph reader and Functional tests * Removing odd CF call * removed xfail for test that is expected to pass * Fixed Convert operations friendly_name * Removed NMS5ToLegacy from opset1_to_legacy conversion * Update NMS5 layer tests * Update NMS5 DSR tests --- .../src/cldnn_engine/cldnn_engine.cpp | 2 + .../src/inference_engine/CMakeLists.txt | 2 + .../cnn_network_ngraph_impl.cpp | 10 ++- .../src/legacy_api/src/ngraph_ops/nms_ie.cpp | 10 ++- .../convert_nms_5_to_legacy.cpp | 24 +++++-- .../convert_opset1_to_legacy.cpp | 1 - .../src/mkldnn_plugin/mkldnn_plugin.cpp | 2 + .../ngraph_reader/ngraph_reader_tests.hpp | 8 +++ .../non_max_suppression_tests.cpp | 18 +++--- .../transformations/convert_nms5_test.cpp | 62 ++++++++++--------- .../dsr_non_max_suppression.cpp | 7 ++- .../non_max_suppression.hpp | 1 - .../non_max_suppression.cpp | 18 ++---- ngraph/python/tests/__init__.py | 24 ------- .../python/tests/test_onnx/test_zoo_models.py | 4 +- 15 files changed, 99 insertions(+), 94 deletions(-) diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.cpp b/inference-engine/src/cldnn_engine/cldnn_engine.cpp index 91f0249d092..39a801254d9 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_engine.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -155,6 +156,7 @@ InferenceEngine::ICNNNetwork::Ptr clDNNEngine::CloneAndTransformNetwork(const In manager.register_pass(); // WA: ConvertPriorBox must be executed before the 1st ConstantFolding pass manager.register_pass(); + manager.register_pass(); manager.register_pass(); manager.register_pass(); manager.register_pass(); diff --git a/inference-engine/src/inference_engine/CMakeLists.txt b/inference-engine/src/inference_engine/CMakeLists.txt index d5170faa5ec..32c53b8ad30 100644 --- a/inference-engine/src/inference_engine/CMakeLists.txt +++ b/inference-engine/src/inference_engine/CMakeLists.txt @@ -14,6 +14,8 @@ file (GLOB LIBRARY_SRC set(LEGACY_SRC_ROOT "${IE_MAIN_SOURCE_DIR}/src/legacy_api/src/") set(LEGACY_LIBRARY_SHARED_SRCS "${LEGACY_SRC_ROOT}/transformations/convert_opset1_to_legacy/convert_one_hot_to_one_hot_ie.cpp" + "${LEGACY_SRC_ROOT}/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.cpp" + "${LEGACY_SRC_ROOT}/ngraph_ops/nms_ie.cpp" "${LEGACY_SRC_ROOT}/ngraph_ops/onehot_ie.cpp") set(IE_STATIC_DEPENDENT_FILES ${CMAKE_CURRENT_SOURCE_DIR}/file_utils.cpp) diff --git a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp index f9ddbe991a9..8a4bc188a0d 100644 --- a/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp +++ b/inference-engine/src/inference_engine/cnn_network_ngraph_impl.cpp @@ -27,6 +27,7 @@ // TODO: remove this pass usage #include +#include #include "ie_ngraph_utils.hpp" #include "exec_graph_info.hpp" @@ -334,11 +335,14 @@ CNNNetworkNGraphImpl::reshape(const std::map>& _ngraph_function->validate_nodes_and_infer_types(); { - auto specialized_ngraph_function = cloneFunction(true); - // Call this transformation because OneHot IE and nGraph have different output precisions + auto specialized_ngraph_function = cloneFunction(false); { - OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetworkNGraphImpl::ConvertOneHot"); + OV_ITT_SCOPED_TASK(itt::domains::IE, "CNNNetworkNGraphImpl::ConvertToLegacy"); ::ngraph::pass::Manager manager; + // resolves dynamism by replacing dynamic operation with static version + manager.register_pass<::ngraph::pass::ConvertNMS5ToLegacyMatcher>(); + manager.register_pass<::ngraph::pass::ConstantFolding>(); + // OneHotToLegacy changes output precision manager.register_pass<::ngraph::pass::ConvertOneHotToOneHotIEMatcher>()->detect_output_type( specialized_ngraph_function); manager.run_passes(specialized_ngraph_function); diff --git a/inference-engine/src/legacy_api/src/ngraph_ops/nms_ie.cpp b/inference-engine/src/legacy_api/src/ngraph_ops/nms_ie.cpp index be26e1c291e..34a65d45e05 100644 --- a/inference-engine/src/legacy_api/src/ngraph_ops/nms_ie.cpp +++ b/inference-engine/src/legacy_api/src/ngraph_ops/nms_ie.cpp @@ -132,10 +132,16 @@ op::NonMaxSuppressionIE3::NonMaxSuppressionIE3(const Output& boxes, } std::shared_ptr op::NonMaxSuppressionIE3::clone_with_new_inputs(const ngraph::OutputVector &new_args) const { - check_new_args_count(this, new_args); - return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), + if (new_args.size() == 6) { + return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), new_args.at(4), new_args.at(5), m_center_point_box, m_sort_result_descending, m_output_type); + } else if (new_args.size() == 5) { + return make_shared(new_args.at(0), new_args.at(1), new_args.at(2), new_args.at(3), + new_args.at(4), m_center_point_box, m_sort_result_descending, + m_output_type); + } + throw ngraph::ngraph_error("Unsupported number of inputs: " + std::to_string(new_args.size())); } bool op::NonMaxSuppressionIE3::visit_attributes(AttributeVisitor& visitor) { diff --git a/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.cpp b/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.cpp index 8ef630e1687..d9dad3b51f0 100644 --- a/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.cpp +++ b/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_nms_5_to_legacy.cpp @@ -84,8 +84,8 @@ ngraph::pass::ConvertNMS5ToLegacyMatcher::ConvertNMS5ToLegacyMatcher() { new_soft_nms_sigma, center_point_box, nms_5->get_sort_result_descending(), - nms_5->get_output_type()); - new_ops.emplace_back(nms_legacy); + element::i32); + new_ops.push_back(nms_legacy); } else { nms_legacy = std::make_shared( new_args.at(0), @@ -95,13 +95,27 @@ ngraph::pass::ConvertNMS5ToLegacyMatcher::ConvertNMS5ToLegacyMatcher() { new_score_threshold, center_point_box, nms_5->get_sort_result_descending(), - nms_5->get_output_type()); - new_ops.emplace_back(nms_legacy); + element::i32); + new_ops.push_back(nms_legacy); + } + + Output output_0 = nms_legacy->output(0); + if (nms_5->output(0).get_element_type() != output_0.get_element_type()) { + output_0 = std::make_shared(output_0, nms_5->output(0).get_element_type()); + output_0.get_node_shared_ptr()->set_friendly_name(nms_5->get_friendly_name() + "/convert.0"); + new_ops.emplace_back(output_0.get_node_shared_ptr()); + } + + Output output_2 = nms_legacy->output(2); + if (nms_5->output(2).get_element_type() != output_2.get_element_type()) { + output_2 = std::make_shared(output_2, nms_5->output(2).get_element_type()); + output_2.get_node_shared_ptr()->set_friendly_name(nms_5->get_friendly_name() + "/convert.2"); + new_ops.emplace_back(output_2.get_node_shared_ptr()); } nms_legacy->set_friendly_name(nms_5->get_friendly_name()); ngraph::copy_runtime_info(nms_5, new_ops); - ngraph::replace_node(nms_5, nms_legacy); + ngraph::replace_node(nms_5, {output_0, nms_legacy->output(1), output_2}); return true; }; diff --git a/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp b/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp index b9995680089..c8775bb5bea 100644 --- a/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp +++ b/inference-engine/src/legacy_api/src/transformations/convert_opset1_to_legacy/convert_opset1_to_legacy.cpp @@ -130,7 +130,6 @@ bool ngraph::pass::ConvertOpSet1ToLegacy::run_on_function(std::shared_ptradd_matcher(); anchor->add_matcher(); anchor->add_matcher(); - anchor->add_matcher(); anchor->add_matcher(); anchor->add_matcher(); anchor->add_matcher(); diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index c7225373b3b..fc1fe7972de 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -100,6 +101,7 @@ static void Transformation(ICNNNetwork::Ptr& clonedNetwork, const Config& conf) manager.register_pass(); // WA: ConvertPriorBox must be executed before the 1st ConstantFolding pass manager.register_pass(); + manager.register_pass(); manager.register_pass(); manager.register_pass(); manager.register_pass(); diff --git a/inference-engine/tests/functional/inference_engine/ngraph_reader/ngraph_reader_tests.hpp b/inference-engine/tests/functional/inference_engine/ngraph_reader/ngraph_reader_tests.hpp index 8e430311a20..801f35eaff9 100644 --- a/inference-engine/tests/functional/inference_engine/ngraph_reader/ngraph_reader_tests.hpp +++ b/inference-engine/tests/functional/inference_engine/ngraph_reader/ngraph_reader_tests.hpp @@ -12,6 +12,8 @@ #include #include +#include +#include #include "common_test_utils/test_common.hpp" #include "common_test_utils/file_utils.hpp" @@ -39,6 +41,12 @@ protected: } auto network = ie.ReadNetwork(modelV10, weights); + auto f = network.getFunction(); + // WA: we have to resolve dynamysm manually to compare resulting function with v7 IR + ngraph::pass::Manager manager; + manager.register_pass(); + manager.run_passes(f); + network = CNNNetwork(f); auto cnnNetwork = ie.ReadNetwork(oldModel, weights); IE_SUPPRESS_DEPRECATED_START diff --git a/inference-engine/tests/functional/inference_engine/ngraph_reader/non_max_suppression_tests.cpp b/inference-engine/tests/functional/inference_engine/ngraph_reader/non_max_suppression_tests.cpp index 27ee3917869..1380bb2196c 100644 --- a/inference-engine/tests/functional/inference_engine/ngraph_reader/non_max_suppression_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/ngraph_reader/non_max_suppression_tests.cpp @@ -72,7 +72,7 @@ TEST_F(NGraphReaderTests, ReadNonMaxSuppression5) { - + 1 @@ -248,8 +248,8 @@ TEST_F(NGraphReaderTests, ReadNonMaxSuppression5) { - - + + 1 @@ -272,7 +272,7 @@ TEST_F(NGraphReaderTests, ReadNonMaxSuppression5) { - + 16000 3 @@ -280,12 +280,12 @@ TEST_F(NGraphReaderTests, ReadNonMaxSuppression5) { 16000 3 - + 1 - + @@ -298,13 +298,13 @@ TEST_F(NGraphReaderTests, ReadNonMaxSuppression5) { - + 16000 3 - + @@ -315,7 +315,7 @@ TEST_F(NGraphReaderTests, ReadNonMaxSuppression5) { - + 1 diff --git a/inference-engine/tests/functional/inference_engine/transformations/convert_nms5_test.cpp b/inference-engine/tests/functional/inference_engine/transformations/convert_nms5_test.cpp index 6ba473952a4..c5f0c2e3c80 100644 --- a/inference-engine/tests/functional/inference_engine/transformations/convert_nms5_test.cpp +++ b/inference-engine/tests/functional/inference_engine/transformations/convert_nms5_test.cpp @@ -30,7 +30,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticSixInputs) { auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); auto soft_nms_sigma = ngraph::opset5::Constant::create(element::f32, Shape{}, {0.25}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold, - soft_nms_sigma, opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + soft_nms_sigma, opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -64,7 +64,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticSixInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - new_soft_nms_sigma, 0, true); + new_soft_nms_sigma, 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -84,7 +84,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticFiveInputs) { auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -114,7 +114,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticFiveInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -133,7 +133,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticFourInputs) { auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -163,7 +163,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticFourInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -181,7 +181,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticThreeInputs) { auto scores = std::make_shared(element::f32, Shape{1, 1, 1000}); auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -211,7 +211,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticThreeInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -228,7 +228,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticTwoInputs) { auto boxes = std::make_shared(element::f32, Shape{1, 1000, 4}); auto scores = std::make_shared(element::f32, Shape{1, 1, 1000}); auto nms = std::make_shared(boxes, scores, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -258,7 +258,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEStaticTwoInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -279,7 +279,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1SixInputs) { auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); auto soft_nms_sigma = ngraph::opset5::Constant::create(element::f32, Shape{}, {0.25}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold, - soft_nms_sigma, opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + soft_nms_sigma, opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -314,7 +314,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1SixInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - new_soft_nms_sigma, 0, true); + new_soft_nms_sigma, 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -333,7 +333,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1FiveInputs) { auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -364,7 +364,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1FiveInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -382,7 +382,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1FourInputs) { auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -413,7 +413,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1FourInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -430,7 +430,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1ThreeInputs) { auto scores = std::make_shared(element::f32, PartialShape::dynamic()); auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -461,7 +461,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1ThreeInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -477,7 +477,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1TwoInputs) { auto boxes = std::make_shared(element::f32, PartialShape::dynamic()); auto scores = std::make_shared(element::f32, PartialShape::dynamic()); auto nms = std::make_shared(boxes, scores, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -508,7 +508,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic1TwoInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -528,7 +528,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2SixInputs) { auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); auto soft_nms_sigma = ngraph::opset5::Constant::create(element::f32, Shape{}, {0.25}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold, - soft_nms_sigma, opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + soft_nms_sigma, opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -562,7 +562,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2SixInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - new_soft_nms_sigma, 0, true); + new_soft_nms_sigma, 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -581,7 +581,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2FiveInputs) { auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); auto score_threshold = opset5::Constant::create(element::f32, Shape{}, {0.7}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, score_threshold, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -611,7 +611,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2FiveInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -629,7 +629,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2FourInputs) { auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); auto iou_threshold = opset5::Constant::create(element::f32, Shape{}, {0.75}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, iou_threshold, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -659,7 +659,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2FourInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -676,7 +676,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2ThreeInputs) { auto scores = std::make_shared(element::f32, PartialShape{DYN, 1, 1000}); auto max_output_boxes_per_class = opset5::Constant::create(element::i64, Shape{}, {10}); auto nms = std::make_shared(boxes, scores, max_output_boxes_per_class, - opset5::NonMaxSuppression::BoxEncodingType::CORNER, true); + opset5::NonMaxSuppression::BoxEncodingType::CORNER, true, element::i32); f = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -706,7 +706,7 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2ThreeInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); @@ -752,10 +752,12 @@ TEST(TransformationTests, ConvertNMS5ToNMSIEDynamic2TwoInputs) { opset5::Constant::create(ngraph::element::i64, one_dim_shape, one_dim_shape), true); auto nms = std::make_shared(boxes, scores, new_max_per_class, new_iou_threshold, new_score_threshold, - 0, true); + 0, true, element::i32); nms->set_friendly_name("nms"); - f_ref = std::make_shared(NodeVector{nms}, ParameterVector{boxes, scores}); + auto convert_0 = std::make_shared(nms->output(0), element::i64); + + f_ref = std::make_shared(NodeVector{convert_0}, ParameterVector{boxes, scores}); } auto res = compare_functions(f, f_ref); diff --git a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp index 4235bfe58ba..02e6d9921bd 100644 --- a/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp +++ b/inference-engine/tests/functional/plugin/myriad/subgraph_tests/dsr_non_max_suppression.cpp @@ -77,9 +77,12 @@ protected: SetRefMode(LayerTestsUtils::RefMode::INTERPRETER); configuration[InferenceEngine::MYRIAD_DETECT_NETWORK_BATCH] = CONFIG_VALUE(NO); const auto testedOp = createTestedOp(); - + const auto identity_0 = std::make_shared(testedOp->output(0), + ngraph::opset5::Constant::create(testedOp->output(0).get_element_type(), ngraph::Shape{1}, {1})); + const auto identity_2 = std::make_shared(testedOp->output(2), + ngraph::opset5::Constant::create(testedOp->output(2).get_element_type(), ngraph::Shape{1}, {1})); function = std::make_shared( - ngraph::OutputVector{testedOp->output(0), testedOp->output(2)}, + ngraph::OutputVector{identity_0, identity_2}, m_parameterVector); } }; diff --git a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp index 5a51f361f31..80b0d0d37d3 100644 --- a/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/single_layer_tests/non_max_suppression.hpp @@ -34,7 +34,6 @@ using NmsParams = std::tuple, virtual public LayerTestsUtils::LayerTestsCommon { public: static std::string getTestCaseName(testing::TestParamInfo obj); - void ConfigureNetwork() override; void Infer() override; void Compare(const std::vector> &expectedOutputs, const std::vector &actualOutputs) override; diff --git a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/non_max_suppression.cpp b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/non_max_suppression.cpp index f59d725d671..27fbf901cae 100644 --- a/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/non_max_suppression.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/single_layer_tests/non_max_suppression.cpp @@ -37,19 +37,6 @@ std::string NmsLayerTest::getTestCaseName(testing::TestParamInfo obj) return result.str(); } -void NmsLayerTest::ConfigureNetwork() { - const OutputsDataMap &outputMap = cnnNetwork.getOutputsInfo(); - auto out = outputMap.begin(); - for (size_t i = 0; i < outputMap.size(); i++) { - if (i < 2) { - TensorDesc desc(out->second->getTensorDesc().getPrecision(), SizeVector{numOfSelectedBoxes, 3}, - TensorDesc::getLayoutByDims(SizeVector{numOfSelectedBoxes, 3})); - *(out->second) = *std::make_shared(out->first, desc); - } - out++; - } -} - void NmsLayerTest::Infer() { inferRequest = executableNetwork.CreateInferRequest(); inputs.clear(); @@ -130,7 +117,10 @@ void NmsLayerTest::SetUp() { auto nms = builder::makeNms(paramOuts[0], paramOuts[1], convertIE2nGraphPrc(maxBoxPrec), convertIE2nGraphPrc(thrPrec), maxOutBoxesPerClass, iouThr, scoreThr, softNmsSigma, boxEncoding, sortResDescend, outType); - function = std::make_shared(nms, params, "NMS"); + auto nms_0_identity = std::make_shared(nms->output(0), opset5::Constant::create(outType, Shape{1}, {1})); + auto nms_1_identity = std::make_shared(nms->output(1), opset5::Constant::create(ngPrc, Shape{1}, {1})); + auto nms_2_identity = std::make_shared(nms->output(2), opset5::Constant::create(outType, Shape{1}, {1})); + function = std::make_shared(OutputVector{nms_0_identity, nms_1_identity, nms_2_identity}, params, "NMS"); } TEST_P(NmsLayerTest, CompareWithRefs) { diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index f25eeb89a7c..26144545855 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -174,30 +174,6 @@ xfail_issue_38735 = xfail_test(reason="RuntimeError: nGraph does not support the xfail_issue_38736 = xfail_test(reason="RuntimeError: nGraph does not support the following ONNX operations:" "NegativeLogLikelihoodLoss") -xfail_issue_42779 = xfail_test(reason="Unsupported dynamic ops:" - "v1::TopKIE TopK_6774 (Gather_706[0]:f32{16000}, Unsqueeze_7522[0]:" - "i32{1}) -> (f32{?}, i32{?})" - "v0::Convert TopK_718.1 (TopK_6774[1]:i32{?}) -> (i32{?})" - "v0::GatherIE Gather_733 (Gather_706[0]:f32{16000}, TopK_718.1[0]:" - "i32{?}) -> (f32{?})" - "v1::Reshape scores (Gather_733[0]:f32{?}, Constant_6852[0]:i32{2})" - " -> (f32{1,?})" - "v0::Result scores (scores[0]:f32{1,?}) -> (f32{1,?})" - "v0::GatherIE Gather_729 (Gather_690[0]:i32{16000}, TopK_718.1[0]:" - "i32{?}) -> (i32{?})" - "v1::Reshape Unsqueeze_730 (Gather_729[0]:i32{?}, Constant_6854[0]:" - "i32{2}) -> (i32{1,?})" - "v1::Eltwise labels (Unsqueeze_730[0]:i32{1,?}, Constant_6855[0]:" - "i32{}) -> (i32{1,?})" - "v0::Result labels (labels[0]:i32{1,?}) -> (i32{1,?})" - "v0::GatherIE Gather_720 (Gather_697[0]:i32{16000}, TopK_718.1[0]:" - "i32{?}) -> (i32{?})" - "v0::GatherIE Gather_727 (Squeeze_719[0]:f32{15130,4}, Gather_720[0]:" - "i32{?}) -> (f32{?,4})" - "v1::Reshape bboxes (Gather_727[0]:f32{?,4}, Constant_6859[0]:i32{3})" - " -> (f32{1,?,4})" - "v0::Result bboxes (bboxes[0]:f32{1,?,4}) -> (f32{1,?,4}))") - # Model ONNX Zoo issues: xfail_issue_36533 = xfail_test(reason="AssertionError: zoo models results mismatch") xfail_issue_39684 = xfail_test(reason="ngraph.exceptions.UserInputError:" diff --git a/ngraph/python/tests/test_onnx/test_zoo_models.py b/ngraph/python/tests/test_onnx/test_zoo_models.py index 88bad873f66..2931a613029 100644 --- a/ngraph/python/tests/test_onnx/test_zoo_models.py +++ b/ngraph/python/tests/test_onnx/test_zoo_models.py @@ -37,8 +37,7 @@ from tests import ( xfail_issue_38084, xfail_issue_39669, xfail_issue_38726, - xfail_issue_40686, - xfail_issue_42779) + xfail_issue_40686) MODELS_ROOT_DIR = tests.MODEL_ZOO_DIR @@ -157,7 +156,6 @@ if len(zoo_models) > 0: (xfail_issue_39685, "test_onnx_model_zoo_text_machine_comprehension_roberta_model_roberta_sequence_classification_9_roberta_sequence_classification_9_roberta_sequence_classification_9_cpu"), (xfail_issue_39669, "test_onnx_model_zoo_text_machine_comprehension_t5_model_t5_encoder_12_t5_encoder_cpu"), (xfail_issue_38084, "test_onnx_model_zoo_vision_object_detection_segmentation_mask_rcnn_model_MaskRCNN_10_mask_rcnn_R_50_FPN_1x_cpu"), - (xfail_issue_42779, "test_onnx_model_zoo_vision_object_detection_segmentation_ssd_model_ssd_10_model_cpu"), (xfail_issue_38084, "test_onnx_model_zoo_vision_object_detection_segmentation_faster_rcnn_model_FasterRCNN_10_faster_rcnn_R_50_FPN_1x_cpu"), (xfail_issue_41815, "test_onnx_model_zoo_vision_object_detection_segmentation_yolov3_model_yolov3_10_yolov3_yolov3_cpu"), (xfail_issue_41815, "test_onnx_model_zoo_vision_object_detection_segmentation_tiny_yolov3_model_tiny_yolov3_11_yolov3_tiny_cpu"),