From 65b8bdf892fd26ee956c568267ce967d4f5a475f Mon Sep 17 00:00:00 2001 From: River Li Date: Tue, 5 Dec 2023 22:18:16 +0800 Subject: [PATCH] [CPU Tests] migrate sub_graph test cases - part 2 (#21379) * [CPU Tests] migrate sub_graph test case - part 2 * remove unused header files --------- Co-authored-by: Vitaliy Urusovskij --- .../src/arm/convert_group_conv.cpp | 45 ++++---- .../src/arm/convert_group_conv1d.cpp | 47 +++----- .../src/arm/convert_reduce_multi_axis.cpp | 60 ++++------ .../subgraph_tests/src/eltwise_caching.cpp | 55 ++++----- .../subgraph_tests/src/eltwise_chain.cpp | 92 +++++++-------- .../subgraph_tests/src/rotary_pos_emb.cpp | 9 +- .../subgraph_tests/src/seq_native_order.cpp | 108 +++++++++--------- .../subgraph_tests/src/static_zero_dims.cpp | 31 +++-- 8 files changed, 213 insertions(+), 234 deletions(-) diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp index 48aea151242..2a631c34416 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv.cpp @@ -2,28 +2,14 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include -#include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/node_builders/group_convolution.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" - -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { typedef std::tuple groupConvLayerCPUTestParamsSet; @@ -60,15 +46,23 @@ protected: ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { - inputParams.push_back(std::make_shared(ngraph::element::f32, shape)); + inputParams.push_back(std::make_shared(ov::element::f32, shape)); } - conv = builder::makeGroupConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, - paddingType, numOutChannels, numOfGroups); + conv = utils::make_group_convolution(inputParams[0], + element::f32, + kernelSize, + strides, + padBegin, + padEnd, + dilation, + paddingType, + numOutChannels, + numOfGroups); ResultVector results; - results.push_back(std::make_shared(conv)); + results.push_back(std::make_shared(conv)); - function = std::make_shared(results, inputParams, "groupConvolution"); + function = std::make_shared(results, inputParams, "groupConvolution"); } }; @@ -96,5 +90,6 @@ const auto groupConvTransformationParams = ::testing::Combine(::testing::ValuesI INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, GroupConvToConvTransformationCPUTest, groupConvTransformationParams, GroupConvToConvTransformationCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp index 79a21d4c8bd..9beb3be72f5 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_group_conv1d.cpp @@ -2,35 +2,23 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/node_builders/convolution.hpp" +#include "common_test_utils/node_builders/group_convolution.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { -typedef std::tuple conv1dConvertCPUTestParamsSet; +typedef std::tuple conv1dConvertCPUTestParamsSet; -class Conv1dConvertTransformationCPUTest: public testing::WithParamInterface, - virtual public SubgraphBaseTest, public CPUTestsBase { +class Conv1dConvertTransformationCPUTest : public testing::WithParamInterface, + virtual public SubgraphBaseTest, + public CPUTestsBase { public: static std::string getTestCaseName(testing::TestParamInfo obj) { InputShape inputShapes; @@ -65,16 +53,16 @@ protected: ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { - inputParams.push_back(std::make_shared(ngraph::element::f32, shape)); + inputParams.push_back(std::make_shared(ov::element::f32, shape)); } switch (convType) { case nodeType::convolution : { - conv = builder::makeConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, + conv = utils::make_convolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, paddingType, numOutChannels); break; } case nodeType::groupConvolution : { - conv = builder::makeGroupConvolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, + conv = utils::make_group_convolution(inputParams[0], element::f32, kernelSize, strides, padBegin, padEnd, dilation, paddingType, numOutChannels, numOfGroups); break; } @@ -84,9 +72,9 @@ protected: } ResultVector results; - results.push_back(std::make_shared(conv)); + results.push_back(std::make_shared(conv)); - function = std::make_shared(results, inputParams, "convolution"); + function = std::make_shared(results, inputParams, "convolution"); } }; @@ -132,5 +120,6 @@ const auto groupConvTransformationParams = ::testing::Combine(::testing::ValuesI INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, Conv1dConvertTransformationCPUTest, groupConvTransformationParams, Conv1dConvertTransformationCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp index 3bb5a06c7d9..2b837a4fd27 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/arm/convert_reduce_multi_axis.cpp @@ -2,35 +2,22 @@ // SPDX-License-Identifier: Apache-2.0 // -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/node_builders/reduce.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -#include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -#include "test_utils/cpu_test_utils.hpp" -#include "test_utils/convolution_params.hpp" - -using namespace InferenceEngine; using namespace CPUTestUtils; -using namespace ov::test; -using namespace ngraph; -using namespace ngraph::helpers; -namespace CPUSubgraphTestsDefinitions { +namespace ov { +namespace test { -typedef std::tuple< - std::vector, // Axis to reduce order - ngraph::helpers::ReductionType, // Reduce operation type - std::vector // Input shapes -> reduceConvertCPUTestParamsSet; +typedef std::tuple, // Axis to reduce order + ov::test::utils::ReductionType, // Reduce operation type + std::vector // Input shapes + > + reduceConvertCPUTestParamsSet; class reduceTransformationCPUTest: public testing::WithParamInterface, virtual public SubgraphBaseTest, public CPUTestsBase { @@ -38,7 +25,7 @@ public: static std::string getTestCaseName(testing::TestParamInfo obj) { std::vector inputShapes; std::vector axes; - ReductionType reductionType; + utils::ReductionType reductionType; std::tie(axes, reductionType, inputShapes) = obj.param; std::ostringstream result; @@ -65,18 +52,18 @@ protected: ov::ParameterVector params; for (auto&& shape : inputDynamicShapes) { - params.push_back(std::make_shared(ngraph::element::f32, shape)); + params.push_back(std::make_shared(ov::element::f32, shape)); } std::vector shapeAxes; shapeAxes.push_back(axes.size()); - auto reductionAxesNode = std::dynamic_pointer_cast( - std::make_shared(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes)); + auto reductionAxesNode = std::dynamic_pointer_cast( + std::make_shared(ov::element::Type_t::i64, ov::Shape(shapeAxes), axes)); - const auto reduce = ngraph::builder::makeReduce(params[0], reductionAxesNode, keepDims, reductionType); + const auto reduce = utils::make_reduce(params[0], reductionAxesNode, keepDims, reductionType); function = makeNgraphFunction(ElementType::f32, params, reduce, "Reduce"); } private: - ngraph::helpers::ReductionType reductionType; + utils::ReductionType reductionType; }; TEST_P(reduceTransformationCPUTest, CompareWithRefs) { @@ -88,11 +75,11 @@ namespace { std::vector> inputShapes = { {{{}, {{2, 19, 2, 9}}}} }; -const std::vector reductionTypes = { - ReductionType::Min, - ReductionType::Max, - ReductionType::Sum, - ReductionType::Prod +const std::vector reductionTypes = { + utils::ReductionType::Min, + utils::ReductionType::Max, + utils::ReductionType::Sum, + utils::ReductionType::Prod }; const std::vector> axes = { {0, 1}, @@ -114,5 +101,6 @@ const auto reduceTransformationParams = ::testing::Combine(::testing::ValuesIn(a INSTANTIATE_TEST_SUITE_P(smoke_GroupConvToConvTransformationTest, reduceTransformationCPUTest, reduceTransformationParams, reduceTransformationCPUTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp index d5f5f3ead3c..487235fa8dd 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_caching.cpp @@ -32,23 +32,23 @@ // |output| // -------- -#include -#include -#include -#include -#include -#include -#include #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" +#include "ov_models/builders.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" #include "test_utils/cpu_test_utils.hpp" -using namespace CPUTestUtils; -using ngraph::helpers::EltwiseTypes; -using namespace ov::test; +#include +#include +#include +#include -namespace CPUSubgraphTestsDefinitions { +using namespace CPUTestUtils; + +namespace ov { +namespace test { +using namespace ov::test::utils; using InputShapesTuple = std::tuple< std::vector, // eltwise input shapes @@ -122,7 +122,7 @@ public: return results.str(); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -155,31 +155,31 @@ protected: init_input_shapes(eltwiseInputShapes); - ngraph::ParameterVector ngraphParam; - std::vector> ngraphInputs; + ov::ParameterVector paramVec; + std::vector> inputNodes; for (size_t i = 0; i < inputDynamicShapes.size(); i++) { - ngraphParam.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); - ngraphInputs.push_back(ngraphParam.back()); + paramVec.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); + inputNodes.push_back(paramVec.back()); } - auto lastNode0 = ngraph::builder::makeEltwise(ngraphParam[0], ngraphParam[1], eltwiseOpTypes[0]); + auto lastNode0 = utils::makeEltwise(paramVec[0], paramVec[1], eltwiseOpTypes[0]); lastNode0->get_rt_info() = getCPUInfo(); - auto lastNode1 = ngraph::builder::makeEltwise(ngraphParam[2], ngraphParam[3], eltwiseOpTypes[1]); + auto lastNode1 = utils::makeEltwise(paramVec[2], paramVec[3], eltwiseOpTypes[1]); lastNode1->get_rt_info() = getCPUInfo(); if (withQuantization) { - lastNode0 = ngraph::builder::makeFakeQuantize(lastNode0, ::ngraph::element::Type(::ngraph::element::Type_t::f32), + lastNode0 = ngraph::builder::makeFakeQuantize(lastNode0, ov::element::Type(ov::element::Type_t::f32), 256, fqInputShapes[0]); - lastNode1 = ngraph::builder::makeFakeQuantize(lastNode1, ::ngraph::element::Type(::ngraph::element::Type_t::f32), + lastNode1 = ngraph::builder::makeFakeQuantize(lastNode1, ov::element::Type(ov::element::Type_t::f32), 256, fqInputShapes[1]); } if (needReshape) { - auto reshapeConstNode = ngraph::builder::makeConstant(::ngraph::element::Type(::ngraph::element::Type_t::i32), + auto reshapeConstNode = ngraph::builder::makeConstant(ov::element::Type(ov::element::Type_t::i32), {reshapeShape.size()}, reshapeShape); - lastNode1 = std::make_shared(lastNode1, reshapeConstNode, false); + lastNode1 = std::make_shared(lastNode1, reshapeConstNode, false); } auto concat = std::make_shared(ov::NodeVector{lastNode0, lastNode1}, 0); - function = std::make_shared(concat, ngraphParam, "eltwise_cache"); + function = std::make_shared(concat, paramVec, "eltwise_cache"); } }; @@ -1328,5 +1328,6 @@ INSTANTIATE_TEST_SUITE_P(smoke_EltwiseCache_7D_dyn, EltwiseCacheTest, ::testing::Values(cpuParams_empty)), EltwiseCacheTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp index ef20c4ffd05..b4bff5634bc 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/eltwise_chain.cpp @@ -6,35 +6,36 @@ #include #include #include -#include -#include -#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "ov_models/builders.hpp" #include "common_test_utils/common_utils.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "test_utils/cpu_test_utils.hpp" +#include "common_test_utils/node_builders/eltwise.hpp" using namespace CPUTestUtils; -using ngraph::helpers::EltwiseTypes; -using namespace ov::test; -namespace CPUSubgraphTestsDefinitions { -typedef std::tuple< - std::vector, // Input shapes - ngraph::helpers::InputLayerType, // Secondary input type - std::vector, // Input precisions - std::vector, // Eltwise operations - bool, // With quantization - std::string // Device name -> EltwiseChainTuple; +namespace ov { +namespace test { +using namespace ov::test::utils; + +typedef std::tuple, // Input shapes + InputLayerType, // Secondary input type + std::vector, // Input precisions + std::vector, // Eltwise operations + bool, // With quantization + std::string // Device name + > + EltwiseChainTuple; class EltwiseChainTest : public testing::WithParamInterface, virtual public SubgraphBaseTest { public: static std::string getTestCaseName(const testing::TestParamInfo &obj) { std::vector inputShapes; - ngraph::helpers::InputLayerType secondaryInputType; + InputLayerType secondaryInputType; std::vector inputPrecisions; std::vector eltwiseOpTypes; bool withQuantization; @@ -65,7 +66,7 @@ public: return results.str(); } - void generate_inputs(const std::vector& targetInputStaticShapes) override { + void generate_inputs(const std::vector& targetInputStaticShapes) override { inputs.clear(); const auto& funcInputs = function->inputs(); for (size_t i = 0; i < funcInputs.size(); ++i) { @@ -81,7 +82,7 @@ protected: abs_threshold = 0.1f; std::vector inputShapes; - ngraph::helpers::InputLayerType secondaryInputType; + InputLayerType secondaryInputType; std::vector inputPrecisions; std::vector eltwiseOpTypes; bool withQuantization; @@ -89,27 +90,27 @@ protected: init_input_shapes(inputShapes); - ngraph::ParameterVector ngraphParam; - std::vector> ngraphInputs; + ov::ParameterVector paramVec; + std::vector> inputNodes; if (secondaryInputType == ngraph::helpers::InputLayerType::PARAMETER) { for (size_t i = 0; i < inputDynamicShapes.size(); i++) { - ngraphParam.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); - ngraphInputs.push_back(ngraphParam.back()); + paramVec.push_back(std::make_shared(inputPrecisions[i], inputDynamicShapes[i])); + inputNodes.push_back(paramVec.back()); } } else { - ngraphParam = ov::ParameterVector {std::make_shared(inputPrecisions[0], inputDynamicShapes.front())}; + paramVec = ov::ParameterVector {std::make_shared(inputPrecisions[0], inputDynamicShapes.front())}; for (size_t i = 1; i < inputPrecisions.size(); i++) { - std::vector ngraphInput1Data(ngraph::shape_size(targetStaticShapes[0][i])); - ngraphInputs.push_back(ngraph::builder::makeConstant(inputPrecisions[i], targetStaticShapes[0][i], - ngraphInput1Data, true)); + std::vector input1Data(ov::shape_size(targetStaticShapes[0][i])); + inputNodes.push_back( + ngraph::builder::makeConstant(inputPrecisions[i], targetStaticShapes[0][i], input1Data, true)); } } if (withQuantization) { - std::vector> eltwiseOps; - eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); + std::vector> eltwiseOps; + eltwiseOps.push_back(makeEltwise(paramVec[0], inputNodes[0], eltwiseOpTypes[0])); for (size_t i = 1; i < eltwiseOpTypes.size() - 1; i++) { - eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); + eltwiseOps.push_back(makeEltwise(eltwiseOps[eltwiseOps.size() - 1], inputNodes[i], eltwiseOpTypes[i])); } std::vector constShape(targetStaticShapes[0][0].size(), 1); @@ -118,19 +119,19 @@ protected: ::ngraph::element::Type(::ngraph::element::Type_t::f32), 256, constShape); - eltwiseOps.push_back(ngraph::builder::makeEltwise(fq, ngraphInputs[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); + eltwiseOps.push_back(makeEltwise(fq, inputNodes[eltwiseOpTypes.size() - 1], eltwiseOpTypes[eltwiseOpTypes.size() - 1])); - ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; - function = std::make_shared(results, ngraphParam, "eltwise_chain_fq"); + ov::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; + function = std::make_shared(results, paramVec, "eltwise_chain_fq"); } else { - std::vector> eltwiseOps; - eltwiseOps.push_back(ngraph::builder::makeEltwise(ngraphParam[0], ngraphInputs[0], eltwiseOpTypes[0])); + std::vector> eltwiseOps; + eltwiseOps.push_back(makeEltwise(paramVec[0], inputNodes[0], eltwiseOpTypes[0])); for (size_t i = 1; i < eltwiseOpTypes.size(); i++) { - eltwiseOps.push_back(ngraph::builder::makeEltwise(eltwiseOps[eltwiseOps.size() - 1], ngraphInputs[i], eltwiseOpTypes[i])); + eltwiseOps.push_back(makeEltwise(eltwiseOps[eltwiseOps.size() - 1], inputNodes[i], eltwiseOpTypes[i])); } - ngraph::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; - function = std::make_shared(results, ngraphParam, "eltwise_chain"); + ov::ResultVector results{std::make_shared(eltwiseOps[eltwiseOps.size() - 1])}; + function = std::make_shared(results, paramVec, "eltwise_chain"); } } }; @@ -141,7 +142,7 @@ TEST_P(EltwiseChainTest, CompareWithRefs) { namespace { -std::vector> inputShapes = { +std::vector> inputShapes = { {{1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}, {1, 1, 2, 3}}, {{1, 48, 5, 6}, {1, 48, 1, 1}, {1, 48, 5, 6}, {1, 1, 5, 6}}, {{1, 72, 28, 28}, {1, 72, 1, 1}, {1, 72, 1, 1}, {1, 72, 1, 1}}, @@ -166,14 +167,14 @@ std::vector> eltwiseOps = { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inputShapes)), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(InputLayerType::CONSTANT), ::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(eltwiseOps), ::testing::Values(false), ::testing::Values(ov::test::utils::DEVICE_CPU)), EltwiseChainTest::getTestCaseName); -std::vector> inputShapesFQ = { +std::vector> inputShapesFQ = { {{1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}, {1, 2, 2, 3}}, {{2, 33, 5, 5}, {2, 33, 5, 5}, {2, 33, 1, 5}, {2, 33, 5, 5}}, {{2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}, {2, 33, 5, 17}}, @@ -197,7 +198,7 @@ std::vector> inputPrecisionsFQ { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChainWithFQ, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(static_shapes_to_test_representation(inputShapesFQ)), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT), + ::testing::Values(InputLayerType::CONSTANT), ::testing::ValuesIn(inputPrecisionsFQ), ::testing::ValuesIn(eltwiseOps), ::testing::Values(true), @@ -455,12 +456,13 @@ std::vector> inputShapes_dyn = { INSTANTIATE_TEST_SUITE_P(smoke_EltwiseChain_dyn, EltwiseChainTest, ::testing::Combine( ::testing::ValuesIn(inputShapes_dyn), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER), + ::testing::Values(InputLayerType::PARAMETER), ::testing::ValuesIn(inputPrecisions), ::testing::ValuesIn(eltwiseOps), ::testing::Values(false), ::testing::Values(ov::test::utils::DEVICE_CPU)), EltwiseChainTest::getTestCaseName); -} // namespace -} // namespace CPUSubgraphTestsDefinitions +} // namespace +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp index 28ed4371c62..c9b367599ab 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/rotary_pos_emb.cpp @@ -22,9 +22,11 @@ using namespace CPUTestUtils; using namespace ov::gen_pattern; -using namespace ov::test; using namespace ov; +namespace ov { +namespace test { + static ov::OutputVector makeCosSinCache(int max_position_embeddings, int rotary_ndims) { std::vector lut_sin(max_position_embeddings * rotary_ndims, 0.0f); std::vector lut_cos(max_position_embeddings * rotary_ndims, 0.0f); @@ -129,8 +131,6 @@ static std::shared_ptr buildROPE_Llama2(const int batch, return std::make_shared(ov::NodeVector{add_Add}, ov::ParameterVector{input, pos_id_end, pos_ids}); } -namespace CPULayerTestsDefinitions { - class RoPECPUTestLlama2 : public SubgraphBaseTest { public: ov::Tensor create_i32_tensor(const ov::Shape& shape, int start, int step = 1) { @@ -328,4 +328,5 @@ TEST_F(RoPECPUTestChatGLM, smoke_CompareWithRefs) { CheckNumberOfNodesWithType(compiledModel, "RoPE", 1); } -} // namespace CPULayerTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp index 5c8d1d8e2dd..5c20ec3a644 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/seq_native_order.cpp @@ -2,16 +2,19 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "common_test_utils/node_builders/gru_cell.hpp" +#include "common_test_utils/node_builders/lstm_cell.hpp" +#include "common_test_utils/node_builders/rnn_cell.hpp" #include "shared_test_classes/base/ov_subgraph.hpp" -#include "ov_models/builders.hpp" #include "test_utils/cpu_test_utils.hpp" #include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp" #include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp" using namespace CPUTestUtils; -using namespace ov::test; +using namespace ov::test::utils; -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { enum class SEQ_TYPE { GRU, @@ -34,7 +37,7 @@ using SeqParams = std::tuple; // 'sequence_lengths' input type + InputLayerType>; // 'sequence_lengths' input type class SequenceCPUTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest, public CPUTestsBase { public: @@ -47,7 +50,7 @@ public: bool linearBeforeReset; ov::op::RecurrentSequenceDirection direction; ElementType netPrecision; - ngraph::helpers::InputLayerType seqInType; + InputLayerType seqInType; std::tie(seqType, hidden_size, input_size, inShapeParams, activations, clip, linearBeforeReset, direction, netPrecision, seqInType) = obj.param; @@ -141,7 +144,7 @@ protected: weightShape.push_back(B_shape); ov::PartialShape seq_len_shape(std::vector{bounds[batch_size_pos]}); - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { inputDynamicShapes.push_back(seq_len_shape); } else { OPENVINO_ASSERT(seq_len_shape.is_static()); @@ -160,7 +163,7 @@ protected: if (seqType == SEQ_TYPE::LSTM) { currTS.emplace_back(std::vector{bs, numDirections, hidden_size}); } - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { currTS.emplace_back(std::vector{bs}); } targetStaticShapes.push_back(currTS); @@ -168,7 +171,7 @@ protected: // funciton creation std::vector types(inputDynamicShapes.size(), netPrecision); - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { types.back() = ElementType::i64; } ov::ParameterVector params; @@ -190,45 +193,45 @@ protected: std::shared_ptr seq_node; if (seqType == SEQ_TYPE::GRU) { - seq_node = ngraph::builder::makeGRU(inputs, - weightShape, - hidden_size, - activations, - {}, - {}, - clip, - linearBeforeReset, - true, - direction, - (seqInType == ngraph::helpers::InputLayerType::CONSTANT ? - ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST : - ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); + seq_node = utils::make_gru( + inputs, + weightShape, + hidden_size, + activations, + {}, + {}, + clip, + linearBeforeReset, + true, + direction, + (seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST + : SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); } else if (seqType == SEQ_TYPE::LSTM) { - seq_node = ngraph::builder::makeLSTM(inputs, - weightShape, - hidden_size, - activations, - {}, - {}, - clip, - true, - direction, - (seqInType == ngraph::helpers::InputLayerType::CONSTANT ? - ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST : - ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); + seq_node = utils::make_lstm( + inputs, + weightShape, + hidden_size, + activations, + {}, + {}, + clip, + true, + direction, + (seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST + : SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); } else if (seqType == SEQ_TYPE::RNN) { - seq_node = ngraph::builder::makeRNN(inputs, - weightShape, - hidden_size, - activations, - {}, - {}, - clip, - true, - direction, - (seqInType == ngraph::helpers::InputLayerType::CONSTANT ? - ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST : - ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); + seq_node = utils::make_rnn( + inputs, + weightShape, + hidden_size, + activations, + {}, + {}, + clip, + true, + direction, + (seqInType == InputLayerType::CONSTANT ? SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST + : SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM)); } else { OPENVINO_THROW("Unsupported seq type"); } @@ -254,7 +257,7 @@ protected: const size_t batchSize = targetInputStaticShapes[0][1]; const int64_t maxSeqLen = targetInputStaticShapes[0][0]; - if (seqInType == ngraph::helpers::InputLayerType::PARAMETER) { + if (seqInType == InputLayerType::PARAMETER) { const auto& funcInputs = function->inputs(); const auto& seqLenInput = inputs.find(funcInputs[seqLengthInIdx].get_node_shared_ptr()); if (seqLenInput == inputs.end()) @@ -266,7 +269,7 @@ protected: } private: - ngraph::helpers::InputLayerType seqInType; + InputLayerType seqInType; size_t seqLengthInIdx = 2; }; @@ -326,7 +329,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_lstm_rnn, SequenceCPUTest ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER)), + ::testing::Values(InputLayerType::PARAMETER)), SequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_gru, SequenceCPUTest, @@ -339,7 +342,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_dynamic_gru, SequenceCPUTest, ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::PARAMETER)), + ::testing::Values(InputLayerType::PARAMETER)), SequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_gru, SequenceCPUTest, @@ -352,7 +355,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_gru, SequenceCPUTest, ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT)), + ::testing::Values(InputLayerType::CONSTANT)), SequenceCPUTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_rnn_lstm, SequenceCPUTest, @@ -365,7 +368,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_SequenceCPUTest_static_rnn_lstm, SequenceCPUTest, ::testing::ValuesIn(linearBeforeReset), ::testing::ValuesIn(direction), ::testing::ValuesIn(netPrecisions), - ::testing::Values(ngraph::helpers::InputLayerType::CONSTANT)), + ::testing::Values(InputLayerType::CONSTANT)), SequenceCPUTest::getTestCaseName); -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov diff --git a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp index 1072890e517..4d304f5d190 100644 --- a/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp +++ b/src/plugins/intel_cpu/tests/functional/subgraph_tests/src/static_zero_dims.cpp @@ -2,14 +2,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" #include "ov_models/builders.hpp" -#include -#include "functional_test_utils/skip_tests_config.hpp" +#include "shared_test_classes/base/ov_subgraph.hpp" -using namespace ov::test; - -namespace SubgraphTestsDefinitions { +namespace ov { +namespace test { class StaticZeroDims : public SubgraphBaseTest { protected: @@ -20,26 +18,26 @@ protected: init_input_shapes({inputShapes}); - auto ngPrc = ngraph::element::f32; + auto ngPrc = ov::element::f32; ov::ParameterVector inputParams; for (auto&& shape : inputDynamicShapes) { inputParams.push_back(std::make_shared(ngPrc, shape)); } - auto splitAxisOp = std::make_shared(ngraph::element::i64, ngraph::Shape{}, std::vector{0}); + auto splitAxisOp = std::make_shared(ov::element::i64, ov::Shape{}, std::vector{0}); std::vector splitLenght = {1, 0, 6}; - auto splitLengthsOp = std::make_shared(ngraph::element::i32, ngraph::Shape{splitLenght.size()}, splitLenght); - auto varSplit = std::make_shared(inputParams[0], splitAxisOp, splitLengthsOp); + auto splitLengthsOp = std::make_shared(ov::element::i32, ov::Shape{splitLenght.size()}, splitLenght); + auto varSplit = std::make_shared(inputParams[0], splitAxisOp, splitLengthsOp); - auto relu1 = std::make_shared(varSplit->output(0)); + auto relu1 = std::make_shared(varSplit->output(0)); auto numInRoi = ngraph::builder::makeConstant(ngPrc, {0}, std::vector{}, false); auto expDet = std::make_shared(varSplit->output(1), numInRoi, 10); - auto relu2 = std::make_shared(expDet); + auto relu2 = std::make_shared(expDet); - auto relu3 = std::make_shared(varSplit->output(2)); + auto relu3 = std::make_shared(varSplit->output(2)); - ngraph::NodeVector results{relu1, relu2, relu3}; - function = std::make_shared(results, inputParams, "StaticZeroDims"); + ov::NodeVector results{relu1, relu2, relu3}; + function = std::make_shared(results, inputParams, "StaticZeroDims"); } void compare(const std::vector &expected, const std::vector &actual) override { @@ -59,4 +57,5 @@ TEST_F(StaticZeroDims, smoke_CompareWithRefs) { run(); } -} // namespace SubgraphTestsDefinitions +} // namespace test +} // namespace ov