Skip to content

Commit

Permalink
Refactor CumSumLayerTest, DeformablePSROIPoolingLayerTest, DepthToSpa…
Browse files Browse the repository at this point in the history
…ceLayerTest (openvinotoolkit#19870)

* Refactor CumSumLayerTest

* Refactor DeformablePSROIPoolingLayerTest

* Refactor DepthToSpaceLayerTest
  • Loading branch information
olpipi authored Oct 12, 2023
1 parent fa33693 commit cb61ad4
Show file tree
Hide file tree
Showing 17 changed files with 600 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@

#include <vector>

#include "single_layer_tests/cum_sum.hpp"
#include "single_op_tests/cum_sum.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace LayerTestsDefinitions;

const std::vector<std::vector<size_t>> shapes = {
{16},
{9, 15},
{16, 10, 12},
{5, 14, 5, 7},
{7, 8, 6, 7, 13},
{2, 3, 4, 2, 3, 5},
{4, 3, 6, 2, 3, 4, 5, 2, 3, 4},
namespace {
using ov::test::CumSumLayerTest;

const std::vector<std::vector<ov::Shape>> shapes_static = {
{{16}},
{{9, 15}},
{{16, 10, 12}},
{{5, 14, 5, 7}},
{{7, 8, 6, 7, 13}},
{{2, 3, 4, 2, 3, 5}},
{{4, 3, 6, 2, 3, 4, 5, 2, 3, 4}},
};

const std::vector<InferenceEngine::Precision> inputPrecision = {
InferenceEngine::Precision::I8,
InferenceEngine::Precision::U8,
InferenceEngine::Precision::I16,
InferenceEngine::Precision::I32,
InferenceEngine::Precision::FP32
const std::vector<ov::element::Type> model_types = {
ov::element::i8,
ov::element::u8,
ov::element::i16,
ov::element::i32,
ov::element::f32
};

const std::vector<int64_t> axes = { 0, 1, 2, 3, 4, 5, 6};
Expand All @@ -34,71 +35,77 @@ const std::vector<bool> exclusive = {true, false};
const std::vector<bool> reverse = {true, false};

const auto testCasesNegativeAxis = ::testing::Combine(
::testing::Values(std::vector<size_t>{4, 16, 3, 6, 5, 2}),
::testing::Values(InferenceEngine::Precision::FP32),
::testing::Values(ov::test::static_shapes_to_test_representation({{4, 16, 3, 6, 5, 2}})),
::testing::Values(ov::element::f32),
::testing::ValuesIn(negativeAxes),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_0 = ::testing::Combine(
::testing::ValuesIn(shapes),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes_static)),
::testing::ValuesIn(model_types),
::testing::Values(axes[0]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_1 = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>(shapes.begin() + 1, shapes.end())),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(
std::vector<std::vector<ov::Shape>>(shapes_static.begin() + 1, shapes_static.end()))),
::testing::ValuesIn(model_types),
::testing::Values(axes[1]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_2 = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>(shapes.begin() + 2, shapes.end())),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(
std::vector<std::vector<ov::Shape>>(shapes_static.begin() + 2, shapes_static.end()))),
::testing::ValuesIn(model_types),
::testing::Values(axes[2]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_3 = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>(shapes.begin() + 3, shapes.end())),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(
std::vector<std::vector<ov::Shape>>(shapes_static.begin() + 3, shapes_static.end()))),
::testing::ValuesIn(model_types),
::testing::Values(axes[3]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_4 = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>(shapes.begin() + 4, shapes.end())),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(
std::vector<std::vector<ov::Shape>>(shapes_static.begin() + 4, shapes_static.end()))),
::testing::ValuesIn(model_types),
::testing::Values(axes[4]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_5 = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>(shapes.begin() + 5, shapes.end())),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(
std::vector<std::vector<ov::Shape>>(shapes_static.begin() + 5, shapes_static.end()))),
::testing::ValuesIn(model_types),
::testing::Values(axes[5]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

const auto testCasesAxis_6 = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>(shapes.begin() + 6, shapes.end())),
::testing::ValuesIn(inputPrecision),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(
std::vector<std::vector<ov::Shape>>(shapes_static.begin() + 6, shapes_static.end()))),
::testing::ValuesIn(model_types),
::testing::Values(axes[6]),
::testing::ValuesIn(exclusive),
::testing::ValuesIn(reverse),
Expand All @@ -113,3 +120,4 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_3, CumSumLayerTest, testCasesAxi
INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_4, CumSumLayerTest, testCasesAxis_4, CumSumLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_5, CumSumLayerTest, testCasesAxis_5, CumSumLayerTest::getTestCaseName);
INSTANTIATE_TEST_SUITE_P(smoke_TestsCumSum_axis_6, CumSumLayerTest, testCasesAxis_6, CumSumLayerTest::getTestCaseName);
} // namespace
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@

