From 7790f2036f7c4c4d0576bf42dfe2be4b6c8c1082 Mon Sep 17 00:00:00 2001 From: Irina Efode Date: Fri, 11 Mar 2022 19:17:53 +0300 Subject: [PATCH] [IE TESTS][CONFORMANCE] Fix for IRs with dynamic shapes (#10880) --- .../src/read_ir_test/read_ir.cpp | 49 ++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/read_ir_test/read_ir.cpp b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/read_ir_test/read_ir.cpp index 551bf062d28..2184e669507 100644 --- a/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/read_ir_test/read_ir.cpp +++ b/src/tests/functional/plugin/conformance/test_runner/conformance_infra/src/read_ir_test/read_ir.cpp @@ -161,28 +161,55 @@ void ReadIRTest::SetUp() { } } } + + bool hasDynamic = false; + for (const auto& param : function->get_parameters()) { + if (param->get_partial_shape().is_dynamic()) { + hasDynamic = true; + break; + } + } + if (hasDynamic && ov::test::subgraph::shapeMode == ov::test::subgraph::ShapeMode::STATIC) { + GTEST_SKIP() << "Dynamic cases are skipped according `shape_mode`"; + } else if (!hasDynamic && ov::test::subgraph::shapeMode == ov::test::subgraph::ShapeMode::DYNAMIC) { + GTEST_SKIP() << "Static cases are skipped according `shape_mode`"; + } + std::vector inputShapes; for (const auto& param : function -> get_parameters()) { if (param->get_partial_shape().is_static()) { - if (ov::test::subgraph::shapeMode == ov::test::subgraph::ShapeMode::DYNAMIC) { - GTEST_SKIP() << "Static cases are skipped according `shape_mode`"; - } inputShapes.push_back(InputShape{{}, {param->get_shape()}}); } else { - if (ov::test::subgraph::shapeMode == ov::test::subgraph::ShapeMode::STATIC) { - GTEST_SKIP() << "Dynamic cases are skipped according `shape_mode`"; - } + std::vector staticShapes = { param->get_partial_shape().get_min_shape(), + param->get_partial_shape().get_min_shape(), + param->get_partial_shape().get_max_shape() }; ov::Shape midShape; for (const auto s : param->get_partial_shape()) { - int dimValue = s.get_length(); + int dimValue = 1; if (s.is_dynamic()) { - CommonTestUtils::fill_data_random(&dimValue, 1, s.get_max_length() - s.get_min_length(), s.get_min_length(), 1); + size_t range = s.get_max_length() - s.get_min_length(); + if (range > std::numeric_limits::max()) { + CommonTestUtils::fill_data_random(&range, 1, std::numeric_limits::max(), s.get_min_length(), 1); + } + CommonTestUtils::fill_data_random(&dimValue, 1, range, s.get_min_length(), 1); + } else { + dimValue = s.get_length(); } midShape.push_back(dimValue); } - inputShapes.push_back(InputShape{param->get_partial_shape(), { param->get_partial_shape().get_min_shape(), - param->get_partial_shape().get_max_shape(), - midShape }}); + staticShapes[1] = midShape; + + // Shape validation to avoid large values + for (auto& shape : staticShapes) { + for (auto& dim : shape) { + if (dim == 0) { + dim = 1; + } else if (dim > std::numeric_limits::max()) { + dim = std::numeric_limits::max(); + } + } + } + inputShapes.push_back(InputShape{param->get_partial_shape(), staticShapes}); } } init_input_shapes(inputShapes);