Slice8, ShuffleChannels, ShapeOf layer tests to API2.0 (#19975)

* `Slice8LayerTest` to API2.0

* `ShuffleChannelsLayerTest` to API2.0

* `ShapeOfLayerTest` to API2.0
This commit is contained in:
Vitaliy Urusovskij 2023-09-21 16:36:26 +04:00 committed by GitHub
parent fc9dedfd6a
commit e5acf880ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 371 additions and 90 deletions

View File

@ -4,22 +4,22 @@
#include <vector>
#include "single_layer_tests/shape_of.hpp"
#include "single_op_tests/shape_of.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using ov::test::ShapeOfLayerTest;
namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::I32
const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::i32
};
INSTANTIATE_TEST_SUITE_P(smoke_Check, ShapeOfLayerTest,
::testing::Combine(
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::I64),
::testing::Values(std::vector<size_t>({10, 10, 10})),
::testing::ValuesIn(model_types),
::testing::Values(ov::element::i64),
::testing::Values(ov::test::static_shapes_to_test_representation({{10, 10, 10}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShapeOfLayerTest::getTestCaseName);
} // namespace

View File

@ -4,35 +4,31 @@
#include <vector>
#include "single_layer_tests/shuffle_channels.hpp"
#include "single_op_tests/shuffle_channels.hpp"
using namespace LayerTestsDefinitions;
using ov::test::ShuffleChannelsLayerTest;
namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::U8,
InferenceEngine::Precision::U16,
InferenceEngine::Precision::FP32
const std::vector<ov::element::Type> model_types = {
ov::element::u8,
ov::element::u16,
ov::element::f32
};
const std::vector<int> axes = {-4, -3, -2, -1, 0, 1, 2, 3};
const std::vector<int> groups = {1, 2, 3, 6};
const auto shuffleChannelsParams4D = ::testing::Combine(
const auto shuffle_channels_params_4D = ::testing::Combine(
::testing::ValuesIn(axes),
::testing::ValuesIn(groups)
);
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerTest,
::testing::Combine(
shuffleChannelsParams4D,
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t >({12, 18, 30, 36})),
shuffle_channels_params_4D,
::testing::ValuesIn(model_types),
::testing::Values(ov::test::static_shapes_to_test_representation({{12, 18, 30, 36}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShuffleChannelsLayerTest::getTestCaseName);
@ -40,60 +36,40 @@ INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels4D, ShuffleChannelsLayerTest,
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels6D, ShuffleChannelsLayerTest,
::testing::Combine(
::testing::Values(std::tuple<int, int>(2, 3)),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t >({24, 6, 12, 18, 30, 36})),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::static_shapes_to_test_representation({{24, 6, 12, 18, 30, 36}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShuffleChannelsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels5D, ShuffleChannelsLayerTest,
::testing::Combine(
::testing::Values(std::tuple<int, int>(2, 3)),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t >({6, 12, 18, 30, 36})),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::static_shapes_to_test_representation({{6, 12, 18, 30, 36}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShuffleChannelsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels3D, ShuffleChannelsLayerTest,
::testing::Combine(
::testing::Values(std::tuple<int, int>(1, 3)),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t >({18, 30, 36})),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::static_shapes_to_test_representation({{18, 30, 36}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShuffleChannelsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels2D, ShuffleChannelsLayerTest,
::testing::Combine(
::testing::Values(std::tuple<int, int>(1, 3)),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t >({18, 30})),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::static_shapes_to_test_representation({{18, 30}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShuffleChannelsLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_ShuffleChannels1D, ShuffleChannelsLayerTest,
::testing::Combine(
::testing::Values(std::tuple<int, int>(0, 3)),
::testing::ValuesIn(netPrecisions),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Precision::UNSPECIFIED),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(InferenceEngine::Layout::ANY),
::testing::Values(std::vector<size_t >({30})),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::static_shapes_to_test_representation({ov::Shape{30}})),
::testing::Values(ov::test::utils::DEVICE_CPU)),
ShuffleChannelsLayerTest::getTestCaseName);

View File

@ -4,28 +4,28 @@
#include <vector>
#include "single_layer_tests/slice.hpp"
#include "single_op_tests/slice.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
using namespace ov::test;
using ov::test::Slice8LayerTest;
using ov::test::Slice8SpecificParams;
namespace {
const std::vector<ElementType> inputPrecisions = {
ElementType::f32,
ElementType::bf16,
ElementType::i8
const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::bf16,
ov::element::i8
};
const std::vector<ElementType> inputPrecisionsOther = {
ElementType::i64,
ElementType::i32,
ElementType::i16,
ElementType::u8
const std::vector<ov::element::Type> model_types_extra = {
ov::element::i64,
ov::element::i32,
ov::element::i16,
ov::element::u8
};
std::vector<Slice8SpecificParams> staticParams = {
std::vector<Slice8SpecificParams> static_params = {
Slice8SpecificParams{ {{{}, {{ 16 }}}}, { 4 }, { 12 }, { 1 }, { 0 } },
Slice8SpecificParams{ {{{}, {{ 16 }}}}, { 0 }, { 8 }, { 2 }, { 0 } },
Slice8SpecificParams{ {{{}, {{ 20, 10, 5 }}}}, { 0, 0}, { 10, 20}, { 1, 1 }, { 1, 0 } },
@ -68,30 +68,20 @@ std::vector<Slice8SpecificParams> staticParams = {
INSTANTIATE_TEST_SUITE_P(smoke_Static, Slice8LayerTest,
::testing::Combine(
::testing::ValuesIn(staticParams),
::testing::ValuesIn(inputPrecisions),
::testing::Values(ElementType::undefined),
::testing::Values(ElementType::undefined),
::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(static_params),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
Slice8LayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_PrecisionTransformation, Slice8LayerTest,
::testing::Combine(
::testing::Values(staticParams[0]),
::testing::ValuesIn(inputPrecisionsOther),
::testing::Values(ElementType::undefined),
::testing::Values(ElementType::undefined),
::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::Values(static_params[0]),
::testing::ValuesIn(model_types_extra),
::testing::Values(ov::test::utils::DEVICE_CPU)),
Slice8LayerTest::getTestCaseName);
std::vector<Slice8SpecificParams> dynamicParams = {
std::vector<Slice8SpecificParams> dynamic_params = {
Slice8SpecificParams{ {{{ -1 }, {{ 8 }, { 16 }}}}, { 4 }, { 12 }, { 1 }, { 0 } },
Slice8SpecificParams{ {{{ ov::Dimension(2, 20) }, {{ 5 }, { 15 }}}}, { 0 }, { 8 }, { 2 }, { 0 } },
Slice8SpecificParams{ {{{ -1, -1, -1 }, {{ 20, 10, 5 }, {5, 10, 20}}}}, { 0, 0}, { 10, 20}, { 1, 1 }, { 1, 0 } },
@ -115,13 +105,8 @@ std::vector<Slice8SpecificParams> dynamicParams = {
INSTANTIATE_TEST_SUITE_P(smoke_Dynamic, Slice8LayerTest,
::testing::Combine(
::testing::ValuesIn(dynamicParams),
::testing::ValuesIn(inputPrecisions),
::testing::Values(ElementType::undefined),
::testing::Values(ElementType::undefined),
::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(dynamic_params),
::testing::ValuesIn(model_types),
::testing::Values(ov::test::utils::DEVICE_CPU)),
Slice8LayerTest::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/shape_of.hpp"
namespace ov {
namespace test {
TEST_P(ShapeOfLayerTest, 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/shuffle_channels.hpp"
namespace ov {
namespace test {
TEST_P(ShuffleChannelsLayerTest, 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/slice.hpp"
namespace ov {
namespace test {
TEST_P(Slice8LayerTest, Inference) {
run();
}
} // 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 <tuple>
#include <string>
#include <vector>
#include <memory>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
ov::element::Type, // Model type
ov::element::Type, // Output type
std::vector<InputShape>, // Input shapes
ov::test::TargetDevice // Device name
> shapeOfParams;
class ShapeOfLayerTest : public testing::WithParamInterface<shapeOfParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(testing::TestParamInfo<ParamType> obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,38 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <vector>
#include <string>
#include <memory>
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
int, // axis
int // group
> shuffleChannelsSpecificParams;
typedef std::tuple<
shuffleChannelsSpecificParams,
ov::element::Type, // Model type
std::vector<InputShape>, // Input shapes
ov::test::TargetDevice // Device name
> shuffleChannelsLayerTestParamsSet;
class ShuffleChannelsLayerTest : public testing::WithParamInterface<shuffleChannelsLayerTestParamsSet>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<shuffleChannelsLayerTestParamsSet>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,40 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2018-2023 Intel Corporation
//
#pragma once
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include "shared_test_classes/base/layer_test_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
struct Slice8SpecificParams {
std::vector<InputShape> shapes;
std::vector<int64_t> start;
std::vector<int64_t> stop;
std::vector<int64_t> step;
std::vector<int64_t> axes;
};
using Slice8Params = std::tuple<
Slice8SpecificParams, // Slice-8 specific parameters
ov::element::Type, // Model type
ov::test::TargetDevice // Device name
>;
class Slice8LayerTest : public testing::WithParamInterface<Slice8Params>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<Slice8Params> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,46 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/shape_of.hpp"
namespace ov {
namespace test {
std::string ShapeOfLayerTest::getTestCaseName(testing::TestParamInfo<shapeOfParams> obj) {
std::vector<InputShape> input_shapes;
ov::element::Type model_type, out_type;
std::string target_device;
std::tie(model_type, out_type, input_shapes, target_device) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < input_shapes.size(); i++) {
result << ov::test::utils::partialShape2str({input_shapes[i].first})
<< (i < input_shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < input_shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < input_shapes.size(); j++) {
result << ov::test::utils::vec2str(input_shapes[j].second[i]) << (j < input_shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "modelType=" << model_type.to_string() << "_";
result << "outType=" << out_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void ShapeOfLayerTest::SetUp() {
std::vector<InputShape> input_shapes;
ov::element::Type model_type;
std::tie(model_type, outType, input_shapes, targetDevice) = this->GetParam();
init_input_shapes(input_shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto shape_of = std::make_shared<ov::op::v3::ShapeOf>(param, outType);
function = std::make_shared<ov::Model>(shape_of->outputs(), ov::ParameterVector{param}, "ShapeOf");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,55 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/shuffle_channels.hpp"
namespace ov {
namespace test {
std::string ShuffleChannelsLayerTest::getTestCaseName(const testing::TestParamInfo<shuffleChannelsLayerTestParamsSet>& obj) {
shuffleChannelsSpecificParams test_params;
ov::element::Type model_type;
std::vector<InputShape> input_shapes;
std::string target_device;
std::tie(test_params, model_type, input_shapes, target_device) = obj.param;
int axis, group;
std::tie(axis, group) = test_params;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < input_shapes.size(); i++) {
result << ov::test::utils::partialShape2str({input_shapes[i].first})
<< (i < input_shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < input_shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < input_shapes.size(); j++) {
result << ov::test::utils::vec2str(input_shapes[j].second[i]) << (j < input_shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "Axis=" << std::to_string(axis) << "_";
result << "Group=" << std::to_string(group) << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void ShuffleChannelsLayerTest::SetUp() {
shuffleChannelsSpecificParams test_params;
ov::element::Type model_type;
std::vector<InputShape> input_shapes;
std::string target_device;
std::tie(test_params, model_type, input_shapes, targetDevice) = this->GetParam();
int axis, group;
std::tie(axis, group) = test_params;
init_input_shapes(input_shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto shuffle_channels = std::make_shared<ov::op::v0::ShuffleChannels>(param, axis, group);
function = std::make_shared<ov::Model>(shuffle_channels->outputs(), ov::ParameterVector{param}, "ShuffleChannels");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,64 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/slice.hpp"
namespace ov {
namespace test {
std::string Slice8LayerTest::getTestCaseName(const testing::TestParamInfo<Slice8Params> &obj) {
Slice8SpecificParams 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.shapes.size(); i++) {
result << ov::test::utils::partialShape2str({params.shapes[i].first})
<< (i < params.shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < params.shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < params.shapes.size(); j++) {
result << ov::test::utils::vec2str(params.shapes[j].second[i]) << (j < params.shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "start=" << ov::test::utils::vec2str(params.start) << "_";
result << "stop=" << ov::test::utils::vec2str(params.stop) << "_";
result << "step=" << ov::test::utils::vec2str(params.step) << "_";
result << "axes=" << ov::test::utils::vec2str(params.axes) << "_";
result << "modelType=" << model_type.to_string() << "_";
result << "trgDev=" << target_device;
return result.str();
}
void Slice8LayerTest::SetUp() {
Slice8SpecificParams test_params;
ov::element::Type model_type;
std::tie(test_params, model_type, targetDevice) = this->GetParam();
init_input_shapes(test_params.shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
ov::Shape const_shape = {test_params.start.size()};
ASSERT_EQ(shape_size(const_shape), test_params.stop.size());
ASSERT_EQ(shape_size(const_shape), test_params.step.size());
auto begin_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.start.data());
auto end_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.stop.data());
auto stride_node = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.step.data());
std::shared_ptr<ov::op::v8::Slice> slice;
if (!test_params.axes.empty()) {
ASSERT_EQ(shape_size(const_shape), test_params.axes.size());
auto axesNode = std::make_shared<ov::op::v0::Constant>(ov::element::i64, const_shape, test_params.axes.data());
slice = std::make_shared<ov::op::v8::Slice>(param, begin_node, end_node, stride_node, axesNode);
} else {
slice = std::make_shared<ov::op::v8::Slice>(param, begin_node, end_node, stride_node);
}
function = std::make_shared<ov::Model>(slice->outputs(), ov::ParameterVector{param}, "Slice-8");
}
} // namespace test
} // namespace ov