[GPU] Refactor AdaptivePooling, BatchNorm, BatchToSpace (#20357)

* adaptive_pooling

* batch_norm

* batch_to_space
This commit is contained in:
Andrei Gorbachev 2023-10-12 05:25:53 +01:00 committed by GitHub
parent d41e7fcc30
commit 57279938c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 86 additions and 141 deletions

View File

@ -5,24 +5,21 @@
#include <string>
#include <vector>
#include "single_layer_tests/adaptive_pooling.hpp"
#include "single_op_tests/adaptive_pooling.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace ngraph::helpers;
using namespace LayerTestsDefinitions;
using namespace ngraph::element;
namespace {
using ov::test::AdaPoolLayerTest;
const std::vector<std::string> poolingModes = {"max", "avg"};
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16,
const std::vector<ov::element::Type> types = {
ov::element::f16,
ov::element::f32
};
const std::vector<std::vector<size_t>> inputShapes1D = {
{1, 3, 5},
{1, 1, 17},
const std::vector<std::vector<ov::Shape>> inputShapes1D = {
{{1, 3, 5}},
{{1, 1, 17}},
};
const std::vector<std::vector<int>> outputShapes1D = {
{2},
@ -31,16 +28,16 @@ const std::vector<std::vector<int>> outputShapes1D = {
INSTANTIATE_TEST_SUITE_P(smoke_AdaptivePooling1D, AdaPoolLayerTest,
::testing::Combine(
::testing::ValuesIn(inputShapes1D),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inputShapes1D)),
::testing::ValuesIn(outputShapes1D),
::testing::ValuesIn(poolingModes),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(types),
::testing::Values(ov::test::utils::DEVICE_GPU)),
AdaPoolLayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> inputShapes2D = {
{1, 3, 4, 6},
{1, 1, 17, 5},
const std::vector<std::vector<ov::Shape>> inputShapes2D = {
{{1, 3, 4, 6}},
{{1, 1, 17, 5}},
};
const std::vector<std::vector<int>> outputShapes2D = {
{2, 4},
@ -49,16 +46,16 @@ const std::vector<std::vector<int>> outputShapes2D = {
INSTANTIATE_TEST_SUITE_P(smoke_AdaptivePooling2D, AdaPoolLayerTest,
::testing::Combine(
::testing::ValuesIn(inputShapes2D),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inputShapes2D)),
::testing::ValuesIn(outputShapes2D),
::testing::ValuesIn(poolingModes),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(types),
::testing::Values(ov::test::utils::DEVICE_GPU)),
AdaPoolLayerTest::getTestCaseName);
const std::vector<std::vector<size_t>> inputShapes3D = {
{1, 1, 3, 3, 3},
{1, 3, 5, 7, 11},
const std::vector<std::vector<ov::Shape>> inputShapes3D = {
{{1, 1, 3, 3, 3}},
{{1, 3, 5, 7, 11}},
};
const std::vector<std::vector<int>> outputShapes3D = {
{2, 2, 2},
@ -67,10 +64,10 @@ const std::vector<std::vector<int>> outputShapes3D = {
INSTANTIATE_TEST_SUITE_P(smoke_AdaptivePooling3D, AdaPoolLayerTest,
::testing::Combine(
::testing::ValuesIn(inputShapes3D),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(inputShapes3D)),
::testing::ValuesIn(outputShapes3D),
::testing::ValuesIn(poolingModes),
::testing::ValuesIn(netPrecisions),
::testing::ValuesIn(types),
::testing::Values(ov::test::utils::DEVICE_GPU)),
AdaPoolLayerTest::getTestCaseName);

View File

@ -4,14 +4,13 @@
#include <vector>
#include "single_layer_tests/batch_norm.hpp"
using namespace LayerTestsDefinitions;
#include "single_op_tests/batch_norm.hpp"
namespace {
const std::vector<InferenceEngine::Precision> netPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::FP16
using ov::test::BatchNormLayerTest;
const std::vector<ov::element::Type> types = {
ov::element::f16,
ov::element::f32
};
const std::vector<double> epsilon = {
@ -19,23 +18,19 @@ const std::vector<double> epsilon = {
1e-5,
1e-4
};
const std::vector<std::vector<size_t>> inputShapes = {
{1, 3},
{2, 5},
{1, 3, 10},
{1, 3, 1, 1},
{2, 5, 4, 4},
};
const std::vector<std::vector<ov::Shape>> inputShapes = {
{{1, 3}},
{{2, 5}},
{{1, 3, 10}},
{{1, 3, 1, 1}},
{{2, 5, 4, 4}},
};
const auto batchNormParams = testing::Combine(
testing::ValuesIn(epsilon),
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(inputShapes),
testing::ValuesIn(types),
testing::ValuesIn(ov::test::static_shapes_to_test_representation(inputShapes)),
testing::Values(ov::test::utils::DEVICE_GPU)
);

View File

@ -4,172 +4,125 @@
#include <vector>
#include "single_layer_tests/batch_to_space.hpp"
#include "single_op_tests/batch_to_space.hpp"
#include "common_test_utils/test_constants.hpp"
using namespace LayerTestsDefinitions;
namespace {
using ov::test::BatchToSpaceLayerTest;
using ov::test::batchToSpaceParamsTuple;
auto bts_only_test_cases = []() {
return std::vector<batchToSpaceParamsTuple>{batchToSpaceParamsTuple({1, 2, 2},
{0, 0, 0},
{0, 0, 0},
{4, 1, 1},
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 1}})),
ov::element::f32,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 1, 1, 1},
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 1, 1}})),
ov::element::f32,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 3, 1, 1},
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 3, 1, 1}})),
ov::element::f32,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 1, 2, 2},
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 2, 2}})),
ov::element::f32,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{8, 1, 1, 2},
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{8, 1, 1, 2}})),
ov::element::f32,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 3, 2, 2},
{0, 0, 1, 0, 3},
{0, 0, 2, 0, 0},
{24, 1, 2, 1, 2},
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{24, 1, 2, 1, 2}})),
ov::element::f32,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 1, 1, 1},
InferenceEngine::Precision::I8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 1, 1}})),
ov::element::i8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 3, 1, 1},
InferenceEngine::Precision::I8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 3, 1, 1}})),
ov::element::i8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 1, 2, 2},
InferenceEngine::Precision::I8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 2, 2}})),
ov::element::i8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{8, 1, 1, 2},
InferenceEngine::Precision::I8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{8, 1, 1, 2}})),
ov::element::i8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 3, 2, 2},
{0, 0, 1, 0, 3},
{0, 0, 2, 0, 0},
{24, 1, 2, 1, 2},
InferenceEngine::Precision::I8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{24, 1, 2, 1, 2}})),
ov::element::i8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 1, 1, 1},
InferenceEngine::Precision::U8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 1, 1}})),
ov::element::u8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 3, 1, 1},
InferenceEngine::Precision::U8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 3, 1, 1}})),
ov::element::u8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{4, 1, 2, 2},
InferenceEngine::Precision::U8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{4, 1, 2, 2}})),
ov::element::u8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 2, 2},
{0, 0, 0, 0},
{0, 0, 0, 0},
{8, 1, 1, 2},
InferenceEngine::Precision::U8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{8, 1, 1, 2}})),
ov::element::u8,
ov::test::utils::DEVICE_GPU),
batchToSpaceParamsTuple({1, 1, 3, 2, 2},
{0, 0, 1, 0, 3},
{0, 0, 2, 0, 0},
{24, 1, 2, 1, 2},
InferenceEngine::Precision::U8,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Precision::UNSPECIFIED,
InferenceEngine::Layout::ANY,
InferenceEngine::Layout::ANY,
ov::test::static_shapes_to_test_representation(std::vector<ov::Shape>({
{24, 1, 2, 1, 2}})),
ov::element::u8,
ov::test::utils::DEVICE_GPU)};
};