StridedSliceLayerTest and SqueezeUnsqueezeLayerTest to API2.0 (#19955)

* `StridedSliceLayerTest` to API2.0

* `SqueezeUnsqueezeLayerTest` to API2.0

* Fix CppLint
This commit is contained in:
Vitaliy Urusovskij 2023-09-21 17:08:51 +04:00 committed by GitHub
parent c4adf80ec6
commit 318106d17d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 371 additions and 99 deletions

View File

@ -4,61 +4,67 @@
#include <vector>
#include "single_layer_tests/squeeze_unsqueeze.hpp"
#include "single_op_tests/squeeze_unsqueeze.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::SqueezeUnsqueezeLayerTest;
namespace {
std::map<std::vector<size_t>, std::vector<std::vector<int>>> axesVectors = {
{{1, 1, 1, 1}, {{-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}, {0, 1, 2}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}}},
{{1, 2, 3, 4}, {{0}}},
{{2, 1, 3, 4}, {{1}}},
{{1}, {{-1}, {0}}},
{{1, 2}, {{0}}},
{{2, 1}, {{1}, {-1}}},
std::map<std::vector<ov::Shape>, std::vector<std::vector<int>>> raw_axes = {
{{{1, 1, 1, 1}}, {{-1}, {0}, {1}, {2}, {3}, {0, 1}, {0, 2}, {0, 3}, {1, 2}, {2, 3}, {0, 1, 2}, {0, 2, 3}, {1, 2, 3}, {0, 1, 2, 3}}},
{{{1, 2, 3, 4}}, {{0}}},
{{{2, 1, 3, 4}}, {{1}}},
{{{1}}, {{-1}, {0}}},
{{{1, 2}}, {{0}}},
{{{2, 1}}, {{1}, {-1}}},
};
std::map<std::vector<size_t>, std::vector<std::vector<int>>> emptyAxesVectors = {
{{1, 1, 1, 1}, {{}}},
{{1, 2, 3, 4}, {{}}},
{{2, 1, 3, 4}, {{}}},
{{1}, {{}}},
{{1, 2}, {{}}},
{{2, 1}, {{}}},
std::map<std::vector<ov::Shape>, std::vector<std::vector<int>>> raw_empty_axes = {
{{{1, 1, 1, 1}}, {{}}},
{{{1, 2, 3, 4}}, {{}}},
{{{2, 1, 3, 4}}, {{}}},
{{{1}}, {{}}},
{{{1, 2}}, {{}}},
{{{2, 1}}, {{}}},
};
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16
auto combined_axes = ov::test::utils::combineParams(raw_axes);
auto combined_empty_axes = ov::test::utils::combineParams(raw_empty_axes);
auto prepare_cases = [](const std::vector<std::pair<std::vector<ov::Shape>, std::vector<int>>>& raw_axes) {
std::vector<std::pair<std::vector<ov::test::InputShape>, std::vector<int>>> cases;
for (const auto& raw_case : raw_axes)
cases.emplace_back(ov::test::static_shapes_to_test_representation(raw_case.first),
raw_case.second);
return cases;
};
const std::vector<ngraph::helpers::SqueezeOpType> opTypes = {
ngraph::helpers::SqueezeOpType::SQUEEZE,
ngraph::helpers::SqueezeOpType::UNSQUEEZE
auto axes = prepare_cases(combined_axes);
auto empty_axes = prepare_cases(combined_empty_axes);
const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::f16
};
const std::vector<ov::test::utils::SqueezeOpType> opTypes = {
ov::test::utils::SqueezeOpType::SQUEEZE,
ov::test::utils::SqueezeOpType::UNSQUEEZE
};
INSTANTIATE_TEST_SUITE_P(smoke_Basic, SqueezeUnsqueezeLayerTest,
::testing::Combine(
::testing::ValuesIn(ov::test::utils::combineParams(axesVectors)),
::testing::ValuesIn(axes),
::testing::ValuesIn(opTypes),
::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(ov::test::utils::DEVICE_CPU)),
SqueezeUnsqueezeLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_Basic_emptyAxes, SqueezeUnsqueezeLayerTest,
::testing::Combine(
::testing::ValuesIn(ov::test::utils::combineParams(emptyAxesVectors)),
::testing::Values(ngraph::helpers::SqueezeOpType::SQUEEZE),
::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(empty_axes),
::testing::Values(ov::test::utils::SqueezeOpType::SQUEEZE),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
SqueezeUnsqueezeLayerTest::getTestCaseName);
} // namespace

View File

@ -4,119 +4,130 @@
#include <vector>
#include "single_layer_tests/strided_slice.hpp"
#include "single_op_tests/strided_slice.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::StridedSliceLayerTest;
namespace {
struct RawParams {
std::vector<ov::Shape> input_shape;
std::vector<int64_t> begin;
std::vector<int64_t> end;
std::vector<int64_t> strides;
std::vector<int64_t> begin_mask;
std::vector<int64_t> end_mask;
std::vector<int64_t> new_axis_mask;
std::vector<int64_t> shrink_axis_mask;
std::vector<int64_t> ellipsis_axis_mask;
};
std::vector<StridedSliceSpecificParams> ss_only_test_cases = {
StridedSliceSpecificParams{ { 16 }, { 4 }, { 12 }, { 1 },
std::vector<RawParams> raw_test_cases = {
RawParams{ {{ 16 }}, { 4 }, { 12 }, { 1 },
{ 0 }, { 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 16 }, { 0 }, { 8 }, { 2 },
RawParams{ {{ 16 }}, { 0 }, { 8 }, { 2 },
{ 1 }, { 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 128, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1 },
RawParams{ {{ 128, 1 }}, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1 },
{ 0, 1, 1 }, { 0, 1, 1 }, { 1, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 128, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1},
RawParams{ {{ 128, 1 }}, { 0, 0, 0 }, { 0, 0, 0 }, { 1, 1, 1},
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 1, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 2, 3 }, { 1, 0 }, { 2, 3 }, { 1, 1 },
RawParams{ {{ 2, 3 }}, { 1, 0 }, { 2, 3 }, { 1, 1 },
{ 0, 0 }, { 0, 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 10, 3 }, { 0, 0 }, { 20, 20 }, { 1, 1 },
RawParams{ {{ 10, 3 }}, { 0, 0 }, { 20, 20 }, { 1, 1 },
{ 0, 1 }, { 0, 1 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, -1, 0 }, { 0, 0, 0 }, { 1, 1, 1 },
RawParams{ {{ 1, 12, 100 }}, { 0, -1, 0 }, { 0, 0, 0 }, { 1, 1, 1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 1, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, 9, 0 }, { 0, 11, 0 }, { 1, 1, 1 },
RawParams{ {{ 1, 12, 100 }}, { 0, 9, 0 }, { 0, 11, 0 }, { 1, 1, 1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, 1, 0 }, { 0, -1, 0 }, { 1, 1, 1 },
RawParams{ {{ 1, 12, 100 }}, { 0, 1, 0 }, { 0, -1, 0 }, { 1, 1, 1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 2, 12, 100 }, { 0, 9, 0 }, { 0, 7, 0 }, { -1, -1, -1 },
RawParams{ {{ 2, 12, 100 }}, { 0, 9, 0 }, { 0, 7, 0 }, { -1, -1, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 2, 12, 100 }, { 0, 7, 0 }, { 0, 9, 0 }, { -1, 1, -1 },
RawParams{ {{ 2, 12, 100 }}, { 0, 7, 0 }, { 0, 9, 0 }, { -1, 1, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, 4, 0 }, { 0, 9, 0 }, { -1, 2, -1 },
RawParams{ {{ 1, 12, 100 }}, { 0, 4, 0 }, { 0, 9, 0 }, { -1, 2, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, 4, 0 }, { 0, 10, 0 }, { -1, 2, -1 },
RawParams{ {{ 1, 12, 100 }}, { 0, 4, 0 }, { 0, 10, 0 }, { -1, 2, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, 9, 0 }, { 0, 4, 0 }, { -1, -2, -1 },
RawParams{ {{ 1, 12, 100 }}, { 0, 9, 0 }, { 0, 4, 0 }, { -1, -2, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 2, 12, 100 }, { 0, 10, 0 }, { 0, 4, 0 }, { -1, -2, -1 },
RawParams{ {{ 2, 12, 100 }}, { 0, 10, 0 }, { 0, 4, 0 }, { -1, -2, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, 11, 0 }, { 0, 0, 0 }, { -1, -2, -1 },
RawParams{ {{ 1, 12, 100 }}, { 0, 11, 0 }, { 0, 0, 0 }, { -1, -2, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100 }, { 0, -6, 0 }, { 0, -8, 0 }, { -1, -2, -1 },
RawParams{ {{ 1, 12, 100 }}, { 0, -6, 0 }, { 0, -8, 0 }, { -1, -2, -1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 20, 10, 5 }, { 0, 0, 0 }, { 3, 10, 0 }, { 1, 1, 1 },
RawParams{ {{ 20, 10, 5 }}, { 0, 0, 0 }, { 3, 10, 0 }, { 1, 1, 1 },
{ 0, 0, 1 }, { 0, 0, 1 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 10, 20 }, { 0, 0, 2 }, { 0, 0, 1000 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 20 }}, { 0, 0, 2 }, { 0, 0, 1000 }, { 1, 1, 1 },
{ 1, 1, 0 }, { 1, 1, 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 10, 10 }, { 0, 1, 0 }, { 0, 1000, 0 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 10 }}, { 0, 1, 0 }, { 0, 1000, 0 }, { 1, 1, 1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 10, 4 }, { 0, 0, 0 }, { 0, 0, 2 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 4 }}, { 0, 0, 0 }, { 0, 0, 2 }, { 1, 1, 1 },
{ 1, 1, 0 }, { 1, 1, 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 10, 4 }, { 0, 0, 2 }, { 0, 0, 1000 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 4 }}, { 0, 0, 2 }, { 0, 0, 1000 }, { 1, 1, 1 },
{ 1, 1, 0 }, { 1, 1, 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 10, 2 }, { 0, 0, 0 }, { 0, 0, 1 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 2 }}, { 0, 0, 0 }, { 0, 0, 1 }, { 1, 1, 1 },
{ 1, 1, 0 }, { 1, 1, 0 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 10, 2 }, { 0, 0, 0 }, { 1000, 0, 0 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 2 }}, { 0, 0, 0 }, { 1000, 0, 0 }, { 1, 1, 1 },
{ 0, 1, 1 }, { 0, 1, 1 }, { }, { }, { } },
StridedSliceSpecificParams{ { 1, 10, 2 }, { 0, 0, 0 }, { 0, 1000, 0 }, { 1, 1, 1 },
RawParams{ {{ 1, 10, 2 }}, { 0, 0, 0 }, { 0, 1000, 0 }, { 1, 1, 1 },
{ 1, 0, 1 }, { 1, 0, 1 }, { }, { }, { } },
StridedSliceSpecificParams{ { 20, 10, 5 }, { 0, 3 }, { 0, 4 }, { 1, 1 },
RawParams{ {{ 20, 10, 5 }}, { 0, 3 }, { 0, 4 }, { 1, 1 },
{ 1, 0 }, { 1, 0 }, { }, { }, { 1, 0 } },
StridedSliceSpecificParams{ { 20, 10, 5 }, { 0, 0 }, { 0, -1 }, { 1, 1 },
RawParams{ {{ 20, 10, 5 }}, { 0, 0 }, { 0, -1 }, { 1, 1 },
{ 1, 0 }, { 1, 0 }, { }, { }, { 1, 0 } },
StridedSliceSpecificParams{ { 20, 10, 5 }, { 0, 0 }, { 0, -1 }, { 1, 1 },
RawParams{ {{ 20, 10, 5 }}, { 0, 0 }, { 0, -1 }, { 1, 1 },
{ 1, 0 }, { 1, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
StridedSliceSpecificParams{ { 1, 12, 100, 1, 1 }, { 0, -1, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 },
RawParams{ {{ 1, 12, 100, 1, 1 }}, { 0, -1, 0, 0 }, { 0, 0, 0, 0 }, { 1, 1, 1, 1 },
{ 1, 0, 1, 0 }, { 1, 0, 1, 0 }, { }, { 0, 1, 0, 1 }, {} },
StridedSliceSpecificParams{ { 2, 2, 2, 2 }, { 0, 0, 0, 0 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 },
RawParams{ {{ 2, 2, 2, 2 }}, { 0, 0, 0, 0 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 },
{ 1, 1, 1, 1}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 2, 2 }, { 0, 0 }, { 2, 2 }, { 1, 1 },
RawParams{ {{ 2, 2, 2, 2 }}, { 0, 0 }, { 2, 2 }, { 1, 1 },
{ 1, 1 }, { 1, 1 }, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 3, 3 }, { 0, -2, -2 }, { 2, -1, -1 }, { 1, 1, 1 },
RawParams{ {{ 2, 2, 3, 3 }}, { 0, -2, -2 }, { 2, -1, -1 }, { 1, 1, 1 },
{ 1, 0 }, { 1, 0 }, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 },
RawParams{ {{ 2, 2, 2, 2 }}, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 },
{ 0, 0, 0, 0}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 2, 2 }, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 },
RawParams{ {{ 2, 2, 2, 2 }}, { 1, 1, 1, 1 }, { 2, 2, 2, 2 }, { 1, 1, 1, 1 },
{ 0, 0, 0, 0}, { 0, 0, 0, 0}, {}, {}, {} },
StridedSliceSpecificParams{ { 1, 2, 6, 4 }, { 0, 0, 4, 0 }, { 1, 2, 6, 4 }, { 1, 1, 1, 1 },
RawParams{ {{ 1, 2, 6, 4 }}, { 0, 0, 4, 0 }, { 1, 2, 6, 4 }, { 1, 1, 1, 1 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, {}, {}, {} },
StridedSliceSpecificParams{ { 1, 2, 6, 4 }, { 0, 0, -3, 0 }, { 1, 2, 6, 4 }, { 1, 1, 1, 1 },
RawParams{ {{ 1, 2, 6, 4 }}, { 0, 0, -3, 0 }, { 1, 2, 6, 4 }, { 1, 1, 1, 1 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, {}, {}, {} },
StridedSliceSpecificParams{ { 1, 2, 6, 4 }, { 0, 0, 4, 0 }, { 1, 2, 6, 4 }, { 1, 1, 1, 1 },
RawParams{ {{ 1, 2, 6, 4 }}, { 0, 0, 4, 0 }, { 1, 2, 6, 4 }, { 1, 1, 1, 1 },
{ 1, 1, 0, 1}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 10, 2, 2, 2 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 2, 1, 1, 1 },
RawParams{ {{ 10, 2, 2, 2 }}, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 2, 1, 1, 1 },
{ 1, 1, 1, 1}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 4, 3 }, { 0, 0, 0, 0 }, { 2, 2, 4, 3 }, { 1, 1, 2, 1 },
RawParams{ {{ 2, 2, 4, 3 }}, { 0, 0, 0, 0 }, { 2, 2, 4, 3 }, { 1, 1, 2, 1 },
{ 1, 1, 1, 1}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 4, 2 }, { 1, 0, 0, 1 }, { 2, 2, 4, 2 }, { 1, 1, 2, 1 },
RawParams{ {{ 2, 2, 4, 2 }}, { 1, 0, 0, 1 }, { 2, 2, 4, 2 }, { 1, 1, 2, 1 },
{ 0, 1, 1, 0}, { 1, 1, 0, 0}, {}, {}, {} },
StridedSliceSpecificParams{ { 1, 2, 4, 2 }, { 1, 0, 0, 0 }, { 1, 2, 4, 2 }, { 1, 1, -2, -1 },
RawParams{ {{ 1, 2, 4, 2 }}, { 1, 0, 0, 0 }, { 1, 2, 4, 2 }, { 1, 1, -2, -1 },
{ 1, 1, 1, 1}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 2, 4, 2 }, { 1, 0, 0, 0 }, { 1, 2, 4, 2 }, { 1, 1, -2, -1 },
RawParams{ {{ 2, 2, 4, 2 }}, { 1, 0, 0, 0 }, { 1, 2, 4, 2 }, { 1, 1, -2, -1 },
{ 0, 1, 1, 1}, { 1, 1, 1, 1}, {}, {}, {} },
StridedSliceSpecificParams{ { 2, 3, 4, 5, 6 }, { 0, 1, 0, 0, 0 }, { 2, 3, 4, 5, 6 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 3, 4, 5, 6 }}, { 0, 1, 0, 0, 0 }, { 2, 3, 4, 5, 6 }, { 1, 1, 1, 1, 1 },
{ 1, 0, 1, 1, 1}, { 1, 0, 1, 1, 1 }, {}, { 0, 1, 0, 0, 0 }, {} },
StridedSliceSpecificParams{ { 2, 3, 4, 5, 6 }, { 0, 0, 3, 0, 0 }, { 2, 3, 4, 3, 6 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 3, 4, 5, 6 }}, { 0, 0, 3, 0, 0 }, { 2, 3, 4, 3, 6 }, { 1, 1, 1, 1, 1 },
{ 1, 1, 0, 1, 1}, { 1, 1, 0, 0, 1 }, {}, { 0, 0, 1, 0, 0 }, {} },
StridedSliceSpecificParams{ { 2, 3, 4, 5, 6 }, { 0, 0, 0, 0, 3 }, { 1, 3, 4, 5, 6 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 3, 4, 5, 6 }}, { 0, 0, 0, 0, 3 }, { 1, 3, 4, 5, 6 }, { 1, 1, 1, 1, 1 },
{ 0, 1, 1, 1, 0}, { 0, 1, 1, 1, 0 }, {}, { 1, 0, 0, 0, 1 }, {} },
StridedSliceSpecificParams{ { 2, 3, 4, 5 }, { 0, 0, 0, 0, 0 }, { 0, 2, 3, 4, 5 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 3, 4, 5 }}, { 0, 0, 0, 0, 0 }, { 0, 2, 3, 4, 5 }, { 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 0, 0, 0, 0 }, {}, {} },
StridedSliceSpecificParams{ { 2, 3, 4, 5 }, { 0, 0, 0, 0, 0 }, { 0, 2, 3, 4, 5 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 3, 4, 5 }}, { 0, 0, 0, 0, 0 }, { 0, 2, 3, 4, 5 }, { 1, 1, 1, 1, 1 },
{ 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 0, 0, 1, 0, 0 }, {}, {} },
StridedSliceSpecificParams{ { 10, 12 }, { -1, 1 }, { -9999, 0 }, { -1, 1 },
RawParams{ {{ 10, 12 }}, { -1, 1 }, { -9999, 0 }, { -1, 1 },
{ 0, 1 }, { 0, 1 }, { 0, 0 }, { 0, 0 }, { 0, 0 } },
StridedSliceSpecificParams{ { 5, 5, 5, 5 }, { -1, 0, -1, 0 }, { -50, 0, -60, 0 }, { -1, 1, -1, 1 },
RawParams{ {{ 5, 5, 5, 5 }}, { -1, 0, -1, 0 }, { -50, 0, -60, 0 }, { -1, 1, -1, 1 },
{ 0, 0, 0, 0 }, { 0, 1, 0, 1 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } },
StridedSliceSpecificParams{ { 1, 2, 4 }, { 0, 2000, 3, 5 }, { 0, 0, 0, 2 }, { 1, 1, 1, 1 },
RawParams{ {{ 1, 2, 4 }}, { 0, 2000, 3, 5 }, { 0, 0, 0, 2 }, { 1, 1, 1, 1 },
{ 1, 0, 1, 1 }, { 1, 0, 1, 0 }, { 0, 1, 0, 0 }, { }, { } },
StridedSliceSpecificParams{ { 2, 2, 4, 4 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 2, 0 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 2, 4, 4 }}, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 2, 0 }, { 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 1 }, { 1, 1, 1, 0, 1 }, { 0, 1, 0, 0, 0 }, { }, { } },
StridedSliceSpecificParams{ { 2, 2, 2, 4, 4 }, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 2, 0 }, { 1, 1, 1, 1, 1 },
RawParams{ {{ 2, 2, 2, 4, 4 }}, { 0, 0, 0, 1, 0 }, { 0, 0, 0, 2, 0 }, { 1, 1, 1, 1, 1 },
{ 1, 1, 1, 0, 1 }, { 1, 1, 1, 0, 1 }, { }, { 0, 1, 0, 0, 0 }, { } },
StridedSliceSpecificParams{{1, 6400, 3, 85},
RawParams{ {{1, 6400, 3, 85}},
{0, 0},
{0, 2},
{1, 1},
@ -127,17 +138,28 @@ std::vector<StridedSliceSpecificParams> ss_only_test_cases = {
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}},
};
auto ss_test_cases = [](const std::vector<RawParams>& raw_test_cases) {
std::vector<ov::test::StridedSliceSpecificParams> cases;
for (const auto& raw_case : raw_test_cases)
cases.push_back(ov::test::StridedSliceSpecificParams{
ov::test::static_shapes_to_test_representation(raw_case.input_shape),
raw_case.begin,
raw_case.end,
raw_case.strides,
raw_case.begin_mask,
raw_case.end_mask,
raw_case.new_axis_mask,
raw_case.shrink_axis_mask,
raw_case.ellipsis_axis_mask});
return cases;
}(raw_test_cases);
INSTANTIATE_TEST_SUITE_P(
smoke, StridedSliceLayerTest,
::testing::Combine(
::testing::ValuesIn(ss_only_test_cases),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(ov::test::utils::DEVICE_CPU),
::testing::Values(std::map<std::string, std::string>())),
::testing::ValuesIn(ss_test_cases),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU)),
StridedSliceLayerTest::getTestCaseName);
} // namespace

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/squeeze_unsqueeze.hpp"
namespace ov {
namespace test {
TEST_P(SqueezeUnsqueezeLayerTest, 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/strided_slice.hpp"
namespace ov {
namespace test {
TEST_P(StridedSliceLayerTest, Inference) {
run();
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,34 @@
// 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 ShapeAxesTuple = std::pair<std::vector<InputShape>, std::vector<int>>;
typedef std::tuple<
ShapeAxesTuple, // InputShape (required), Squeeze indexes (if empty treated as non-existent)
ov::test::utils::SqueezeOpType, // Op type
ov::element::Type, // Model type
ov::test::TargetDevice // Target device name
> squeezeParams;
class SqueezeUnsqueezeLayerTest : public testing::WithParamInterface<squeezeParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<squeezeParams>& 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 <memory>
#include <string>
#include <tuple>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
struct StridedSliceSpecificParams {
std::vector<InputShape> input_shape;
std::vector<int64_t> begin;
std::vector<int64_t> end;
std::vector<int64_t> strides;
std::vector<int64_t> begin_mask;
std::vector<int64_t> end_mask;
std::vector<int64_t> new_axis_mask;
std::vector<int64_t> shrink_axis_mask;
std::vector<int64_t> ellipsis_axis_mask;
};
using StridedSliceParams = std::tuple<
StridedSliceSpecificParams,
ov::element::Type, // Model type
ov::test::TargetDevice // Device name
>;
class StridedSliceLayerTest : public testing::WithParamInterface<StridedSliceParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<StridedSliceParams> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,67 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/squeeze_unsqueeze.hpp"
namespace ov {
namespace test {
std::string SqueezeUnsqueezeLayerTest::getTestCaseName(const testing::TestParamInfo<squeezeParams>& obj) {
ov::element::Type model_type;
ShapeAxesTuple shape_item;
std::string targetDevice;
ov::test::utils::SqueezeOpType op_type;
std::tie(shape_item, op_type, model_type, targetDevice) = obj.param;
std::ostringstream result;
const char separator = '_';
result << "IS=(";
for (size_t i = 0lu; i < shape_item.first.size(); i++) {
result << ov::test::utils::partialShape2str({shape_item.first[i].first})
<< (i < shape_item.first.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shape_item.first.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shape_item.first.size(); j++) {
result << ov::test::utils::vec2str(shape_item.first[j].second[i]) << (j < shape_item.first.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "OpType=" << op_type << separator;
result << "Axes=" << (shape_item.second.empty() ? "default" : ov::test::utils::vec2str(shape_item.second)) << separator;
result << "modelType=" << model_type.to_string() << separator;
result << "trgDev=" << targetDevice;
return result.str();
}
void SqueezeUnsqueezeLayerTest::SetUp() {
ov::element::Type model_type;
std::vector<InputShape> input_shapes;
std::vector<int> axes;
ShapeAxesTuple shape_item;
ov::test::utils::SqueezeOpType op_type;
std::tie(shape_item, op_type, model_type, targetDevice) = GetParam();
std::tie(input_shapes, axes) = shape_item;
init_input_shapes(input_shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
std::shared_ptr<ov::Node> op;
if (axes.empty() && op_type == ov::test::utils::SqueezeOpType::SQUEEZE) {
op = std::make_shared<ov::op::v0::Squeeze>(param);
} else {
auto constant = std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{axes.size()}, axes);
if (op_type == op_type == ov::test::utils::SqueezeOpType::SQUEEZE)
op = std::make_shared<ov::op::v0::Squeeze>(param, constant);
else
op = std::make_shared<ov::op::v0::Unsqueeze>(param, constant);
}
auto name = op_type == ov::test::utils::SqueezeOpType::SQUEEZE ? "Squeeze" : "Unsqueeze";
function = std::make_shared<ov::Model>(op->outputs(), ov::ParameterVector{param}, name);
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,70 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/strided_slice.hpp"
namespace ov {
namespace test {
std::string StridedSliceLayerTest::getTestCaseName(const testing::TestParamInfo<StridedSliceParams> &obj) {
StridedSliceSpecificParams params;
ov::element::Type model_type;
std::string target_device;
std::tie(params, model_type, target_device) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < params.input_shape.size(); i++) {
result << ov::test::utils::partialShape2str({params.input_shape[i].first})
<< (i < params.input_shape.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < params.input_shape.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < params.input_shape.size(); j++) {
result << ov::test::utils::vec2str(params.input_shape[j].second[i]) << (j < params.input_shape.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "modelType=" << model_type.to_string() << "_";
result << "begin=" << ov::test::utils::vec2str(params.begin) << "_";
result << "end=" << ov::test::utils::vec2str(params.end) << "_";
result << "stride=" << ov::test::utils::vec2str(params.strides) << "_";
result << "begin_m=" << ov::test::utils::vec2str(params.begin_mask) << "_";
result << "end_m=" << ov::test::utils::vec2str(params.end_mask) << "_";
result << "new_axis_m=" << (params.new_axis_mask.empty() ? "def" : ov::test::utils::vec2str(params.new_axis_mask)) << "_";
result << "shrink_m=" << (params.shrink_axis_mask.empty() ? "def" : ov::test::utils::vec2str(params.shrink_axis_mask)) << "_";
result << "ellipsis_m=" << (params.ellipsis_axis_mask.empty() ? "def" : ov::test::utils::vec2str(params.ellipsis_axis_mask)) << "_";
result << "trgDev=" << target_device;
return result.str();
}
void StridedSliceLayerTest::SetUp() {
StridedSliceSpecificParams ssParams;
ov::element::Type model_type;
std::tie(ssParams, model_type, targetDevice) = this->GetParam();
init_input_shapes(ssParams.input_shape);
ASSERT_EQ(ssParams.begin.size(), ssParams.end.size());
ASSERT_EQ(ssParams.begin.size(), ssParams.strides.size());
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
ov::Shape const_shape = {ssParams.begin.size()};
auto begin_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, ssParams.begin.data());
auto end_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, ssParams.end.data());
auto stride_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, ssParams.strides.data());
auto stridedSlice = std::make_shared<ov::op::v1::StridedSlice>(param,
begin_node,
end_node,
stride_node,
ssParams.begin_mask,
ssParams.end_mask,
ssParams.new_axis_mask,
ssParams.shrink_axis_mask,
ssParams.ellipsis_axis_mask);
auto result = std::make_shared<ov::op::v0::Result>(stridedSlice);
function = std::make_shared<ov::Model>(ov::ResultVector{result}, ov::ParameterVector{param}, "StridedSlice");
}
} // namespace test
} // namespace ov