#include <vector>

#include "single_layer_tests/deformable_psroi_pooling.hpp"
#include "single_op_tests/deformable_psroi_pooling.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace LayerTestsDefinitions;

namespace {
using ov::test::DeformablePSROIPoolingLayerTest;

std::vector<std::vector<ov::Shape>> shapes_static {
//dataShape, roisShape, offsetsShape
{{3, 8, 16, 16}, {10, 5}},
{{1, 8, 67, 32}, {10, 5}},
{{3, 8, 16, 16}, {10, 5}, {10, 2, 2, 2}},
{{1, 8, 67, 32}, {10, 5}, {10, 2, 2, 2}},
};

const auto deformablePSROIParams = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>{{3, 8, 16, 16}, {1, 8, 67, 32}}), // data input shape
::testing::Values(std::vector<size_t>{10, 5}), // rois input shape
// Empty offsets shape means test without optional third input
::testing::ValuesIn(std::vector<std::vector<size_t>>{{}, {10, 2, 2, 2}}), // offsets input shape
::testing::Values(2), // output_dim
::testing::Values(2), // group_size
::testing::ValuesIn(std::vector<float>{1.0f, 0.5f, 0.0625f}), // spatial scale
Expand All @@ -24,17 +28,20 @@ namespace {

const auto deformablePSROICases_test_params = ::testing::Combine(
deformablePSROIParams,
::testing::Values(InferenceEngine::Precision::FP32), // Net precision
::testing::Values(ov::test::utils::DEVICE_CPU)); // Device name
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes_static)),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU));

INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params,
DeformablePSROIPoolingLayerTest::getTestCaseName);


std::vector<std::vector<ov::Shape>> shapes_advanced_static {
//dataShape, roisShape, offsetsShape
{{2, 441, 63, 38}, {30, 5}, {30, 2, 3, 3}}
};

const auto deformablePSROIParams_advanced = ::testing::Combine(
::testing::ValuesIn(std::vector<std::vector<size_t>>{{2, 441, 63, 38}}), // data input shape
::testing::Values(std::vector<size_t>{30, 5}), // rois input shape
::testing::Values(std::vector<size_t>{30, 2, 3, 3}), // offsets input shape
::testing::Values(49), // output_dim
::testing::Values(3), // group_size
::testing::ValuesIn(std::vector<float>{0.0625}), // spatial scale
Expand All @@ -44,8 +51,9 @@ namespace {

const auto deformablePSROICases_test_params_advanced = ::testing::Combine(
deformablePSROIParams_advanced,
::testing::Values(InferenceEngine::Precision::FP32), // Net precision
::testing::Values(ov::test::utils::DEVICE_CPU)); // Device name
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(shapes_advanced_static)),
::testing::Values(ov::element::f32),
::testing::Values(ov::test::utils::DEVICE_CPU));

