diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp index d4d87b825e7..837844e4fcf 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/adaptive_pooling.cpp @@ -4,55 +4,62 @@ #include -#include "single_layer_tests/adaptive_pooling.hpp" +#include "single_op_tests/adaptive_pooling.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +namespace { +using ov::test::AdaPoolLayerTest; - -const std::vector netPRCs = { - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::FP32 +const std::vector types = { + ov::element::f16, + ov::element::f32 }; -const auto AdaPool3DCases = ::testing::Combine( - ::testing::ValuesIn( - std::vector> { - { 1, 2, 1}, - { 1, 1, 3 }, - { 3, 17, 5 }}), +const std::vector> input_shapes_3d_static = { + {{ 1, 2, 1}}, + {{ 1, 1, 3 }}, + {{ 3, 17, 5 }} +}; + +const auto ada_pool_3d_cases = ::testing::Combine( + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_3d_static)), ::testing::ValuesIn(std::vector>{ {1}, {3}, {5} }), ::testing::ValuesIn(std::vector{"max", "avg"}), - ::testing::ValuesIn(netPRCs), + ::testing::ValuesIn(types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); -INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool3D, AdaPoolLayerTest, AdaPool3DCases, AdaPoolLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool3D, AdaPoolLayerTest, ada_pool_3d_cases, AdaPoolLayerTest::getTestCaseName); -const auto AdaPool4DCases = ::testing::Combine( - ::testing::ValuesIn( - std::vector> { - { 1, 2, 1, 2}, - { 1, 1, 3, 2}, - { 3, 17, 5, 1}}), +const std::vector> input_shapes_4d_static = { + {{ 1, 2, 1, 2 }}, + {{ 1, 1, 3, 2 }}, + {{ 3, 17, 5, 1 }} +}; + +const auto ada_pool_4d_cases = ::testing::Combine( + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_4d_static)), ::testing::ValuesIn(std::vector>{ {1, 1}, {3, 5}, {5, 5} }), ::testing::ValuesIn(std::vector{"max", "avg"}), - ::testing::ValuesIn(netPRCs), + ::testing::ValuesIn(types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); -INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool4D, AdaPoolLayerTest, AdaPool4DCases, AdaPoolLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool4D, AdaPoolLayerTest, ada_pool_4d_cases, AdaPoolLayerTest::getTestCaseName); -const auto AdaPool5DCases = ::testing::Combine( - ::testing::ValuesIn( - std::vector> { - { 1, 2, 1, 2, 2}, - { 1, 1, 3, 2, 3}, - { 3, 17, 5, 1, 2}}), +const std::vector> input_shapes_5d_static = { + {{ 1, 2, 1, 2, 2 }}, + {{ 1, 1, 3, 2, 3 }}, + {{ 3, 17, 5, 1, 2 }} +}; + +const auto ada_pool_5d_cases = ::testing::Combine( + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_5d_static)), ::testing::ValuesIn(std::vector>{ {1, 1, 1}, {3, 5, 3}, {5, 5, 5} }), ::testing::ValuesIn(std::vector{"max", "avg"}), - ::testing::ValuesIn(netPRCs), + ::testing::ValuesIn(types), ::testing::Values(ov::test::utils::DEVICE_CPU) ); -INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool5D, AdaPoolLayerTest, AdaPool5DCases, AdaPoolLayerTest::getTestCaseName); +INSTANTIATE_TEST_SUITE_P(smoke_TestsAdaPool5D, AdaPoolLayerTest, ada_pool_5d_cases, AdaPoolLayerTest::getTestCaseName); +} // namespace diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp index 467e32c2668..a7850b4e943 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_norm.cpp @@ -4,14 +4,14 @@ #include -#include "single_layer_tests/batch_norm.hpp" - -using namespace LayerTestsDefinitions; +#include "single_op_tests/batch_norm.hpp" namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16 +using ov::test::BatchNormLayerTest; + +const std::vector model_type = { + ov::element::f32, + ov::element::f16 }; const std::vector epsilon = { @@ -20,30 +20,26 @@ const std::vector epsilon = { 1e-5, 1e-4 }; -const std::vector> inputShapes = { - {1, 3}, - {2, 5}, - {1, 3, 10}, - {1, 3, 1, 1}, - {2, 5, 4, 4}, +const std::vector> input_shapes_static = { + {{1, 3}}, + {{2, 5}}, + {{1, 3, 10}}, + {{1, 3, 1, 1}}, + {{2, 5, 4, 4}}, }; -const auto batchNormParams = testing::Combine( +const auto batch_norm_params = testing::Combine( testing::ValuesIn(epsilon), - testing::ValuesIn(netPrecisions), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Precision::UNSPECIFIED), - testing::Values(InferenceEngine::Layout::ANY), - testing::Values(InferenceEngine::Layout::ANY), - testing::ValuesIn(inputShapes), + testing::ValuesIn(model_type), + testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_static)), testing::Values(ov::test::utils::DEVICE_CPU) ); INSTANTIATE_TEST_SUITE_P( smoke_BatchNorm, BatchNormLayerTest, - batchNormParams, + batch_norm_params, BatchNormLayerTest::getTestCaseName ); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp index 2883915a910..dc7c4f41afb 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/batch_to_space.cpp @@ -2,23 +2,20 @@ // SPDX-License-Identifier: Apache-2.0 // -#include - -#include "single_layer_tests/batch_to_space.hpp" +#include "single_op_tests/batch_to_space.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; - namespace { +using ov::test::BatchToSpaceLayerTest; -const std::vector net_precisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::I32 +const std::vector net_types = { + ov::element::f32, + ov::element::i32 }; -const std::vector> data_shapes_2D = { - {12, 4}, - {48, 3} +const std::vector> data_shapes_2D_static = { + {{12, 4}}, + {{48, 3}} }; const std::vector> block_shapes_2D = { @@ -35,12 +32,8 @@ const auto batch_to_space_2d_tests = ::testing::Combine( ::testing::ValuesIn(block_shapes_2D), ::testing::ValuesIn(crops_2D), ::testing::ValuesIn(crops_2D), - ::testing::ValuesIn(data_shapes_2D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_2D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P( @@ -49,10 +42,10 @@ INSTANTIATE_TEST_SUITE_P( batch_to_space_2d_tests, BatchToSpaceLayerTest::getTestCaseName); -const std::vector> data_shapes_4D = { - {4, 1, 2, 2}, - {4, 3, 2, 2}, - {8, 1, 3, 2} +const std::vector> data_shapes_4D_static = { + {{4, 1, 2, 2}}, + {{4, 3, 2, 2}}, + {{8, 1, 3, 2}} }; const std::vector> block_shapes_4D = { @@ -76,24 +69,16 @@ const auto batch_to_space_4d_spatial_dims_tests = ::testing::Combine( ::testing::Values(block_shapes_4D[0]), ::testing::ValuesIn(crops_begin_4D), ::testing::ValuesIn(crops_end_4D), - ::testing::ValuesIn(data_shapes_4D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_4D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); const auto batch_to_space_4d_channel_dim_tests = ::testing::Combine( ::testing::Values(block_shapes_4D[1]), ::testing::Values(crops_begin_4D[0]), ::testing::Values(crops_end_4D[0]), - ::testing::ValuesIn(data_shapes_4D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_4D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P( @@ -108,8 +93,8 @@ INSTANTIATE_TEST_SUITE_P( batch_to_space_4d_channel_dim_tests, BatchToSpaceLayerTest::getTestCaseName); -const std::vector> data_shapes_5D = { - {12, 1, 2, 1, 2} +const std::vector> data_shapes_5D_static = { + {{12, 1, 2, 1, 2}} }; const std::vector> block_shapes_5D = { @@ -133,24 +118,16 @@ const auto batch_to_space_5d_spatial_dims_tests = ::testing::Combine( ::testing::Values(block_shapes_5D[0]), ::testing::ValuesIn(crops_begin_5D), ::testing::ValuesIn(crops_end_5D), - ::testing::ValuesIn(data_shapes_5D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_5D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); const auto batch_to_space_5d_channel_dim_tests = ::testing::Combine( ::testing::Values(block_shapes_5D[1]), ::testing::Values(crops_begin_5D[0]), ::testing::Values(crops_end_5D[0]), - ::testing::ValuesIn(data_shapes_5D), - ::testing::ValuesIn(net_precisions), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Precision::UNSPECIFIED), - ::testing::Values(InferenceEngine::Layout::ANY), - ::testing::Values(InferenceEngine::Layout::ANY), + ::testing::ValuesIn(ov::test::static_shapes_to_test_representation(data_shapes_5D_static)), + ::testing::ValuesIn(net_types), ::testing::Values(ov::test::utils::DEVICE_CPU)); INSTANTIATE_TEST_SUITE_P( diff --git a/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp b/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp index f4d41b2b122..3caf98b7566 100644 --- a/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp +++ b/src/tests/functional/plugin/shared/include/single_layer_tests/adaptive_pooling.hpp @@ -9,7 +9,7 @@ namespace LayerTestsDefinitions { TEST_P(AdaPoolLayerTest, CompareWithRefs) { -Run(); + Run(); } } // namespace LayerTestsDefinitions diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp new file mode 100644 index 00000000000..74b49d5f663 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/adaptive_pooling.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/adaptive_pooling.hpp" + +namespace ov { +namespace test { +TEST_P(AdaPoolLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp new file mode 100644 index 00000000000..d7cad68321c --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/batch_norm.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/batch_norm.hpp" + +namespace ov { +namespace test { +TEST_P(BatchNormLayerTest, Inference) { + run(); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp new file mode 100644 index 00000000000..d894fd039ab --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/batch_to_space.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/batch_to_space.hpp" + +namespace ov { +namespace test { + +TEST_P(BatchToSpaceLayerTest, Inference) { + run(); +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp new file mode 100644 index 00000000000..5f3e5932a41 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/adaptive_pooling.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using adapoolParams = std::tuple< + std::vector, // feature map shape + std::vector, // pooled spatial shape + std::string, // pooling mode + ov::element::Type, // model type + std::string>; // device name + +class AdaPoolLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp new file mode 100644 index 00000000000..f28b24d088a --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_norm.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +typedef std::tuple< + double, // epsilon + ov::element::Type, // Model type + std::vector, // Input shape + std::string // Target device name +> BatchNormLayerTestParams; + +class BatchNormLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); +protected: + void SetUp() override; +}; + +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp new file mode 100644 index 00000000000..07ac5c21542 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/batch_to_space.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using batchToSpaceParamsTuple = typename std::tuple< + std::vector, // block shape + std::vector, // crops begin + std::vector, // crops end + std::vector, // Input shapes + ov::element::Type, // Model type + std::string>; // Device name>; + +class BatchToSpaceLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseTest { +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); + +protected: + void SetUp() override; +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp index 0e29e65f22c..d3eb67f907d 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.hpp @@ -26,10 +26,8 @@ typedef std::tuple< class ComparisonLayerTest : public testing::WithParamInterface, virtual public ov::test::SubgraphBaseTest { - ngraph::helpers::ComparisonTypes comparison_op_type; protected: void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; public: static std::string getTestCaseName(const testing::TestParamInfo &obj); }; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp index 0b2b053cd48..507739669a2 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/gru_sequence.hpp @@ -30,9 +30,6 @@ public: protected: void SetUp() override; - void generate_inputs(const std::vector& targetInputStaticShapes) override; - ov::test::utils::SequenceTestsMode m_mode; - int64_t m_max_seq_len = 0; }; } // namespace test } // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp index 369b6dedcd7..7a7e2bc4a89 100644 --- a/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp +++ b/src/tests/functional/shared_test_classes/src/base/utils/generate_inputs.cpp @@ -963,6 +963,51 @@ ov::runtime::Tensor generate(const return tensor; } +namespace comparison { +void fill_tensor(ov::Tensor& tensor) { + auto data_ptr = static_cast(tensor.data()); + auto data_ptr_int = static_cast(tensor.data()); + auto range = tensor.get_size(); + auto start = -static_cast(range) / 2.f; + testing::internal::Random random(1); + for (size_t i = 0; i < range; i++) { + if (i % 7 == 0) { + data_ptr[i] = std::numeric_limits::infinity(); + } else if (i % 7 == 1) { + data_ptr[i] = -std::numeric_limits::infinity(); + } else if (i % 7 == 2) { + data_ptr_int[i] = 0x7F800000 + random.Generate(range); + } else if (i % 7 == 3) { + data_ptr[i] = std::numeric_limits::quiet_NaN(); + } else if (i % 7 == 5) { + data_ptr[i] = -std::numeric_limits::quiet_NaN(); + } else { + data_ptr[i] = start + static_cast(random.Generate(range)); + } + } +} +} // namespace comparison + +ov::runtime::Tensor generate(const + std::shared_ptr& node, + size_t port, + const ov::element::Type& elemType, + const ov::Shape& targetShape) { + ov::Tensor tensor(elemType, targetShape); + comparison::fill_tensor(tensor); + return tensor; +} + +ov::runtime::Tensor generate(const + std::shared_ptr& node, + size_t port, + const ov::element::Type& elemType, + const ov::Shape& targetShape) { + ov::Tensor tensor{elemType, targetShape}; + comparison::fill_tensor(tensor); + return tensor; +} + template ov::runtime::Tensor generateInput(const std::shared_ptr& node, size_t port, diff --git a/src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp b/src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp new file mode 100644 index 00000000000..17a848c8475 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/adaptive_pooling.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/adaptive_pooling.hpp" + +namespace ov { +namespace test { + +std::string AdaPoolLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector shapes; + std::vector pooled_spatial_shape; + + std::string pooling_mode; + ov::element::Type model_type; + std::string target_device; + std::tie(shapes, pooled_spatial_shape, pooling_mode, model_type, target_device) = obj.param; + + std::ostringstream result; + + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "pooled_spatial_shape=" << ov::test::utils::vec2str(pooled_spatial_shape) << "_"; + result << "mode=" << pooling_mode << "_"; + result << "IT=" << model_type.get_type_name() << "_"; + result << "dev=" << target_device; + return result.str(); +} + +void AdaPoolLayerTest::SetUp() { + std::vector shapes; + std::vector pooled_spatial_shape; + std::string pooling_mode; + ov::element::Type model_type; + std::tie(shapes, pooled_spatial_shape, pooling_mode, model_type, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + ov::ParameterVector params{std::make_shared(model_type, inputDynamicShapes.front())}; + + ov::Shape pooled_shape = {pooled_spatial_shape.size()}; + auto pooled_param = std::make_shared(ov::element::i32, pooled_shape, pooled_spatial_shape); + + // we cannot create abstract Op to use polymorphism + auto adapoolMax = std::make_shared(params[0], pooled_param, ov::element::i32); + auto adapoolAvg = std::make_shared(params[0], pooled_param); + + function = (pooling_mode == "max" ? + std::make_shared(adapoolMax->outputs(), params, "AdaPoolMax") : + std::make_shared(adapoolAvg->outputs(), params, "AdaPoolAvg")); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp b/src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp new file mode 100644 index 00000000000..f2df32ba504 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/batch_norm.cpp @@ -0,0 +1,61 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/batch_norm.hpp" + +#include "common_test_utils/ov_tensor_utils.hpp" + +namespace ov { +namespace test { +std::string BatchNormLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + ov::element::Type model_type; + std::vector shapes; + double epsilon; + std::string target_device; + std::tie(epsilon, model_type, shapes, target_device) = obj.param; + + std::ostringstream result; + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "inT=" << model_type.get_type_name() << "_"; + result << "epsilon=" << epsilon << "_"; + result << "trgDev=" << target_device; + return result.str(); +} + +void BatchNormLayerTest::SetUp() { + ov::element::Type model_type; + std::vector shapes; + double epsilon; + std::tie(epsilon, model_type, shapes, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + ov::ParameterVector params {std::make_shared(model_type, inputDynamicShapes.front())}; + + auto constant_shape = ov::Shape{params[0]->get_shape().at(1)}; + auto gamma_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 1, 0); + auto gamma = std::make_shared(gamma_tensor); + + auto beta_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 1, 0); + auto beta = std::make_shared(beta_tensor); + + auto mean_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 1, 0); + auto mean = std::make_shared(mean_tensor); + + // Fill the vector for variance with positive values + auto variance_tensor = ov::test::utils::create_and_fill_tensor(model_type, constant_shape, 10, 0); + auto variance = std::make_shared(variance_tensor); + auto batch_norm = std::make_shared(params[0], gamma, beta, mean, variance, epsilon); + + function = std::make_shared(ov::OutputVector{batch_norm}, params, "BatchNormInference"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp b/src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp new file mode 100644 index 00000000000..b814d07304d --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/batch_to_space.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/batch_to_space.hpp" + +namespace ov { +namespace test { +std::string BatchToSpaceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { + std::vector shapes; + std::vector block_shape, crops_begin, crops_end; + ov::element::Type model_type; + std::string target_name; + std::tie(block_shape, crops_begin, crops_end, shapes, model_type, target_name) = obj.param; + std::ostringstream result; + result << "IS=("; + for (const auto& shape : shapes) { + result << ov::test::utils::partialShape2str({shape.first}) << "_"; + } + result << ")_TS=("; + for (const auto& shape : shapes) { + for (const auto& item : shape.second) { + result << ov::test::utils::vec2str(item) << "_"; + } + } + result << "inT=" << model_type.get_type_name() << "_"; + result << "BS=" << ov::test::utils::vec2str(block_shape) << "_"; + result << "CB=" << ov::test::utils::vec2str(crops_begin) << "_"; + result << "CE=" << ov::test::utils::vec2str(crops_end) << "_"; + result << "trgDev=" << target_name << "_"; + return result.str(); +} + +void BatchToSpaceLayerTest::SetUp() { + std::vector shapes; + std::vector block_shape, crops_begin, crops_end; + ov::element::Type model_type; + std::tie(block_shape, crops_begin, crops_end, shapes, model_type, targetDevice) = this->GetParam(); + init_input_shapes(shapes); + + ov::ParameterVector params{std::make_shared(model_type, inputDynamicShapes.front())}; + + auto const_shape = ov::Shape{inputDynamicShapes.front().size()}; + auto block_shape_node = std::make_shared(ov::element::i64, const_shape, block_shape.data()); + auto crops_begin_node = std::make_shared(ov::element::i64, const_shape, crops_begin.data()); + auto crops_end_node = std::make_shared(ov::element::i64, const_shape, crops_end.data()); + + auto b2s = std::make_shared(params[0], block_shape_node, crops_begin_node, crops_end_node); + ov::OutputVector results{std::make_shared(b2s)}; + function = std::make_shared(results, params, "BatchToSpace"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp b/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp index 7dacd12bc9d..f7ea71c95bb 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/comparison.cpp @@ -51,6 +51,7 @@ void ComparisonLayerTest::SetUp() { InputLayerType second_input_type; std::map additional_config; ov::element::Type model_type; + ngraph::helpers::ComparisonTypes comparison_op_type; std::tie(shapes, comparison_op_type, second_input_type, @@ -74,40 +75,5 @@ void ComparisonLayerTest::SetUp() { auto comparisonNode = ngraph::builder::makeComparison(inputs[0], second_input, comparison_op_type); function = std::make_shared(comparisonNode, inputs, "Comparison"); } - -void ComparisonLayerTest::generate_inputs(const std::vector& target_input_static_shapes) { - if (comparison_op_type == ComparisonTypes::IS_FINITE || comparison_op_type == ComparisonTypes::IS_NAN) { - inputs.clear(); - auto params = function->get_parameters(); - OPENVINO_ASSERT(target_input_static_shapes.size() >= params.size()); - for (int i = 0; i < params.size(); i++) { - ov::Tensor tensor(params[i]->get_element_type(), target_input_static_shapes[i]); - auto data_ptr = static_cast(tensor.data()); - auto data_ptr_int = static_cast(tensor.data()); - auto range = tensor.get_size(); - auto start = -static_cast(range) / 2.f; - testing::internal::Random random(1); - for (size_t i = 0; i < range; i++) { - if (i % 7 == 0) { - data_ptr[i] = std::numeric_limits::infinity(); - } else if (i % 7 == 1) { - data_ptr[i] = -std::numeric_limits::infinity(); - } else if (i % 7 == 2) { - data_ptr_int[i] = 0x7F800000 + random.Generate(range); - } else if (i % 7 == 3) { - data_ptr[i] = std::numeric_limits::quiet_NaN(); - } else if (i % 7 == 5) { - data_ptr[i] = -std::numeric_limits::quiet_NaN(); - } else { - data_ptr[i] = start + static_cast(random.Generate(range)); - } - } - inputs.insert({params[i], tensor}); - } - } else { - SubgraphBaseTest::generate_inputs(target_input_static_shapes); - } -} - } // namespace test } // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp index 54e7140830d..e98b04c5aa8 100644 --- a/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp +++ b/src/tests/functional/shared_test_classes/src/single_op/gru_sequence.cpp @@ -61,7 +61,8 @@ void GRUSequenceTest::SetUp() { bool linear_before_reset; ov::op::RecurrentSequenceDirection direction; InputLayerType wbr_type; - std::tie(m_mode, shapes, activations, clip, linear_before_reset, direction, wbr_type, + ov::test::utils::SequenceTestsMode mode; + std::tie(mode, shapes, activations, clip, linear_before_reset, direction, wbr_type, inType, targetDevice) = this->GetParam(); outType = inType; init_input_shapes(shapes); @@ -87,15 +88,15 @@ void GRUSequenceTest::SetUp() { const auto& b_shape = ov::Shape{num_directions, (linear_before_reset ? 4 : 3) * hidden_size}; std::shared_ptr seq_lengths_node; - if (m_mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { + if (mode == SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_PARAM || + mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM) { auto param = std::make_shared(ov::element::i64, inputDynamicShapes[2]); param->set_friendly_name("seq_lengths"); params.push_back(param); seq_lengths_node = param; - } else if (m_mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { + } else if (mode == SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) { auto tensor = ov::test::utils::create_and_fill_tensor(ov::element::i64, targetStaticShapes[0][2], seq_lengths, 0); seq_lengths_node = std::make_shared(tensor); } else { @@ -131,9 +132,9 @@ void GRUSequenceTest::SetUp() { std::make_shared(gru_sequence->output(1))}; function = std::make_shared(results, params, "gru_sequence"); - bool is_pure_sequence = (m_mode == SequenceTestsMode::PURE_SEQ || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || - m_mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); + bool is_pure_sequence = (mode == SequenceTestsMode::PURE_SEQ || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM || + mode == SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST); if (!is_pure_sequence) { ov::pass::Manager manager; if (direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL) @@ -147,15 +148,5 @@ void GRUSequenceTest::SetUp() { EXPECT_EQ(ti_found, false); } } - -void GRUSequenceTest::generate_inputs(const std::vector& target_input_static_shapes) { - inputs.clear(); - auto params = function->get_parameters(); - OPENVINO_ASSERT(target_input_static_shapes.size() >= params.size()); - for (int i = 0; i < params.size(); i++) { - auto tensor = ov::test::utils::create_and_fill_tensor(params[i]->get_element_type(), target_input_static_shapes[i], m_max_seq_len, 0); - inputs.insert({params[i], tensor}); - } -} } // namespace test } // namespace ov