RNNSequence, Result, Reshape, ReorgYolo, RegionYolo layer tests to API2.0 (#20644)

* `RNNSequenceTest` to API2.0

* `Result` to API2.0

* `Reshape` to API2.0

* `ReorgYolo` to API2.0

* `RegionYolo` to API2.0

* Alignment fixes

* Skip more `RNNSequenceTest` cases
This commit is contained in:
Vitaliy Urusovskij 2023-10-25 10:16:28 +04:00 committed by GitHub
parent 46f46c6cc6
commit a71283ea94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 643 additions and 97 deletions

View File

@ -4,16 +4,16 @@
#include <vector>
#include "single_layer_tests/region_yolo.hpp"
#include "single_op_tests/region_yolo.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::RegionYoloLayerTest;
const std::vector<ngraph::Shape> inShapes_caffe = {
const std::vector<std::vector<size_t>> in_shapes_caffe = {
{1, 125, 13, 13}
};
const std::vector<ngraph::Shape> inShapes_mxnet = {
const std::vector<std::vector<size_t>> in_shapes_mxnet = {
{1, 75, 52, 52},
{1, 75, 32, 32},
{1, 75, 26, 26},
@ -22,7 +22,7 @@ const std::vector<ngraph::Shape> inShapes_mxnet = {
{1, 75, 8, 8}
};
const std::vector<ngraph::Shape> inShapes_v3 = {
const std::vector<std::vector<size_t>> in_shapes_v3 = {
{1, 255, 52, 52},
{1, 255, 26, 26},
{1, 255, 13, 13}
@ -41,8 +41,8 @@ const size_t coords = 4;
const int start_axis = 1;
const int end_axis = 3;
const auto testCase_yolov3 = ::testing::Combine(
::testing::ValuesIn(inShapes_v3),
const auto test_case_yolov3 = ::testing::Combine(
::testing::ValuesIn(in_shapes_v3),
::testing::Values(classes[0]),
::testing::Values(coords),
::testing::Values(num_regions[1]),
@ -50,12 +50,12 @@ const auto testCase_yolov3 = ::testing::Combine(
::testing::Values(masks[2]),
::testing::Values(start_axis),
::testing::Values(end_axis),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_yolov3_mxnet = ::testing::Combine(
::testing::ValuesIn(inShapes_mxnet),
const auto test_case_yolov3_mxnet = ::testing::Combine(
::testing::ValuesIn(in_shapes_mxnet),
::testing::Values(classes[1]),
::testing::Values(coords),
::testing::Values(num_regions[1]),
@ -63,12 +63,12 @@ const auto testCase_yolov3_mxnet = ::testing::Combine(
::testing::Values(masks[1]),
::testing::Values(start_axis),
::testing::Values(end_axis),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_yolov2_caffe = ::testing::Combine(
::testing::ValuesIn(inShapes_caffe),
const auto test_case_yolov2_caffe = ::testing::Combine(
::testing::ValuesIn(in_shapes_caffe),
::testing::Values(classes[1]),
::testing::Values(coords),
::testing::Values(num_regions[0]),
@ -76,10 +76,10 @@ const auto testCase_yolov2_caffe = ::testing::Combine(
::testing::Values(masks[0]),
::testing::Values(start_axis),
::testing::Values(end_axis),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYolov3, RegionYoloLayerTest, testCase_yolov3, RegionYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnet, RegionYoloLayerTest, testCase_yolov3_mxnet, RegionYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffe, RegionYoloLayerTest, testCase_yolov2_caffe, RegionYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYolov3, RegionYoloLayerTest, test_case_yolov3, RegionYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloMxnet, RegionYoloLayerTest, test_case_yolov3_mxnet, RegionYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsRegionYoloCaffe, RegionYoloLayerTest, test_case_yolov2_caffe, RegionYoloLayerTest::getTestCaseName);

View File

@ -4,16 +4,16 @@
#include <vector>
#include "single_layer_tests/reorg_yolo.hpp"
#include "single_op_tests/reorg_yolo.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::ReorgYoloLayerTest;
const std::vector<ngraph::Shape> inShapes_caffe_yolov2 = {
const std::vector<std::vector<size_t>> in_shapes_caffe_yolov2 = {
{1, 64, 26, 26},
};
const std::vector<ngraph::Shape> inShapes = {
const std::vector<std::vector<size_t>> in_shapes = {
{1, 4, 4, 4},
{1, 8, 4, 4},
{1, 9, 3, 3},
@ -25,51 +25,51 @@ const std::vector<size_t> strides = {
2, 3
};
const auto testCase_caffe_yolov2 = ::testing::Combine(
::testing::ValuesIn(inShapes_caffe_yolov2),
const auto test_case_caffe_yolov2 = ::testing::Combine(
::testing::ValuesIn(in_shapes_caffe_yolov2),
::testing::Values(strides[0]),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_smallest = ::testing::Combine(
::testing::Values(inShapes[0]),
const auto test_case_smallest = ::testing::Combine(
::testing::Values(in_shapes[0]),
::testing::Values(strides[0]),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_stride_2 = ::testing::Combine(
::testing::Values(inShapes[1]),
const auto test_case_stride_2 = ::testing::Combine(
::testing::Values(in_shapes[1]),
::testing::Values(strides[0]),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_stride_3 = ::testing::Combine(
::testing::Values(inShapes[2]),
const auto test_case_stride_3 = ::testing::Combine(
::testing::Values(in_shapes[2]),
::testing::Values(strides[1]),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_smaller_h = ::testing::Combine(
::testing::Values(inShapes[4]),
const auto test_case_smaller_h = ::testing::Combine(
::testing::Values(in_shapes[4]),
::testing::Values(strides[0]),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
const auto testCase_batch_2 = ::testing::Combine(
::testing::Values(inShapes[3]),
const auto test_case_batch_2 = ::testing::Combine(
::testing::Values(in_shapes[3]),
::testing::Values(strides[0]),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)
);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_caffe_YoloV2, ReorgYoloLayerTest, testCase_caffe_yolov2, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2_smallest, ReorgYoloLayerTest, testCase_smallest, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2, ReorgYoloLayerTest, testCase_stride_2, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_3, ReorgYoloLayerTest, testCase_stride_3, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_smaller_h, ReorgYoloLayerTest, testCase_smaller_h, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_batch_2, ReorgYoloLayerTest, testCase_batch_2, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_caffe_YoloV2, ReorgYoloLayerTest, test_case_caffe_yolov2, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2_smallest, ReorgYoloLayerTest, test_case_smallest, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_2, ReorgYoloLayerTest, test_case_stride_2, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_stride_3, ReorgYoloLayerTest, test_case_stride_3, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_smaller_h, ReorgYoloLayerTest, test_case_smaller_h, ReorgYoloLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsReorgYolo_batch_2, ReorgYoloLayerTest, test_case_batch_2, ReorgYoloLayerTest::getTestCaseName);

View File

@ -4,42 +4,32 @@
#include <vector>
#include "single_layer_tests/reshape.hpp"
#include "single_op_tests/reshape.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::ReshapeLayerTest;
namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16
const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::f16
};
INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheck, ReshapeLayerTest,
::testing::Combine(
::testing::Values(true),
::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(model_types),
::testing::Values(std::vector<size_t>({10, 10, 10, 10})),
::testing::Values(std::vector<int64_t>({10, 0, 100})),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(std::map<std::string, std::string>({}))),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ReshapeLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ReshapeCheckNegative, ReshapeLayerTest,
::testing::Combine(
::testing::Values(true),
::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(model_types),
::testing::Values(std::vector<size_t>({10, 10, 10, 10})),
::testing::Values(std::vector<int64_t>({10, -1, 100})),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(std::map<std::string, std::string>({}))),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ReshapeLayerTest::getTestCaseName);
} // namespace

View File

@ -4,28 +4,33 @@
#include <vector>
#include "shared_test_classes/single_layer/result.hpp"
#include "single_op_tests/result.hpp"
using namespace LayerTestsDefinitions;
using namespace InferenceEngine;
using ov::test::ResultLayerTest;
namespace {
std::vector<InferenceEngine::SizeVector> inputDims = {
{7}, {1000}, {3, 5}, {65, 33}, {33, 65},
{1, 1000}, {223, 217, 21}, {3, 4, 5, 1}, {3, 4, 1, 5, 1}};
std::vector<InferenceEngine::Precision> inputPrecisions = {
InferenceEngine::Precision::U8, InferenceEngine::Precision::FP32,
InferenceEngine::Precision::I32,
std::vector<std::vector<size_t>> input_shapes = {
{7},
{1000},
{3, 5},
{65, 33},
{33, 65},
{1, 1000},
{223, 217, 21},
{3, 4, 5, 1},
{3, 4, 1, 5, 1}
};
ConfigMap config;
std::vector<ov::element::Type> model_types = {
ov::element::u8,
ov::element::f32,
ov::element::i32,
};
INSTANTIATE_TEST_SUITE_P(
smoke_ResultLayerTest, ResultLayerTest,
::testing::Combine(::testing::ValuesIn(inputDims),
::testing::ValuesIn(inputPrecisions),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(config)),
::testing::Combine(::testing::ValuesIn(input_shapes),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ResultLayerTest::getTestCaseName);
} // namespace

View File

@ -3,21 +3,24 @@
//
#include <vector>
#include <ngraph/op/util/attr_types.hpp>
#include "single_layer_tests/rnn_sequence.hpp"
#include "openvino/op/util/attr_types.hpp"
#include "single_op_tests/rnn_sequence.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::RNNSequenceTest;
using ov::test::utils::SequenceTestsMode;
using ov::test::utils::InputLayerType;
using ov::op::RecurrentSequenceDirection;
namespace {
std::vector<ngraph::helpers::SequenceTestsMode> mode{ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST,
ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST,
ngraph::helpers::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM,
ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM,
ngraph::helpers::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST,
ngraph::helpers::SequenceTestsMode::PURE_SEQ};
std::vector<SequenceTestsMode> mode{SequenceTestsMode::CONVERT_TO_TI_MAX_SEQ_LEN_CONST,
SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST,
SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_PARAM,
SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_PARAM,
SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST,
SequenceTestsMode::PURE_SEQ};
// output values increase rapidly without clip, so use only seq_lengths = 2
std::vector<size_t> seq_lengths_zero_clip{2};
std::vector<size_t> seq_lengths_zero_clip{10};
std::vector<size_t> seq_lengths_clip_non_zero{20};
std::vector<size_t> batch{1, 10};
std::vector<size_t> hidden_size{1, 10};
@ -25,11 +28,11 @@ namespace {
std::vector<std::vector<std::string>> activations = {{"relu"}, {"sigmoid"}, {"tanh"}};
std::vector<float> clip{0.f};
std::vector<float> clip_non_zeros{0.7f};
std::vector<ngraph::op::RecurrentSequenceDirection> direction = {ngraph::op::RecurrentSequenceDirection::FORWARD,
ngraph::op::RecurrentSequenceDirection::REVERSE,
ngraph::op::RecurrentSequenceDirection::BIDIRECTIONAL,
std::vector<RecurrentSequenceDirection> direction = {RecurrentSequenceDirection::FORWARD,
RecurrentSequenceDirection::REVERSE,
RecurrentSequenceDirection::BIDIRECTIONAL,
};
std::vector<InferenceEngine::Precision> netPrecisions = {InferenceEngine::Precision::FP32};
std::vector<ov::element::Type> model_types = {ov::element::f32};
INSTANTIATE_TEST_SUITE_P(smoke_RNNSequenceCommonZeroClip, RNNSequenceTest,
::testing::Combine(
@ -41,8 +44,8 @@ namespace {
::testing::ValuesIn(activations),
::testing::ValuesIn(clip),
::testing::ValuesIn(direction),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
::testing::ValuesIn(netPrecisions),
::testing::Values(InputLayerType::CONSTANT),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
RNNSequenceTest::getTestCaseName);
@ -56,8 +59,8 @@ namespace {
::testing::ValuesIn(activations),
::testing::ValuesIn(clip_non_zeros),
::testing::ValuesIn(direction),
::testing::Values(ngraph::helpers::InputLayerType::CONSTANT),
::testing::ValuesIn(netPrecisions),
::testing::Values(InputLayerType::CONSTANT),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
RNNSequenceTest::getTestCaseName);

View File

@ -193,6 +193,8 @@ std::vector<std::string> disabledTestPatterns() {
R"(smoke_Interpolate_Basic_Down_Sample_Tail/InterpolateLayerTest.Inference.*(asymmetric|align_corners).*f16.*)",
// Need to generate sequence exactly in the i64 data type. Enable in scope of i64 enabling.
R"(.*RandomUniformLayerTestCPU.*OutPrc=i64.*)",
// Issue: 123321
R"(.*smoke_RNNSequenceCommonZeroClip/RNNSequenceTest.Inference.*hidden_size=10.*relu.*)",
};
#if defined(OPENVINO_ARCH_X86)
@ -217,6 +219,8 @@ std::vector<std::string> disabledTestPatterns() {
retVector.emplace_back(R"(smoke_CPU_OVClassLoadNetworkAndCheckWithSecondaryPropertiesDoubleTest/OVClassLoadNetworkAndCheckSecondaryPropertiesTest.LoadNetworkAndCheckSecondaryPropertiesTest.*)");
retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckSecondaryPropertiesTest.*)");
retVector.emplace_back(R"(smoke_CPU_OVClassCompileModelAndCheckWithSecondaryPropertiesDoubleTest.*)");
// Issue: 123321
retVector.emplace_back(R"(.*smoke_RNNSequenceCommonZeroClip/RNNSequenceTest.Inference.*hidden_size=1.*relu.*direction=reverse.*)");
}
// invalid test: checks u8 precision for runtime graph, while it should be f32
retVector.emplace_back(R"(smoke_NegativeQuantizedMatMulMultiplyFusion.*)");

View File

@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/region_yolo.hpp"
namespace ov {
namespace test {
TEST_P(RegionYoloLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/reorg_yolo.hpp"
namespace ov {
namespace test {
TEST_P(ReorgYoloLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/reshape.hpp"
namespace ov {
namespace test {
TEST_P(ReshapeLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_op/result.hpp"
namespace ov {
namespace test {
TEST_P(ResultLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@ -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_sequence.hpp"
namespace ov {
namespace test {
TEST_P(RNNSequenceTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,37 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
using regionYoloParamsTuple = std::tuple<
std::vector<size_t>, // Input shape
size_t, // Classes
size_t, // Coordinates
size_t, // Num regions
bool, // Do softmax
std::vector<int64_t>, // Mask
int, // Start axis
int, // End axis
ov::element::Type, // Model type
ov::test::TargetDevice // Device name
>;
class RegionYoloLayerTest : public testing::WithParamInterface<regionYoloParamsTuple>,
virtual public ov::test::SubgraphBaseStaticTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<regionYoloParamsTuple> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,31 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
using ReorgYoloParamsTuple = typename std::tuple<
std::vector<size_t>, // Input shape
size_t, // Stride
ov::element::Type, // Model type
ov::test::TargetDevice // Device name
>;
class ReorgYoloLayerTest : public testing::WithParamInterface<ReorgYoloParamsTuple>,
virtual public ov::test::SubgraphBaseStaticTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ReorgYoloParamsTuple> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,32 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
using reshapeParams = std::tuple<
bool, // SpecialZero
ov::element::Type, // Model type
std::vector<size_t>, // Input shapes
std::vector<int64_t>, // OutForm shapes
ov::test::TargetDevice // Device name
>;
class ReshapeLayerTest : public testing::WithParamInterface<reshapeParams>,
virtual public ov::test::SubgraphBaseStaticTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<reshapeParams> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,31 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
using ResultTestParamSet = std::tuple<
std::vector<size_t>, // Input shapes
ov::element::Type, // Model type
ov::test::TargetDevice // Device name
>;
class ResultLayerTest : public testing::WithParamInterface<ResultTestParamSet>,
virtual public ov::test::SubgraphBaseStaticTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<ResultTestParamSet>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,43 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include <vector>
#include <memory>
#include <ngraph/op/util/attr_types.hpp>
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "ov_models/builders.hpp"
#include "common_test_utils/test_enums.hpp"
namespace ov {
namespace test {
using RNNSequenceParams = typename std::tuple<
ov::test::utils::SequenceTestsMode, // Pure Sequence or TensorIterator
size_t, // Sequence lengths
size_t, // Batch
size_t, // Hidden size
size_t, // Input size
std::vector<std::string>, // Activations
float, // Clip
ov::op::RecurrentSequenceDirection, // Direction
ov::test::utils::InputLayerType, // WRB input type (Constant or Parameter)
ov::element::Type, // Model type
ov::test::TargetDevice // Device name
>;
class RNNSequenceTest : public testing::WithParamInterface<RNNSequenceParams>,
virtual public ov::test::SubgraphBaseStaticTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<RNNSequenceParams> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,52 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/region_yolo.hpp"
namespace ov {
namespace test {
std::string RegionYoloLayerTest::getTestCaseName(const testing::TestParamInfo<regionYoloParamsTuple> &obj) {
std::vector<size_t> input_shape;
ov::element::Type model_type;
std::string target_device;
size_t classes;
size_t coords;
size_t num_regions;
bool do_softmax;
std::vector<int64_t> mask;
int start_axis;
int end_axis;
std::tie(input_shape, classes, coords, num_regions, do_softmax , mask, start_axis, end_axis, model_type, target_device) = obj.param;
std::ostringstream result;
result << "IS=" << ov::test::utils::vec2str(input_shape) << "_";
result << "classes=" << classes << "_";
result << "coords=" << coords << "_";
result << "num=" << num_regions << "_";
result << "doSoftmax=" << do_softmax << "_";
result << "axis=" << start_axis << "_";
result << "endAxis=" << end_axis << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void RegionYoloLayerTest::SetUp() {
std::vector<size_t> input_shape;
ov::element::Type model_type;
size_t classes;
size_t coords;
size_t num_regions;
bool do_softmax;
std::vector<int64_t> mask;
int start_axis;
int end_axis;
std::tie(input_shape, classes, coords, num_regions, do_softmax, mask, start_axis, end_axis, model_type, targetDevice) = this->GetParam();
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape));
auto region_yolo = std::make_shared<ov::op::v0::RegionYolo>(param, coords, classes, num_regions, do_softmax, mask, start_axis, end_axis);
function = std::make_shared<ov::Model>(region_yolo->outputs(), ov::ParameterVector{param}, "RegionYolo");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,33 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/reorg_yolo.hpp"
namespace ov {
namespace test {
std::string ReorgYoloLayerTest::getTestCaseName(const testing::TestParamInfo<ReorgYoloParamsTuple> &obj) {
std::vector<size_t> input_shape;
ov::element::Type model_type;
size_t stride;
std::string target_device;
std::tie(input_shape, stride, model_type, target_device) = obj.param;
std::ostringstream result;
result << "IS=" << ov::test::utils::vec2str(input_shape) << "_";
result << "stride=" << stride << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void ReorgYoloLayerTest::SetUp() {
std::vector<size_t> input_shape;
ov::element::Type model_type;
size_t stride;
std::tie(input_shape, stride, model_type, targetDevice) = this->GetParam();
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape));
auto reorg_yolo = std::make_shared<ov::op::v0::ReorgYolo>(param, stride);
function = std::make_shared<ov::Model>(reorg_yolo->outputs(), ov::ParameterVector{param}, "ReorgYolo");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,39 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/reshape.hpp"
namespace ov {
namespace test {
std::string ReshapeLayerTest::getTestCaseName(const testing::TestParamInfo<reshapeParams>& obj) {
std::vector<size_t> input_shape;
ov::element::Type model_type;
std::vector<int64_t> out_form_shapes;
std::string target_device;
bool special_zero;
std::tie(special_zero, model_type, input_shape, out_form_shapes, target_device) = obj.param;
std::ostringstream result;
result << "IS=" << ov::test::utils::vec2str(input_shape) << "_";
result << "OS=" << ov::test::utils::vec2str(out_form_shapes) << "_";
result << "specialZero=" << special_zero << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void ReshapeLayerTest::SetUp() {
std::vector<size_t> input_shape;
ov::element::Type model_type;
std::vector<int64_t> out_form_shapes;
bool special_zero;
std::tie(special_zero, model_type, input_shape, out_form_shapes, targetDevice) = this->GetParam();
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape));
auto const_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{out_form_shapes.size()}, out_form_shapes);
auto reshape = std::make_shared<ov::op::v1::Reshape>(param, const_node, special_zero);
function = std::make_shared<ov::Model>(reshape->outputs(), ov::ParameterVector{param}, "Reshape");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,32 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/result.hpp"
namespace ov {
namespace test {
std::string ResultLayerTest::getTestCaseName(const testing::TestParamInfo<ResultTestParamSet>& obj) {
std::vector<size_t> input_shape;
ov::element::Type model_type;
std::string target_device;
std::tie(input_shape, model_type, target_device) = obj.param;
std::ostringstream result;
result << "IS=" << ov::test::utils::vec2str(input_shape) << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void ResultLayerTest::SetUp() {
std::vector<size_t> input_shape;
ov::element::Type model_type;
std::tie(input_shape, model_type, targetDevice) = GetParam();
ov::ParameterVector params{std::make_shared<ov::op::v0::Parameter>(model_type, ov::Shape(input_shape))};
auto result = std::make_shared<ov::op::v0::Result>(params[0]);
function = std::make_shared<ov::Model>(result->outputs(), params, "result");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,139 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "openvino/pass/manager.hpp"
#include "transformations/op_conversions/bidirectional_sequences_decomposition.hpp"
#include "transformations/op_conversions/convert_sequences_to_tensor_iterator.hpp"
#include "shared_test_classes/single_op/rnn_sequence.hpp"
#include "common_test_utils/ov_tensor_utils.hpp"
// #include "ov_models/utils/ov_helpers.hpp"
using ov::test::utils::InputLayerType;
using ov::test::utils::SequenceTestsMode;
namespace ov {
namespace test {
std::string RNNSequenceTest::getTestCaseName(const testing::TestParamInfo<RNNSequenceParams> &obj) {
SequenceTestsMode mode;
size_t seq_lengths;
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;
ov::op::RecurrentSequenceDirection direction;
ov::element::Type model_type;
InputLayerType WRBType;
std::string target_device;
std::tie(mode, seq_lengths, batch, hidden_size, input_size, activations, clip, direction, WRBType,
model_type, target_device) = obj.param;
std::vector<std::vector<size_t>> input_shapes = {
{{batch, input_size}, {batch, hidden_size}, {batch, hidden_size}, {hidden_size, input_size},
{hidden_size, hidden_size}, {hidden_size}},
};
std::ostringstream result;
result << "mode=" << mode << "_";
result << "seq_lengths=" << seq_lengths << "_";
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 << "direction=" << direction << "_";
result << "clip=" << clip << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "targetDevice=" << target_device;
return result.str();
}
void RNNSequenceTest::SetUp() {
SequenceTestsMode mode;
size_t seq_lengths;
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;
ov::op::RecurrentSequenceDirection direction;
InputLayerType WRBType;
ov::element::Type model_type;
std::tie(mode, seq_lengths, batch, hidden_size, input_size, activations, clip, direction, WRBType,
model_type, targetDevice) = this->GetParam();
size_t num_directions = direction == ov::op::RecurrentSequenceDirection::BIDIRECTIONAL ? 2 : 1;
std::vector<ov::Shape> input_shapes = {
{{batch, seq_lengths, input_size}, {batch, num_directions, hidden_size}, {batch},
{num_directions, hidden_size, input_size}, {num_directions, hidden_size, hidden_size},
{num_directions, 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::shared_ptr<ov::Node> seq_lengths_node;
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::op::v0::Parameter>(ov::element::i64, input_shapes[2]);
param->set_friendly_name("seq_lengths");
params.push_back(param);
seq_lengths_node = param;
} else if (mode == ov::test::utils::SequenceTestsMode::CONVERT_TO_TI_RAND_SEQ_LEN_CONST ||
mode == ov::test::utils::SequenceTestsMode::PURE_SEQ_RAND_SEQ_LEN_CONST) {
auto tensor = ov::test::utils::create_and_fill_tensor(ov::element::i64, input_shapes[2], static_cast<float>(seq_lengths), 0.f);
seq_lengths_node = std::make_shared<ov::op::v0::Constant>(tensor);
} else {
std::vector<float> lengths(batch, seq_lengths);
seq_lengths_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, input_shapes[2], lengths);
}
const auto& W_shape = input_shapes[3];
const auto& R_shape = input_shapes[4];
const auto& B_shape = input_shapes[5];
std::shared_ptr<ov::Node> W, R, B;
if (WRBType == InputLayerType::PARAMETER) {
const auto W_param = std::make_shared<ov::op::v0::Parameter>(model_type, W_shape);
const auto R_param = std::make_shared<ov::op::v0::Parameter>(model_type, R_shape);
const auto B_param = std::make_shared<ov::op::v0::Parameter>(model_type, B_shape);
W = W_param;
R = R_param;
B = B_param;
params.push_back(W_param);
params.push_back(R_param);
params.push_back(B_param);
} else {
const auto W_tensor = ov::test::utils::create_and_fill_tensor(model_type, W_shape);
const auto R_tensor = ov::test::utils::create_and_fill_tensor(model_type, R_shape);
const auto B_tensor = ov::test::utils::create_and_fill_tensor(model_type, B_shape);
W = std::make_shared<ov::op::v0::Constant>(W_tensor);
R = std::make_shared<ov::op::v0::Constant>(R_tensor);
B = std::make_shared<ov::op::v0::Constant>(B_tensor);
}
auto rnn_sequence = std::make_shared<ov::op::v5::RNNSequence>(params[0], params[1], seq_lengths_node, W, R, B, hidden_size, direction,
activations, activations_alpha, activations_beta, clip);
function = std::make_shared<ov::Model>(rnn_sequence->outputs(), params, "rnn_sequence");
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)
manager.register_pass<ov::pass::BidirectionalRNNSequenceDecomposition>();
manager.register_pass<ov::pass::ConvertRNNSequenceToTensorIterator>();
manager.run_passes(function);
bool ti_found = ngraph::helpers::is_tensor_iterator_exist(function);
EXPECT_EQ(ti_found, true);
} else {
bool ti_found = ngraph::helpers::is_tensor_iterator_exist(function);
EXPECT_EQ(ti_found, false);
}
}
} // namespace test
} // namespace ov