From 04c766e9f17061ee1c9d51c06a7db19f8c5c895b Mon Sep 17 00:00:00 2001 From: Vitaliy Urusovskij Date: Wed, 25 Oct 2023 13:37:36 +0400 Subject: [PATCH] `ReverseSequence`, `RNNCell`, `Reverse` to API2.0 (#20569) * `ReverseSequence` to API2.0 * `RNNCell` to API2.0 * `Reverse` GPU test to API2.0 * Alignment fix --- .../single_layer_tests/reverse_sequence.cpp | 44 +++---- .../single_layer_tests/rnn_cell.cpp | 16 +-- .../single_layer_tests/reverse.cpp | 79 ++++++------- .../single_layer_tests/rnn_cell.cpp | 18 +-- .../skip_tests_config.cpp | 2 + .../include/single_op_tests/reverse.hpp | 15 +++ .../single_op_tests/reverse_sequence.hpp | 15 +++ .../include/single_op_tests/rnn_cell.hpp | 15 +++ .../shared_test_classes/single_op/reverse.hpp | 28 +++++ .../single_op/reverse_sequence.hpp | 36 ++++++ .../single_op/rnn_cell.hpp | 42 +++++++ .../src/single_op/reverse.cpp | 49 ++++++++ .../src/single_op/reverse_sequence.cpp | 59 ++++++++++ .../src/single_op/rnn_cell.cpp | 109 ++++++++++++++++++ 14 files changed, 447 insertions(+), 80 deletions(-) create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/reverse.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/reverse_sequence.hpp create mode 100644 src/tests/functional/plugin/shared/include/single_op_tests/rnn_cell.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse_sequence.hpp create mode 100644 src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/rnn_cell.hpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/reverse.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/reverse_sequence.cpp create mode 100644 src/tests/functional/shared_test_classes/src/single_op/rnn_cell.cpp diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reverse_sequence.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reverse_sequence.cpp index d8a9fc23c49..fd1c3354f0b 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reverse_sequence.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/reverse_sequence.cpp @@ -4,43 +4,43 @@ #include -#include "single_layer_tests/reverse_sequence.hpp" +#include "single_op_tests/reverse_sequence.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::ReverseSequenceLayerTest; namespace { -const std::vector netPrecisions = { - InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::U8, - InferenceEngine::Precision::I8, - InferenceEngine::Precision::U16, - InferenceEngine::Precision::I32 +const std::vector model_types = { + ov::element::f32, + ov::element::f16, + ov::element::u8, + ov::element::i8, + ov::element::u16, + ov::element::i32 }; -const std::vector batchAxisIndices = { 0L }; +const std::vector batch_axis_indices = { 0L }; -const std::vector seqAxisIndices = { 1L }; +const std::vector seq_axis_indices = { 1L }; -const std::vector> inputShapes = { {3, 10} }; //, 10, 20 +const std::vector> input_shapes = { {3, 10} }; //, 10, 20 -const std::vector> reversSeqLengthsVecShapes = { {3} }; +const std::vector> reverse_seq_shapes = { {3} }; -const std::vector secondaryInputTypes = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER +const std::vector secondary_input_types = { + ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER }; INSTANTIATE_TEST_SUITE_P(smoke_ReverseSequence, ReverseSequenceLayerTest, ::testing::Combine( - ::testing::ValuesIn(batchAxisIndices), - ::testing::ValuesIn(seqAxisIndices), - ::testing::ValuesIn(inputShapes), - ::testing::ValuesIn(reversSeqLengthsVecShapes), - ::testing::ValuesIn(secondaryInputTypes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(batch_axis_indices), + ::testing::ValuesIn(seq_axis_indices), + ::testing::ValuesIn(input_shapes), + ::testing::ValuesIn(reverse_seq_shapes), + ::testing::ValuesIn(secondary_input_types), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_CPU)), ReverseSequenceLayerTest::getTestCaseName); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp index cedd5442e41..b0b2ea664e4 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp @@ -4,10 +4,10 @@ #include -#include "single_layer_tests/rnn_cell.hpp" +#include "single_op_tests/rnn_cell.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::RNNCellTest; namespace { std::vector should_decompose{false, true}; @@ -16,12 +16,12 @@ namespace { std::vector input_size{1, 30}; std::vector> activations = {{"relu"}, {"sigmoid"}, {"tanh"}}; std::vector clip = {0.f, 0.7f}; - std::vector layer_types = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER + std::vector layer_types = { + ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER }; - std::vector netPrecisions = {InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16}; + std::vector model_types = {ov::element::f32, + ov::element::f16}; INSTANTIATE_TEST_SUITE_P(smoke_RNNCellCommon, RNNCellTest, ::testing::Combine( @@ -34,7 +34,7 @@ namespace { ::testing::ValuesIn(layer_types), ::testing::ValuesIn(layer_types), ::testing::ValuesIn(layer_types), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_CPU)), RNNCellTest::getTestCaseName); diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/reverse.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/reverse.cpp index a14827a678a..453e8a7cbd0 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/reverse.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/reverse.cpp @@ -2,92 +2,89 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "single_layer_tests/reverse.hpp" - -#include - +#include "single_op_tests/reverse.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::ReverseLayerTest; namespace { -const std::vector netPrecisions = {InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16, - InferenceEngine::Precision::I32, - InferenceEngine::Precision::I64, - InferenceEngine::Precision::I8, - InferenceEngine::Precision::U8}; +const std::vector model_types = {ov::element::f32, + ov::element::f16, + ov::element::i32, + ov::element::i64, + ov::element::i8, + ov::element::u8}; -const std::vector> inputShapes1D = {{10}}; -const std::vector> indices1D = {{0}}; +const std::vector> input_shapes_1D = {{10}}; +const std::vector> indices_1D = {{0}}; const std::vector modes = {"index", "mask"}; INSTANTIATE_TEST_SUITE_P(smoke_Reverse1D, ReverseLayerTest, - ::testing::Combine(::testing::ValuesIn(inputShapes1D), - ::testing::ValuesIn(indices1D), + ::testing::Combine(::testing::ValuesIn(input_shapes_1D), + ::testing::ValuesIn(indices_1D), ::testing::ValuesIn(modes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), ReverseLayerTest::getTestCaseName); -const std::vector> inputShapes2D = {{3, 4}, {1, 3}}; -const std::vector> indices2D = {{0}, {1}}; +const std::vector> input_shapes_2D = {{3, 4}, {1, 3}}; +const std::vector> indices_2D = {{0}, {1}}; INSTANTIATE_TEST_SUITE_P(smoke_Reverse2D, ReverseLayerTest, - ::testing::Combine(::testing::ValuesIn(inputShapes2D), - ::testing::ValuesIn(indices2D), + ::testing::Combine(::testing::ValuesIn(input_shapes_2D), + ::testing::ValuesIn(indices_2D), ::testing::ValuesIn(modes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), ReverseLayerTest::getTestCaseName); -const std::vector> inputShapes3D = {{1, 3, 4}, {2, 5, 6}}; -const std::vector> indices3D = {{0}, {0, 1}, {0, 2}}; +const std::vector> input_shapes_3D = {{1, 3, 4}, {2, 5, 6}}; +const std::vector> indices_3D = {{0}, {0, 1}, {0, 2}}; INSTANTIATE_TEST_SUITE_P(smoke_Reverse3D, ReverseLayerTest, - ::testing::Combine(::testing::ValuesIn(inputShapes3D), - ::testing::ValuesIn(indices3D), + ::testing::Combine(::testing::ValuesIn(input_shapes_3D), + ::testing::ValuesIn(indices_3D), ::testing::ValuesIn(modes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), ReverseLayerTest::getTestCaseName); -const std::vector> inputShapes4D = {{1, 2, 3, 4}, {1, 2, 5, 6}}; -const std::vector> indices4D = {{1}, {1, 2}, {1, 3}}; +const std::vector> input_shapes_4D = {{1, 2, 3, 4}, {1, 2, 5, 6}}; +const std::vector> indices_4D = {{1}, {1, 2}, {1, 3}}; INSTANTIATE_TEST_SUITE_P(smoke_Reverse4D, ReverseLayerTest, - ::testing::Combine(::testing::ValuesIn(inputShapes4D), - ::testing::ValuesIn(indices4D), + ::testing::Combine(::testing::ValuesIn(input_shapes_4D), + ::testing::ValuesIn(indices_4D), ::testing::ValuesIn(modes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), ReverseLayerTest::getTestCaseName); -const std::vector> inputShapes5D = {{1, 1, 4, 3, 3}}; -const std::vector> indices5D = {{2}, {2, 3}, {2, 4}}; +const std::vector> input_shapes_5D = {{1, 1, 4, 3, 3}}; +const std::vector> indices_5D = {{2}, {2, 3}, {2, 4}}; INSTANTIATE_TEST_SUITE_P(smoke_Reverse5D, ReverseLayerTest, - ::testing::Combine(::testing::ValuesIn(inputShapes5D), - ::testing::ValuesIn(indices5D), + ::testing::Combine(::testing::ValuesIn(input_shapes_5D), + ::testing::ValuesIn(indices_5D), ::testing::ValuesIn(modes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), ReverseLayerTest::getTestCaseName); -const std::vector> inputShapes6D = {{1, 1, 4, 3, 3, 3}}; -const std::vector> indices6D = {{2}, {1, 3}, {3, 5}, {1, 4, 5}}; +const std::vector> input_shapes_6D = {{1, 1, 4, 3, 3, 3}}; +const std::vector> indices_6D = {{2}, {1, 3}, {3, 5}, {1, 4, 5}}; INSTANTIATE_TEST_SUITE_P(smoke_Reverse6D, ReverseLayerTest, - ::testing::Combine(::testing::ValuesIn(inputShapes6D), - ::testing::ValuesIn(indices6D), + ::testing::Combine(::testing::ValuesIn(input_shapes_6D), + ::testing::ValuesIn(indices_6D), ::testing::ValuesIn(modes), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), ReverseLayerTest::getTestCaseName); diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp index a471761bc9d..b721d406aac 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/single_layer_tests/rnn_cell.cpp @@ -4,10 +4,10 @@ #include -#include "single_layer_tests/rnn_cell.hpp" +#include "single_op_tests/rnn_cell.hpp" #include "common_test_utils/test_constants.hpp" -using namespace LayerTestsDefinitions; +using ov::test::RNNCellTest; namespace { std::vector should_decompose{false, true}; @@ -16,14 +16,14 @@ namespace { std::vector input_size{1, 30}; std::vector> activations = {{"relu"}, {"sigmoid"}, {"tanh"}}; std::vector clip = {0.f, 0.7f}; - std::vector layer_types = { - ngraph::helpers::InputLayerType::CONSTANT, - ngraph::helpers::InputLayerType::PARAMETER + std::vector layer_types = { + ov::test::utils::InputLayerType::CONSTANT, + ov::test::utils::InputLayerType::PARAMETER }; - std::vector netPrecisions = {InferenceEngine::Precision::FP32, - InferenceEngine::Precision::FP16}; + std::vector model_types = {ov::element::f32, + ov::element::f16}; - INSTANTIATE_TEST_SUITE_P(RNNCellCommon, RNNCellTest, + INSTANTIATE_TEST_SUITE_P(smoke_RNNCellCommon, RNNCellTest, ::testing::Combine( ::testing::ValuesIn(should_decompose), ::testing::ValuesIn(batch), @@ -34,7 +34,7 @@ namespace { ::testing::ValuesIn(layer_types), ::testing::ValuesIn(layer_types), ::testing::ValuesIn(layer_types), - ::testing::ValuesIn(netPrecisions), + ::testing::ValuesIn(model_types), ::testing::Values(ov::test::utils::DEVICE_GPU)), RNNCellTest::getTestCaseName); diff --git a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp index 25b679cf22c..23699ee8aa7 100644 --- a/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp +++ b/src/plugins/intel_gpu/tests/functional/shared_tests_instances/skip_tests_config.cpp @@ -117,5 +117,7 @@ std::vector disabledTestPatterns() { R"(.*MemoryDynamicBatch.*)", // Issue: 123493 R"(.*GroupNormalizationTest.*CompareWithRefs.*NetType=f16.*)", + // Issue: 123507 + R"(.*ReverseLayerTest.*mask.*f16.*)", }; } diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/reverse.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/reverse.hpp new file mode 100644 index 00000000000..be9181cce17 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/reverse.hpp @@ -0,0 +1,15 @@ +// Copyright (C) 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/single_op/reverse.hpp" + +namespace ov { +namespace test { +TEST_P(ReverseLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/reverse_sequence.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/reverse_sequence.hpp new file mode 100644 index 00000000000..f68be26ebaf --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/reverse_sequence.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/reverse_sequence.hpp" + +namespace ov { +namespace test { +TEST_P(ReverseSequenceLayerTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/plugin/shared/include/single_op_tests/rnn_cell.hpp b/src/tests/functional/plugin/shared/include/single_op_tests/rnn_cell.hpp new file mode 100644 index 00000000000..58336cac837 --- /dev/null +++ b/src/tests/functional/plugin/shared/include/single_op_tests/rnn_cell.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/rnn_cell.hpp" + +namespace ov { +namespace test { +TEST_P(RNNCellTest, Inference) { + run(); +}; +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse.hpp new file mode 100644 index 00000000000..c7b36227f81 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse.hpp @@ -0,0 +1,28 @@ +// Copyright (C) 2022 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "shared_test_classes/base/ov_subgraph.hpp" + +namespace ov { +namespace test { +using reverseParams = std::tuple< + std::vector, // Input shape + std::vector, // Axes + std::string, // Mode + ov::element::Type, // Model type + ov::test::TargetDevice // Device name +>; + +class ReverseLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +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/reverse_sequence.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse_sequence.hpp new file mode 100644 index 00000000000..a97e7eac453 --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/reverse_sequence.hpp @@ -0,0 +1,36 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { +using ReverseSequenceParamsTuple = typename std::tuple< + int64_t, // Index of the batch dimension + int64_t, // Index of the sequence dimension + std::vector, // Input shapes + std::vector, // Shape of the input vector with sequence lengths to be reversed + ov::test::utils::InputLayerType, // Secondary input type + ov::element::Type, // Model type + ov::test::TargetDevice // Device name +>; + +class ReverseSequenceLayerTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +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/rnn_cell.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/rnn_cell.hpp new file mode 100644 index 00000000000..e7d2bfe1f5b --- /dev/null +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/rnn_cell.hpp @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright (C) 2018-2023 Intel Corporation +// + +#pragma once + +#include +#include +#include +#include + +#include "shared_test_classes/base/ov_subgraph.hpp" +#include "common_test_utils/test_enums.hpp" + +namespace ov { +namespace test { + +using RNNCellParams = typename std::tuple< + bool, // Use decompose to sub-ops transformation + size_t, // Batch + size_t, // Hidden size + size_t, // Input size + std::vector, // Activations + float, // Clip + ov::test::utils::InputLayerType, // W input type (Constant or Parameter) + ov::test::utils::InputLayerType, // R input type (Constant or Parameter) + ov::test::utils::InputLayerType, // B input type (Constant or Parameter) + ov::element::Type, // Model type + ov::test::TargetDevice // Device name +>; + +class RNNCellTest : public testing::WithParamInterface, + virtual public ov::test::SubgraphBaseStaticTest { +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/src/single_op/reverse.cpp b/src/tests/functional/shared_test_classes/src/single_op/reverse.cpp new file mode 100644 index 00000000000..cd5a9958bf9 --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/reverse.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/reverse.hpp" + +namespace ov { +namespace test { + +std::string ReverseLayerTest::getTestCaseName(const testing::TestParamInfo& obj) { + std::vector input_shape; + std::vector axes; + std::string mode; + ov::element::Type model_type; + std::string target_device; + std::tie(input_shape, axes, mode, model_type, target_device) = obj.param; + + std::ostringstream result; + result << "in_shape=" << ov::test::utils::vec2str(input_shape) << "_"; + result << "axes=" << ov::test::utils::vec2str(axes) << "_"; + result << "mode=" << mode << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "targetDevice=" << target_device; + return result.str(); +} + +void ReverseLayerTest::SetUp() { + std::vector input_shape; + std::vector axes; + std::string mode; + ov::element::Type model_type; + std::tie(input_shape, axes, mode, model_type, targetDevice) = GetParam(); + + auto param = std::make_shared(model_type, ov::Shape(input_shape)); + std::shared_ptr axes_constant; + if (mode == "index") { + axes_constant = std::make_shared(ov::element::i32, ov::Shape{axes.size()}, axes); + } else { + std::vector axes_mask(input_shape.size(), false); + for (auto axis : axes) + axes_mask[axis] = true; + axes_constant = + std::make_shared(ov::element::boolean, ov::Shape{axes_mask.size()}, axes_mask); + } + auto reverse = std::make_shared(param, axes_constant, mode); + function = std::make_shared(reverse->outputs(), ov::ParameterVector{param}, "reverse"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/reverse_sequence.cpp b/src/tests/functional/shared_test_classes/src/single_op/reverse_sequence.cpp new file mode 100644 index 00000000000..e2ff553a29a --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/reverse_sequence.cpp @@ -0,0 +1,59 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "shared_test_classes/single_op/reverse_sequence.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" + +namespace ov { +namespace test { +std::string ReverseSequenceLayerTest::getTestCaseName(const testing::TestParamInfo &obj) { + int64_t batch_axis_idx; + int64_t seq_axis_idx; + ov::element::Type model_type; + std::string target_device; + std::vector input_shape; + std::vector second_input_shape; + ov::test::utils::InputLayerType secondary_input_type; + + std::tie(batch_axis_idx, seq_axis_idx, input_shape, second_input_shape, secondary_input_type, model_type, target_device) = obj.param; + + std::ostringstream result; + result << "IS=" << ov::test::utils::vec2str(input_shape) << "_"; + result << "seqLengthsShape" << ov::test::utils::vec2str(second_input_shape) << "_"; + result << "secondaryInputType=" << secondary_input_type << "_"; + result << "batchAxis=" << batch_axis_idx << "_"; + result << "seqAxis=" << seq_axis_idx << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "targetDevice=" << target_device; + return result.str(); +} + +void ReverseSequenceLayerTest::SetUp() { + ov::element::Type model_type; + int64_t batch_axis_idx; + int64_t seq_axis_idx; + std::vector input_shape; + std::vector second_input_shape; + ov::test::utils::InputLayerType secondary_input_type; + + std::tie(batch_axis_idx, seq_axis_idx, input_shape, second_input_shape, secondary_input_type, model_type, targetDevice) = GetParam(); + + ov::ParameterVector params {std::make_shared(model_type, ov::Shape(input_shape))}; + auto second_data_type = ov::element::i32; //according to the specification + std::shared_ptr secondary_input; + if (ov::test::utils::InputLayerType::CONSTANT == secondary_input_type) { + auto tensor = ov::test::utils::create_and_fill_tensor(second_data_type, second_input_shape); + secondary_input = std::make_shared(tensor); + } else if (ov::test::utils::InputLayerType::PARAMETER == secondary_input_type) { + secondary_input = std::make_shared(second_data_type, ov::Shape(second_input_shape)); + params.push_back(std::dynamic_pointer_cast(secondary_input)); + } else { + throw std::runtime_error("Unsupported input type"); + } + + auto reverse = std::make_shared(params[0], secondary_input, batch_axis_idx, seq_axis_idx); + function = std::make_shared(reverse->outputs(), params, "ReverseSequence"); +} +} // namespace test +} // namespace ov diff --git a/src/tests/functional/shared_test_classes/src/single_op/rnn_cell.cpp b/src/tests/functional/shared_test_classes/src/single_op/rnn_cell.cpp new file mode 100644 index 00000000000..88a9d4673dc --- /dev/null +++ b/src/tests/functional/shared_test_classes/src/single_op/rnn_cell.cpp @@ -0,0 +1,109 @@ +// Copyright (C) 2018-2023 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "openvino/pass/manager.hpp" +#include "transformations/op_conversions/rnn_cell_decomposition.hpp" +#include "shared_test_classes/single_op/rnn_cell.hpp" +#include "common_test_utils/ov_tensor_utils.hpp" + +namespace ov { +namespace test { + +using utils::InputLayerType; + +std::string RNNCellTest::getTestCaseName(const testing::TestParamInfo &obj) { + bool should_decompose; + size_t batch; + size_t hidden_size; + size_t input_size; + std::vector activations; + float clip; + InputLayerType WType; + InputLayerType RType; + InputLayerType BType; + ov::element::Type model_type; + std::string target_device; + std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, WType, RType, BType, + model_type, target_device) = obj.param; + std::vector> input_shapes = {{batch, input_size}, {batch, hidden_size}, + {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; + std::ostringstream result; + result << "decomposition" << should_decompose << "_"; + result << "batch=" << batch << "_"; + result << "hidden_size=" << hidden_size << "_"; + result << "input_size=" << input_size << "_"; + result << "IS=" << ov::test::utils::vec2str(input_shapes) << "_"; + result << "activations=" << ov::test::utils::vec2str(activations) << "_"; + result << "clip=" << clip << "_"; + result << "WType=" << WType << "_"; + result << "RType=" << RType << "_"; + result << "BType=" << BType << "_"; + result << "modelType=" << model_type.to_string() << "_"; + result << "targetDevice=" << target_device; + return result.str(); +} + +void RNNCellTest::SetUp() { + bool should_decompose; + size_t batch; + size_t hidden_size; + size_t input_size; + std::vector activations; + std::vector activations_alpha; + std::vector activations_beta; + float clip; + InputLayerType WType; + InputLayerType RType; + InputLayerType BType; + ov::element::Type model_type; + std::tie(should_decompose, batch, hidden_size, input_size, activations, clip, WType, RType, BType, + model_type, targetDevice) = this->GetParam(); + + std::vector> input_shapes = {{batch, input_size}, {batch, hidden_size}, + {hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}}; + ov::ParameterVector params{std::make_shared(model_type, ov::Shape(input_shapes[0])), + std::make_shared(model_type, ov::Shape(input_shapes[1]))}; + std::vector WRB = {input_shapes[2], input_shapes[3], input_shapes[4]}; + + std::shared_ptr W; + if (WType == InputLayerType::PARAMETER) { + const auto param = std::make_shared(model_type, WRB[0]); + W = param; + params.push_back(param); + } else { + auto tensor = ov::test::utils::create_and_fill_tensor(model_type, WRB[0]); + W = std::make_shared(tensor); + } + + std::shared_ptr R; + if (RType == InputLayerType::PARAMETER) { + const auto param = std::make_shared(model_type, WRB[1]); + R = param; + params.push_back(param); + } else { + auto tensor = ov::test::utils::create_and_fill_tensor(model_type, WRB[1]); + R = std::make_shared(tensor); + } + + std::shared_ptr B; + if (BType == InputLayerType::PARAMETER) { + const auto param = std::make_shared(model_type, WRB[2]); + B = param; + params.push_back(param); + } else { + auto tensor = ov::test::utils::create_and_fill_tensor(model_type, WRB[2]); + B = std::make_shared(tensor); + } + + auto rnn_cell = std::make_shared(params[0], params[1], W, R, B, hidden_size, activations, + activations_alpha, activations_beta, clip); + function = std::make_shared(rnn_cell->outputs(), params, "rnn_cell"); + if (should_decompose) { + ov::pass::Manager m; + m.register_pass(); + m.run_passes(function); + } +} +} // namespace test +} // namespace ov