diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp index 0f71f32ef7b95f..4197076d6dc0d6 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -2,44 +2,38 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "subgraph_tests/constant_result.hpp" + #include -#include "subgraph_tests/constant_result.hpp" #include "common_test_utils/test_constants.hpp" -using namespace SubgraphTestsDefinitions; -using namespace InferenceEngine; +using namespace ov::test; namespace { -const std::vector types = { - ConstantSubgraphType::SINGLE_COMPONENT, - ConstantSubgraphType::SEVERAL_COMPONENT -}; - -const std::vector shapes = { - {1, 3, 10, 10}, - {2, 3, 4, 5} -}; - -const std::vector precisions = { - Precision::U8, - Precision::I8, - Precision::U16, - Precision::I16, - Precision::I32, - Precision::U64, - Precision::I64, - Precision::FP32, - Precision::BOOL -}; - -INSTANTIATE_TEST_SUITE_P(smoke_Check, ConstantResultSubgraphTest, - ::testing::Combine( - ::testing::ValuesIn(types), - ::testing::ValuesIn(shapes), - ::testing::ValuesIn(precisions), - ::testing::Values(ov::test::utils::DEVICE_CPU)), - ConstantResultSubgraphTest::getTestCaseName); - -} // namespace +const std::vector types = {ConstantSubgraphType::SINGLE_COMPONENT, + ConstantSubgraphType::SEVERAL_COMPONENT}; + +const std::vector shapes = {{1, 3, 10, 10}, {2, 3, 4, 5}}; + +const std::vector precisions = {ov::element::u8, + ov::element::i8, + ov::element::u16, + ov::element::i16, + ov::element::u32, + ov::element::i32, + ov::element::u64, + ov::element::i64, + ov::element::f32, + ov::element::boolean}; + +INSTANTIATE_TEST_SUITE_P(smoke_Check, + ConstantResultSubgraphTest, + ::testing::Combine(::testing::ValuesIn(types), + ::testing::ValuesIn(shapes), + ::testing::ValuesIn(precisions), + ::testing::Values(ov::test::utils::DEVICE_CPU)), + ConstantResultSubgraphTest::getTestCaseName); + +} // namespace diff --git a/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp b/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp index a3f9aabb67c01f..312466a2f765f0 100644 --- a/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/src/plugins/intel_gna/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -2,11 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "subgraph_tests/constant_result.hpp" - #include #include "common_test_utils/test_constants.hpp" +#include "subgraph_tests/constant_result_legacy.hpp" using namespace SubgraphTestsDefinitions; using namespace InferenceEngine; diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp index b23220562451bf..97614faf548515 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/subgraph_tests/constant_result.cpp @@ -4,7 +4,7 @@ #include -#include "subgraph_tests/constant_result.hpp" +#include "subgraph_tests/constant_result_legacy.hpp" #include "common_test_utils/test_constants.hpp" using namespace SubgraphTestsDefinitions; diff --git a/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result.hpp b/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result.hpp index c3d8905fc219e2..e9aa3517cafcc7 100644 --- a/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result.hpp +++ b/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result.hpp @@ -6,11 +6,12 @@ #include "shared_test_classes/subgraph/constant_result.hpp" -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { TEST_P(ConstantResultSubgraphTest, CompareWithRefs) { - Run(); + run(); } -} // namespace SubgraphTestsDefinitions - +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result_legacy.hpp b/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result_legacy.hpp new file mode 100644 index 00000000000000..d41ceef9ed5a08 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/subgraph_tests/constant_result_legacy.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/subgraph/constant_result.hpp" + +namespace SubgraphTestsDefinitions { + +TEST_P(ConstantResultSubgraphTest, CompareWithRefs) { + Run(); +} + +} // namespace SubgraphTestsDefinitions diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/constant_result.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/constant_result.hpp index 6537eaefc5ade4..b979473ead34d1 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/constant_result.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/subgraph/constant_result.hpp @@ -4,35 +4,63 @@ #pragma once -#include +#include #include +#include #include -#include +#include "openvino/core/type/element_type.hpp" #include "shared_test_classes/base/layer_test_utils.hpp" -#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { + +enum class ConstantSubgraphType { SINGLE_COMPONENT, SEVERAL_COMPONENT }; + +std::ostream& operator<<(std::ostream& os, ConstantSubgraphType type); + +typedef std::tuple + constResultParams; + +class ConstantResultSubgraphTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + void createGraph(const ConstantSubgraphType& type, + const ov::Shape& input_shape, + const ov::element::Type& input_type); -enum class ConstantSubgraphType { - SINGLE_COMPONENT, - SEVERAL_COMPONENT +protected: + void SetUp() override; }; -std::ostream& operator<<(std::ostream &os, ConstantSubgraphType type); +} // namespace test +} // namespace ov -typedef std::tuple < - ConstantSubgraphType, - InferenceEngine::SizeVector, // input shape - InferenceEngine::Precision, // input precision - std::string // Device name -> constResultParams; +namespace SubgraphTestsDefinitions { + +using ov::test::ConstantSubgraphType; + +typedef std::tuple + constResultParams; class ConstantResultSubgraphTest : public testing::WithParamInterface, virtual public LayerTestsUtils::LayerTestsCommon { public: static std::string getTestCaseName(const testing::TestParamInfo& obj); - void createGraph(const ConstantSubgraphType& type, const InferenceEngine::SizeVector &inputShape, const InferenceEngine::Precision &inputPrecision); + void createGraph(const ConstantSubgraphType& type, + const InferenceEngine::SizeVector& inputShape, + const InferenceEngine::Precision& inputPrecision); + protected: void SetUp() override; }; diff --git a/src/tests/functional/shared_test_classes/src/subgraph/constant_result.cpp b/src/tests/functional/shared_test_classes/src/subgraph/constant_result.cpp index e14239f14c56f1..7e7261fe3eeaec 100644 --- a/src/tests/functional/shared_test_classes/src/subgraph/constant_result.cpp +++ b/src/tests/functional/shared_test_classes/src/subgraph/constant_result.cpp @@ -4,29 +4,84 @@ #include "shared_test_classes/subgraph/constant_result.hpp" -using namespace InferenceEngine; -using namespace ngraph; +#include "ov_models/builders.hpp" +#include "openvino/op/result.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { -std::ostream& operator<<(std::ostream &os, ConstantSubgraphType type) { +std::ostream& operator<<(std::ostream& os, ConstantSubgraphType type) { switch (type) { - case ConstantSubgraphType::SINGLE_COMPONENT: - os << "SINGLE_COMPONENT"; - break; - case ConstantSubgraphType::SEVERAL_COMPONENT: - os << "SEVERAL_COMPONENT"; - break; - default: - os << "UNSUPPORTED_CONST_SUBGRAPH_TYPE"; + case ConstantSubgraphType::SINGLE_COMPONENT: + os << "SINGLE_COMPONENT"; + break; + case ConstantSubgraphType::SEVERAL_COMPONENT: + os << "SEVERAL_COMPONENT"; + break; + default: + os << "UNSUPPORTED_CONST_SUBGRAPH_TYPE"; } return os; } std::string ConstantResultSubgraphTest::getTestCaseName(const testing::TestParamInfo& obj) { ConstantSubgraphType type; - SizeVector IS; - Precision inputPrecision; + ov::Shape input_shape; + ov::element::Type input_type; + std::string target_device; + + std::tie(type, input_shape, input_type, target_device) = obj.param; + std::ostringstream result; + result << "SubgraphType=" << type << "_"; + result << "IS=" << input_shape << "_"; + result << "IT=" << input_type << "_"; + result << "Device=" << target_device; + return result.str(); +} + +void ConstantResultSubgraphTest::createGraph(const ConstantSubgraphType& type, + const ov::Shape& input_shape, + const ov::element::Type& input_type) { + ParameterVector params; + ResultVector results; + switch (type) { + case ConstantSubgraphType::SINGLE_COMPONENT: { + auto input = ngraph::builder::makeConstant(input_type, input_shape, {}, true); + results.push_back(std::make_shared(input)); + break; + } + case ConstantSubgraphType::SEVERAL_COMPONENT: { + auto input1 = ngraph::builder::makeConstant(input_type, input_shape, {}, true); + results.push_back(std::make_shared(input1)); + auto input2 = ngraph::builder::makeConstant(input_type, input_shape, {}, true); + results.push_back(std::make_shared(input2)); + break; + } + default: { + throw std::runtime_error("Unsupported constant graph type"); + } + } + function = std::make_shared(results, params, "ConstResult"); +} + +void ConstantResultSubgraphTest::SetUp() { + ConstantSubgraphType type; + ov::Shape input_shape; + ov::element::Type input_type; + std::tie(type, input_shape, input_type, targetDevice) = this->GetParam(); + + createGraph(type, input_shape, input_type); +} +} // namespace test +} // namespace ov + +namespace SubgraphTestsDefinitions { + +std::string ConstantResultSubgraphTest::getTestCaseName(const testing::TestParamInfo& obj) { + ConstantSubgraphType type; + InferenceEngine::SizeVector IS; + InferenceEngine::Precision inputPrecision; std::string targetDevice; std::tie(type, IS, inputPrecision, targetDevice) = obj.param; @@ -38,35 +93,37 @@ std::string ConstantResultSubgraphTest::getTestCaseName(const testing::TestParam return result.str(); } -void ConstantResultSubgraphTest::createGraph(const ConstantSubgraphType& type, const SizeVector &inputShape, const Precision &inputPrecision) { +void ConstantResultSubgraphTest::createGraph(const ConstantSubgraphType& type, + const InferenceEngine::SizeVector& inputShape, + const InferenceEngine::Precision& inputPrecision) { auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(inputPrecision); - ParameterVector params; - ResultVector results; + ov::ParameterVector params; + ov::ResultVector results; switch (type) { - case ConstantSubgraphType::SINGLE_COMPONENT: { - auto input = builder::makeConstant(ngPrc, inputShape, {}, true); - results.push_back(std::make_shared(input)); - break; - } - case ConstantSubgraphType::SEVERAL_COMPONENT: { - auto input1 = builder::makeConstant(ngPrc, inputShape, {}, true); - results.push_back(std::make_shared(input1)); - auto input2 = builder::makeConstant(ngPrc, inputShape, {}, true); - results.push_back(std::make_shared(input2)); - break; - } - default: { - throw std::runtime_error("Unsupported constant graph type"); - } + case ConstantSubgraphType::SINGLE_COMPONENT: { + auto input = ngraph::builder::makeConstant(ngPrc, inputShape, {}, true); + results.push_back(std::make_shared(input)); + break; + } + case ConstantSubgraphType::SEVERAL_COMPONENT: { + auto input1 = ngraph::builder::makeConstant(ngPrc, inputShape, {}, true); + results.push_back(std::make_shared(input1)); + auto input2 = ngraph::builder::makeConstant(ngPrc, inputShape, {}, true); + results.push_back(std::make_shared(input2)); + break; + } + default: { + throw std::runtime_error("Unsupported constant graph type"); + } } - function = std::make_shared(results, params, "ConstResult"); + function = std::make_shared(results, params, "ConstResult"); } void ConstantResultSubgraphTest::SetUp() { ConstantSubgraphType type; - SizeVector IS; - Precision inputPrecision; + InferenceEngine::SizeVector IS; + InferenceEngine::Precision inputPrecision; std::tie(type, IS, inputPrecision, targetDevice) = this->GetParam(); createGraph(type, IS, inputPrecision);