ReverseSequence
, RNNCell
, Reverse
to API2.0 (#20569)
* `ReverseSequence` to API2.0 * `RNNCell` to API2.0 * `Reverse` GPU test to API2.0 * Alignment fix
This commit is contained in:
parent
f2b26962fa
commit
04c766e9f1
@ -4,43 +4,43 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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<InferenceEngine::Precision> netPrecisions = {
|
||||
InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::U8,
|
||||
InferenceEngine::Precision::I8,
|
||||
InferenceEngine::Precision::U16,
|
||||
InferenceEngine::Precision::I32
|
||||
const std::vector<ov::element::Type> model_types = {
|
||||
ov::element::f32,
|
||||
ov::element::f16,
|
||||
ov::element::u8,
|
||||
ov::element::i8,
|
||||
ov::element::u16,
|
||||
ov::element::i32
|
||||
};
|
||||
|
||||
const std::vector<int64_t> batchAxisIndices = { 0L };
|
||||
const std::vector<int64_t> batch_axis_indices = { 0L };
|
||||
|
||||
const std::vector<int64_t> seqAxisIndices = { 1L };
|
||||
const std::vector<int64_t> seq_axis_indices = { 1L };
|
||||
|
||||
const std::vector<std::vector<size_t>> inputShapes = { {3, 10} }; //, 10, 20
|
||||
const std::vector<std::vector<size_t>> input_shapes = { {3, 10} }; //, 10, 20
|
||||
|
||||
const std::vector<std::vector<size_t>> reversSeqLengthsVecShapes = { {3} };
|
||||
const std::vector<std::vector<size_t>> reverse_seq_shapes = { {3} };
|
||||
|
||||
const std::vector<ngraph::helpers::InputLayerType> secondaryInputTypes = {
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::PARAMETER
|
||||
const std::vector<ov::test::utils::InputLayerType> 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);
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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<bool> should_decompose{false, true};
|
||||
@ -16,12 +16,12 @@ namespace {
|
||||
std::vector<size_t> input_size{1, 30};
|
||||
std::vector<std::vector<std::string>> activations = {{"relu"}, {"sigmoid"}, {"tanh"}};
|
||||
std::vector<float> clip = {0.f, 0.7f};
|
||||
std::vector<ngraph::helpers::InputLayerType> layer_types = {
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::PARAMETER
|
||||
std::vector<ov::test::utils::InputLayerType> layer_types = {
|
||||
ov::test::utils::InputLayerType::CONSTANT,
|
||||
ov::test::utils::InputLayerType::PARAMETER
|
||||
};
|
||||
std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16};
|
||||
std::vector<ov::element::Type> 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);
|
||||
|
||||
|
@ -2,92 +2,89 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "single_layer_tests/reverse.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_op_tests/reverse.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
using ov::test::ReverseLayerTest;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::I32,
|
||||
InferenceEngine::Precision::I64,
|
||||
InferenceEngine::Precision::I8,
|
||||
InferenceEngine::Precision::U8};
|
||||
const std::vector<ov::element::Type> model_types = {ov::element::f32,
|
||||
ov::element::f16,
|
||||
ov::element::i32,
|
||||
ov::element::i64,
|
||||
ov::element::i8,
|
||||
ov::element::u8};
|
||||
|
||||
const std::vector<std::vector<size_t>> inputShapes1D = {{10}};
|
||||
const std::vector<std::vector<int>> indices1D = {{0}};
|
||||
const std::vector<std::vector<size_t>> input_shapes_1D = {{10}};
|
||||
const std::vector<std::vector<int>> indices_1D = {{0}};
|
||||
const std::vector<std::string> 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<std::vector<size_t>> inputShapes2D = {{3, 4}, {1, 3}};
|
||||
const std::vector<std::vector<int>> indices2D = {{0}, {1}};
|
||||
const std::vector<std::vector<size_t>> input_shapes_2D = {{3, 4}, {1, 3}};
|
||||
const std::vector<std::vector<int>> 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<std::vector<size_t>> inputShapes3D = {{1, 3, 4}, {2, 5, 6}};
|
||||
const std::vector<std::vector<int>> indices3D = {{0}, {0, 1}, {0, 2}};
|
||||
const std::vector<std::vector<size_t>> input_shapes_3D = {{1, 3, 4}, {2, 5, 6}};
|
||||
const std::vector<std::vector<int>> 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<std::vector<size_t>> inputShapes4D = {{1, 2, 3, 4}, {1, 2, 5, 6}};
|
||||
const std::vector<std::vector<int>> indices4D = {{1}, {1, 2}, {1, 3}};
|
||||
const std::vector<std::vector<size_t>> input_shapes_4D = {{1, 2, 3, 4}, {1, 2, 5, 6}};
|
||||
const std::vector<std::vector<int>> 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<std::vector<size_t>> inputShapes5D = {{1, 1, 4, 3, 3}};
|
||||
const std::vector<std::vector<int>> indices5D = {{2}, {2, 3}, {2, 4}};
|
||||
const std::vector<std::vector<size_t>> input_shapes_5D = {{1, 1, 4, 3, 3}};
|
||||
const std::vector<std::vector<int>> 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<std::vector<size_t>> inputShapes6D = {{1, 1, 4, 3, 3, 3}};
|
||||
const std::vector<std::vector<int>> indices6D = {{2}, {1, 3}, {3, 5}, {1, 4, 5}};
|
||||
const std::vector<std::vector<size_t>> input_shapes_6D = {{1, 1, 4, 3, 3, 3}};
|
||||
const std::vector<std::vector<int>> 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);
|
||||
|
||||
|
@ -4,10 +4,10 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#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<bool> should_decompose{false, true};
|
||||
@ -16,14 +16,14 @@ namespace {
|
||||
std::vector<size_t> input_size{1, 30};
|
||||
std::vector<std::vector<std::string>> activations = {{"relu"}, {"sigmoid"}, {"tanh"}};
|
||||
std::vector<float> clip = {0.f, 0.7f};
|
||||
std::vector<ngraph::helpers::InputLayerType> layer_types = {
|
||||
ngraph::helpers::InputLayerType::CONSTANT,
|
||||
ngraph::helpers::InputLayerType::PARAMETER
|
||||
std::vector<ov::test::utils::InputLayerType> layer_types = {
|
||||
ov::test::utils::InputLayerType::CONSTANT,
|
||||
ov::test::utils::InputLayerType::PARAMETER
|
||||
};
|
||||
std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32,
|
||||
InferenceEngine::Precision::FP16};
|
||||
std::vector<ov::element::Type> 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);
|
||||
|
||||
|
@ -117,5 +117,7 @@ std::vector<std::string> disabledTestPatterns() {
|
||||
R"(.*MemoryDynamicBatch.*)",
|
||||
// Issue: 123493
|
||||
R"(.*GroupNormalizationTest.*CompareWithRefs.*NetType=f16.*)",
|
||||
// Issue: 123507
|
||||
R"(.*ReverseLayerTest.*mask.*f16.*)",
|
||||
};
|
||||
}
|
||||
|
@ -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
|
@ -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
|
@ -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
|
@ -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<size_t>, // Input shape
|
||||
std::vector<int>, // Axes
|
||||
std::string, // Mode
|
||||
ov::element::Type, // Model type
|
||||
ov::test::TargetDevice // Device name
|
||||
>;
|
||||
|
||||
class ReverseLayerTest : public testing::WithParamInterface<reverseParams>,
|
||||
virtual public ov::test::SubgraphBaseStaticTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<reverseParams>& obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,36 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#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<size_t>, // Input shapes
|
||||
std::vector<size_t>, // 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<ReverseSequenceParamsTuple>,
|
||||
virtual public ov::test::SubgraphBaseStaticTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ReverseSequenceParamsTuple> &obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <tuple>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
#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<std::string>, // 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<RNNCellParams >,
|
||||
virtual public ov::test::SubgraphBaseStaticTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<RNNCellParams> &obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -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<reverseParams>& obj) {
|
||||
std::vector<size_t> input_shape;
|
||||
std::vector<int> 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<size_t> input_shape;
|
||||
std::vector<int> axes;
|
||||
std::string mode;
|
||||
ov::element::Type model_type;
|
||||
std::tie(input_shape, axes, mode, model_type, targetDevice) = GetParam();
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape));
|
||||
std::shared_ptr<ov::op::v0::Constant> axes_constant;
|
||||
if (mode == "index") {
|
||||
axes_constant = std::make_shared<ov::op::v0::Constant>(ov::element::i32, ov::Shape{axes.size()}, axes);
|
||||
} else {
|
||||
std::vector<bool> axes_mask(input_shape.size(), false);
|
||||
for (auto axis : axes)
|
||||
axes_mask[axis] = true;
|
||||
axes_constant =
|
||||
std::make_shared<ov::op::v0::Constant>(ov::element::boolean, ov::Shape{axes_mask.size()}, axes_mask);
|
||||
}
|
||||
auto reverse = std::make_shared<ov::op::v1::Reverse>(param, axes_constant, mode);
|
||||
function = std::make_shared<ov::Model>(reverse->outputs(), ov::ParameterVector{param}, "reverse");
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -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<ReverseSequenceParamsTuple> &obj) {
|
||||
int64_t batch_axis_idx;
|
||||
int64_t seq_axis_idx;
|
||||
ov::element::Type model_type;
|
||||
std::string target_device;
|
||||
std::vector<size_t> input_shape;
|
||||
std::vector<size_t> 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<size_t> input_shape;
|
||||
std::vector<size_t> 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<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape))};
|
||||
auto second_data_type = ov::element::i32; //according to the specification
|
||||
std::shared_ptr<ov::Node> 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<ov::op::v0::Constant>(tensor);
|
||||
} else if (ov::test::utils::InputLayerType::PARAMETER == secondary_input_type) {
|
||||
secondary_input = std::make_shared<ov::op::v0::Parameter>(second_data_type, ov::Shape(second_input_shape));
|
||||
params.push_back(std::dynamic_pointer_cast<ov::op::v0::Parameter>(secondary_input));
|
||||
} else {
|
||||
throw std::runtime_error("Unsupported input type");
|
||||
}
|
||||
|
||||
auto reverse = std::make_shared<ov::op::v0::ReverseSequence>(params[0], secondary_input, batch_axis_idx, seq_axis_idx);
|
||||
function = std::make_shared<ov::Model>(reverse->outputs(), params, "ReverseSequence");
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
@ -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<RNNCellParams> &obj) {
|
||||
bool should_decompose;
|
||||
size_t batch;
|
||||
size_t hidden_size;
|
||||
size_t input_size;
|
||||
std::vector<std::string> 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<std::vector<size_t>> 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<std::string> activations;
|
||||
std::vector<float> activations_alpha;
|
||||
std::vector<float> 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<std::vector<size_t>> input_shapes = {{batch, input_size}, {batch, hidden_size},
|
||||
{hidden_size, input_size}, {hidden_size, hidden_size}, {hidden_size}};
|
||||
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shapes[0])),
|
||||
std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shapes[1]))};
|
||||
std::vector<ov::Shape> WRB = {input_shapes[2], input_shapes[3], input_shapes[4]};
|
||||
|
||||
std::shared_ptr<ov::Node> W;
|
||||
if (WType == InputLayerType::PARAMETER) {
|
||||
const auto param = std::make_shared<ov::op::v0::Parameter>(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<ov::op::v0::Constant>(tensor);
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Node> R;
|
||||
if (RType == InputLayerType::PARAMETER) {
|
||||
const auto param = std::make_shared<ov::op::v0::Parameter>(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<ov::op::v0::Constant>(tensor);
|
||||
}
|
||||
|
||||
std::shared_ptr<ov::Node> B;
|
||||
if (BType == InputLayerType::PARAMETER) {
|
||||
const auto param = std::make_shared<ov::op::v0::Parameter>(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<ov::op::v0::Constant>(tensor);
|
||||
}
|
||||
|
||||
auto rnn_cell = std::make_shared<ov::op::v0::RNNCell>(params[0], params[1], W, R, B, hidden_size, activations,
|
||||
activations_alpha, activations_beta, clip);
|
||||
function = std::make_shared<ov::Model>(rnn_cell->outputs(), params, "rnn_cell");
|
||||
if (should_decompose) {
|
||||
ov::pass::Manager m;
|
||||
m.register_pass<ov::pass::RNNCellDecomposition>();
|
||||
m.run_passes(function);
|
||||
}
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
Loading…
Reference in New Issue
Block a user