From aaf4ba0b5162cd81c0f9756b10b0a62517df3ee4 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 24 Jan 2022 13:41:14 +0300 Subject: [PATCH] [GNA] Enabled the new tests (#9753) * Enabled the new tests * Enabled unsupported precisions * Added additional checks --- .../behavior/ov_infer_request/io_tensor.cpp | 45 +++++++++++++++++++ .../behavior/ov_infer_request/io_tensor.hpp | 1 + .../behavior/ov_infer_request/io_tensor.cpp | 7 ++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/tests/functional/plugin/gna/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp b/src/tests/functional/plugin/gna/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp index f68579b9a10..af3c57205bf 100644 --- a/src/tests/functional/plugin/gna/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp +++ b/src/tests/functional/plugin/gna/shared_tests_instances/behavior/ov_infer_request/io_tensor.cpp @@ -33,6 +33,44 @@ std::vector prcs = { ov::element::u64, }; +std::vector supported_input_prcs = { + ov::element::f32, + ov::element::i16, + ov::element::u8 +}; + +class OVInferRequestCheckTensorPrecisionGNA : public OVInferRequestCheckTensorPrecision { +public: + void SetUp() override { + try { + OVInferRequestCheckTensorPrecision::SetUp(); + if (std::count(supported_input_prcs.begin(), supported_input_prcs.end(), element_type) == 0) { + FAIL() << "Precision " << element_type.c_type_string() << " is marked as unsupported but the network was loaded successfully"; + } + } + catch (std::runtime_error& e) { + const std::string errorMsg = e.what(); + const auto expectedMsg = exp_error_str_; + ASSERT_STR_CONTAINS(errorMsg, expectedMsg); + EXPECT_TRUE(errorMsg.find(expectedMsg) != std::string::npos) + << "Wrong error message, actual error message: " << errorMsg + << ", expected: " << expectedMsg; + if (std::count(supported_input_prcs.begin(), supported_input_prcs.end(), element_type) == 0) { + GTEST_SKIP_(expectedMsg.c_str()); + } else { + FAIL() << "Precision " << element_type.c_type_string() << " is marked as supported but the network was not loaded"; + } + } + } + +private: + std::string exp_error_str_ = "The plugin does not support input precision"; +}; + +TEST_P(OVInferRequestCheckTensorPrecisionGNA, CheckInputsOutputs) { + Run(); +} + INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestIOTensorTest, ::testing::Combine( ::testing::Values(CommonTestUtils::DEVICE_GNA), @@ -46,4 +84,11 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestIOTensorSetPrecision ::testing::ValuesIn(configs)), OVInferRequestIOTensorSetPrecisionTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests, OVInferRequestCheckTensorPrecisionGNA, + ::testing::Combine( + ::testing::ValuesIn(prcs), + ::testing::Values(CommonTestUtils::DEVICE_GNA), + ::testing::ValuesIn(configs)), + OVInferRequestCheckTensorPrecisionGNA::getTestCaseName); + } // namespace \ No newline at end of file diff --git a/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/io_tensor.hpp b/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/io_tensor.hpp index 2dd01988d1d..b70dc1fce58 100644 --- a/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/io_tensor.hpp +++ b/src/tests/functional/plugin/shared/include/behavior/ov_infer_request/io_tensor.hpp @@ -49,6 +49,7 @@ struct OVInferRequestCheckTensorPrecision : public testing::WithParamInterface& obj); void SetUp() override; void TearDown() override; + void Run(); std::shared_ptr core = utils::PluginCache::get().core(); std::shared_ptr model; diff --git a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp index 79028590ef3..f14e042b9cd 100644 --- a/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp +++ b/src/tests/functional/plugin/shared/src/behavior/ov_infer_request/io_tensor.cpp @@ -267,7 +267,7 @@ void OVInferRequestCheckTensorPrecision::TearDown() { req = {}; } -TEST_P(OVInferRequestCheckTensorPrecision, CheckInputsOutputs) { +void OVInferRequestCheckTensorPrecision::Run() { EXPECT_EQ(element_type, compModel.input(0).get_element_type()); EXPECT_EQ(element_type, compModel.input(1).get_element_type()); EXPECT_EQ(element_type, compModel.output().get_element_type()); @@ -275,6 +275,11 @@ TEST_P(OVInferRequestCheckTensorPrecision, CheckInputsOutputs) { EXPECT_EQ(element_type, req.get_input_tensor(1).get_element_type()); EXPECT_EQ(element_type, req.get_output_tensor().get_element_type()); } + +TEST_P(OVInferRequestCheckTensorPrecision, CheckInputsOutputs) { + Run(); +} + } // namespace behavior } // namespace test } // namespace ov