INSTANTIATE_TEST_SUITE_P(smoke_TestsDeformablePSROIPooling_advanced, DeformablePSROIPoolingLayerTest, deformablePSROICases_test_params_advanced,
DeformablePSROIPoolingLayerTest::getTestCaseName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,63 @@
// SPDX-License-Identifier: Apache-2.0
//

#include <vector>
#include <ngraph/opsets/opset3.hpp>

#include "single_layer_tests/depth_to_space.hpp"
#include "single_op_tests/depth_to_space.hpp"
#include "common_test_utils/test_constants.hpp"

using namespace LayerTestsDefinitions;
using namespace ngraph::opset3;

namespace {
const std::vector<InferenceEngine::Precision> inputPrecisions = {
InferenceEngine::Precision::FP32,
InferenceEngine::Precision::U8,
InferenceEngine::Precision::I16,
using ov::test::DepthToSpaceLayerTest;
using ov::op::v0::DepthToSpace;

const std::vector<ov::element::Type> model_types = {
ov::element::f32,
ov::element::u8,
ov::element::i16,
};

const std::vector<DepthToSpace::DepthToSpaceMode> modes = {
DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST,
DepthToSpace::DepthToSpaceMode::DEPTH_FIRST
};

const std::vector<std::vector<size_t >> inputShapesBS2 = {
{1, 4, 1, 1}, {1, 4, 2, 2}, {1, 4, 3, 3}, {2, 32, 3, 3}, {2, 16, 5, 4},
{1, 8, 1, 1, 1}, {1, 8, 2, 2, 2}, {1, 8, 3, 3, 3}, {2, 32, 3, 3, 3}, {2, 16, 5, 4, 6}
const std::vector<std::vector<ov::Shape>> input_shapes_bs2_static = {
{{1, 4, 1, 1}},
{{1, 4, 2, 2}},
{{1, 4, 3, 3}},
{{2, 32, 3, 3}},
{{2, 16, 5, 4}},
{{1, 8, 1, 1, 1}},
{{1, 8, 2, 2, 2}},
{{1, 8, 3, 3, 3}},
{{2, 32, 3, 3, 3}},
{{2, 16, 5, 4, 6}}
};

const auto DepthToSpaceBS2 = ::testing::Combine(
::testing::ValuesIn(inputShapesBS2),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_bs2_static)),
::testing::ValuesIn(model_types),
::testing::ValuesIn(modes),
::testing::Values(1, 2),
::testing::Values(ov::test::utils::DEVICE_CPU)
);

INSTANTIATE_TEST_SUITE_P(smoke_DepthToSpaceBS2, DepthToSpaceLayerTest, DepthToSpaceBS2, DepthToSpaceLayerTest::getTestCaseName);

const std::vector<std::vector<size_t >> inputShapesBS3 = {
{1, 9, 1, 1}, {1, 9, 2, 2}, {1, 9, 3, 3}, {2, 36, 3, 3}, {2, 27, 5, 4},
{1, 27, 1, 1, 1}, {1, 27, 2, 2, 2}, {1, 27, 3, 3, 3}, {2, 108, 3, 3, 3}, {2, 54, 5, 4, 6}
const std::vector<std::vector<ov::Shape>> input_shapes_bs3_static = {
{{1, 9, 1, 1}},
{{1, 9, 2, 2}},
{{1, 9, 3, 3}},
{{2, 36, 3, 3}},
{{2, 27, 5, 4}},
{{1, 27, 1, 1, 1}},
{{1, 27, 2, 2, 2}},
{{1, 27, 3, 3, 3}},
{{2, 108, 3, 3, 3}},
{{2, 54, 5, 4, 6}}
};

const auto DepthToSpaceBS3 = ::testing::Combine(
::testing::ValuesIn(inputShapesBS3),
::testing::ValuesIn(inputPrecisions),
::testing::ValuesIn(ov::test::static_shapes_to_test_representation(input_shapes_bs3_static)),
::testing::ValuesIn(model_types),
::testing::ValuesIn(modes),
::testing::Values(1, 3),
::testing::Values(ov::test::utils::DEVICE_CPU)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,9 @@ class ROIPoolingCPULayerTest : public testing::WithParamInterface<ROIPoolingCPUT
}
} else {
switch (funcInput.get_element_type()) {
case ngraph::element::f32: {
ov::test::utils::fill_data_roi<InferenceEngine::Precision::FP32>(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode);
break;
}
case ngraph::element::bf16: {
ov::test::utils::fill_data_roi<InferenceEngine::Precision::BF16>(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode);
case ov::element::f32:
case ov::element::bf16: {
ov::test::utils::fill_data_roi(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode);
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,9 @@ class ROIPoolingLayerGPUTest : public testing::WithParamInterface<ROIPoolingGPUT
}
} else {
switch (funcInput.get_element_type()) {
case ngraph::element::f32: {
ov::test::utils::fill_data_roi<InferenceEngine::Precision::FP32>(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode);
break;
}
case ngraph::element::bf16: {
ov::test::utils::fill_data_roi<InferenceEngine::Precision::BF16>(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode);
case ov::element::f32:
case ov::element::bf16: {
ov::test::utils::fill_data_roi(tensor, feat_map_shape[0] - 1, height, width, 1.f, is_roi_max_mode);
break;
}
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "shared_test_classes/single_op/cum_sum.hpp"

namespace ov {
namespace test {
TEST_P(CumSumLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "shared_test_classes/single_op/deformable_psroi_pooling.hpp"

namespace ov {
namespace test {
TEST_P(DeformablePSROIPoolingLayerTest, Inference) {
run();
}
} // namespace test
} // namespace ov
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#pragma once

#include "shared_test_classes/single_op/depth_to_space.hpp"

namespace ov {
namespace test {
TEST_P(DepthToSpaceLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov
Loading

0 comments on commit cb61ad4

Please sign in to comment.