Refactor CumSumLayerTest, DeformablePSROIPoolingLayerTest, DepthToSpaceLayerTest (#19870)

* Refactor CumSumLayerTest

* Refactor DeformablePSROIPoolingLayerTest

* Refactor DepthToSpaceLayerTest
This commit is contained in:
Oleg Pipikin 2023-10-12 20:27:55 +02:00 committed by GitHub
parent fa33693c4a
commit cb61ad46bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 599 additions and 124 deletions

View File

@ -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;
namespace {
using ov::test::CumSumLayerTest;
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},
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};
@ -34,8 +35,8 @@ 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),
@ -43,8 +44,8 @@ const auto testCasesNegativeAxis = ::testing::Combine(
);
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),
@ -52,8 +53,9 @@ const auto testCasesAxis_0 = ::testing::Combine(
);
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),
@ -61,8 +63,9 @@ const auto testCasesAxis_1 = ::testing::Combine(
);
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),
@ -70,8 +73,9 @@ const auto testCasesAxis_2 = ::testing::Combine(
);
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),
@ -79,8 +83,9 @@ const auto testCasesAxis_3 = ::testing::Combine(
);
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),
@ -88,8 +93,9 @@ const auto testCasesAxis_4 = ::testing::Combine(
);
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),
@ -97,8 +103,9 @@ const auto testCasesAxis_5 = ::testing::Combine(
);
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),
@ -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

View File

@ -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
@ -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
@ -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);

View File

@ -2,20 +2,17 @@
// 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 = {
@ -23,14 +20,22 @@ const std::vector<DepthToSpace::DepthToSpaceMode> modes = {
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)
@ -38,14 +43,22 @@ const auto DepthToSpaceBS2 = ::testing::Combine(
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)

View File

@ -155,12 +155,9 @@ protected:
}
} 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:

View File

@ -148,12 +148,9 @@ protected:
}
} 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:

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/cum_sum.hpp"
namespace ov {
namespace test {
TEST_P(CumSumLayerTest, 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/deformable_psroi_pooling.hpp"
namespace ov {
namespace test {
TEST_P(DeformablePSROIPoolingLayerTest, 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/depth_to_space.hpp"
namespace ov {
namespace test {
TEST_P(DepthToSpaceLayerTest, Inference) {
run();
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,33 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <tuple>
#include <string>
#include "shared_test_classes/base/ov_subgraph.hpp"
namespace ov {
namespace test {
typedef std::tuple<
std::vector<InputShape>, // Input shapes
ov::element::Type, // Model type
int64_t, // Axis
bool, // Exclusive
bool, // Reverse
std::string> cumSumParams; // Device name
class CumSumLayerTest : public testing::WithParamInterface<cumSumParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<cumSumParams>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,39 @@
// 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 deformablePSROISpecificParams = std::tuple<
int64_t, // output_dim
int64_t, // group_size
float, // spatial_scale
std::vector<int64_t>, // spatial_bins_x_y
float, // trans_std
int64_t>; // part_size
using deformablePSROILayerTestParams = std::tuple<
deformablePSROISpecificParams,
std::vector<InputShape>, // data input shape
ov::element::Type, // Net type
std::string>; // Device name
class DeformablePSROIPoolingLayerTest : public testing::WithParamInterface<deformablePSROILayerTestParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<deformablePSROILayerTestParams>& obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -0,0 +1,33 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <string>
#include <tuple>
#include <vector>
#include "shared_test_classes/base/ov_subgraph.hpp"
#include "openvino/op/depth_to_space.hpp"
namespace ov {
namespace test {
using depthToSpaceParamsTuple = typename std::tuple<
std::vector<InputShape>, // Input shape
ov::element::Type, // Model type
ov::op::v0::DepthToSpace::DepthToSpaceMode, // Mode
std::size_t, // Block size
std::string>; // Device name>
class DepthToSpaceLayerTest : public testing::WithParamInterface<depthToSpaceParamsTuple>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<depthToSpaceParamsTuple> &obj);
protected:
void SetUp() override;
};
} // namespace test
} // namespace ov

View File

@ -855,6 +855,28 @@ ov::runtime::Tensor generate(const std::shared_ptr<ngraph::op::v8::Softmax>& nod
return generate(std::dynamic_pointer_cast<ov::Node>(node), port, elemType, targetShape);
}
ov::runtime::Tensor generate(const
std::shared_ptr<ov::op::v1::DeformablePSROIPooling>& node,
size_t port,
const ov::element::Type& elemType,
const ov::Shape& targetShape) {
if (port == 1) {
ov::Tensor tensor(elemType, targetShape);
auto data_input_shape = node->input(0).get_shape();
const auto batch_distrib = data_input_shape[0] - 1;
const auto height = data_input_shape[2] / node->get_spatial_scale();
const auto width = data_input_shape[3] / node->get_spatial_scale();
ov::test::utils::fill_data_roi(tensor, batch_distrib, height, width, 1.0f, true);
return tensor;
} else if (port == 2) {
ov::Tensor tensor(elemType, targetShape);
ov::test::utils::fill_tensor_random(tensor, 1.8, -0.9);
return tensor;
}
return generate(std::static_pointer_cast<ov::Node>(node), port, elemType, targetShape);
}
ov::runtime::Tensor generate(const
std::shared_ptr<ngraph::op::v3::ScatterNDUpdate>& node,
size_t port,

View File

@ -0,0 +1,54 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/cum_sum.hpp"
namespace ov {
namespace test {
std::string CumSumLayerTest::getTestCaseName(const testing::TestParamInfo<cumSumParams>& obj) {
std::vector<InputShape> shapes;
ov::element::Type model_type;
int64_t axis;
bool exclusive, reverse;
std::string targetDevice;
std::tie(shapes, model_type, axis, exclusive, reverse, targetDevice) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "Precision=" << model_type.get_type_name() << "_";
result << "Axis=" << axis << "_";
result << "Exclusive=" << (exclusive ? "TRUE" : "FALSE") << "_";
result << "Reverse=" << (reverse ? "TRUE" : "FALSE") << "_";
result << "TargetDevice=" << targetDevice;
return result.str();
}
void CumSumLayerTest::SetUp() {
std::vector<InputShape> shapes;
ov::element::Type model_type;
bool exclusive, reverse;
int64_t axis;
std::tie(shapes, model_type, axis, exclusive, reverse, targetDevice) = this->GetParam();
init_input_shapes(shapes);
const auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
const auto axis_node = std::make_shared<ov::op::v0::Constant>(ov::element::Type_t::i64, ov::Shape{}, std::vector<int64_t>{axis});
const auto cum_sum = std::make_shared<ov::op::v0::CumSum>(param, axis_node, exclusive, reverse);
auto result = std::make_shared<ov::op::v0::Result>(cum_sum);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "cumsum");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,110 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/deformable_psroi_pooling.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/result.hpp"
#include "openvino/op/deformable_psroi_pooling.hpp"
namespace ov {
namespace test {
std::string DeformablePSROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo<deformablePSROILayerTestParams>& obj) {
std::vector<InputShape> shapes;
ov::element::Type model_type;
int64_t outputDim;
int64_t groupSize;
float spatialScale;
std::vector<int64_t> spatialBinsXY;
float trans_std;
int64_t part_size;
std::string target_device;
deformablePSROISpecificParams opParams;
std::tie(opParams, shapes, model_type, target_device) = obj.param;
std::tie(outputDim, groupSize, spatialScale, spatialBinsXY,
trans_std, part_size) = opParams;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "out_dim=" << outputDim << "_";
result << "group_size=" << groupSize << "_";
result << "scale=" << spatialScale << "_";
result << "bins_x=" << spatialBinsXY[0] << "_";
result << "bins_y=" << spatialBinsXY[1] << "_";
result << "trans_std=" << trans_std << "_";
result << "part_size=" << part_size << "_";
result << "prec=" << model_type.get_type_name() << "_";
result << "dev=" << target_device;
return result.str();
}
void DeformablePSROIPoolingLayerTest::SetUp() {
std::vector<InputShape> shapes;
ov::element::Type model_type;
int64_t outputDim;
int64_t groupSize;
std::string mode = "bilinear_deformable";
std::vector<int64_t> spatialBinsXY;
float trans_std, spatial_scale;
int64_t part_size;
deformablePSROISpecificParams opParams;
std::tie(opParams, shapes, model_type, targetDevice) = this->GetParam();
std::tie(outputDim, groupSize, spatial_scale, spatialBinsXY, trans_std, part_size) = opParams;
init_input_shapes(shapes);
ov::ParameterVector params;
std::shared_ptr<ov::op::v1::DeformablePSROIPooling> defomablePSROIPooling;
if (2 == inputDynamicShapes.size()) { // Test without optional third input (offsets)
params = ov::ParameterVector{std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[0]),
std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[1])};
defomablePSROIPooling = std::make_shared<ov::op::v1::DeformablePSROIPooling>(params[0],
params[1],
outputDim,
spatial_scale,
groupSize,
mode,
spatialBinsXY[0],
spatialBinsXY[1],
trans_std,
part_size);
} else {
params = ov::ParameterVector{std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[0]),
std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[1]),
std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[2])};
defomablePSROIPooling = std::make_shared<ov::op::v1::DeformablePSROIPooling>(params[0],
params[1],
params[2],
outputDim,
spatial_scale,
groupSize,
mode,
spatialBinsXY[0],
spatialBinsXY[1],
trans_std,
part_size);
}
auto result = std::make_shared<ov::op::v0::Result>(defomablePSROIPooling);
function = std::make_shared<ov::Model>(result, params, "deformable_psroi_pooling");
}
} // namespace test
} // namespace ov

View File

@ -0,0 +1,72 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "shared_test_classes/single_op/depth_to_space.hpp"
#include "openvino/op/parameter.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/result.hpp"
#include "openvino/op/depth_to_space.hpp"
namespace ov {
namespace test {
using ov::op::v0::DepthToSpace;
static inline std::string DepthToSpaceModeToString(const DepthToSpace::DepthToSpaceMode& mode) {
static std::map<DepthToSpace::DepthToSpaceMode, std::string> names = {
{DepthToSpace::DepthToSpaceMode::BLOCKS_FIRST, "BLOCKS_FIRST"},
{DepthToSpace::DepthToSpaceMode::DEPTH_FIRST, "DEPTH_FIRST"},
};
auto i = names.find(mode);
if (i != names.end())
return i->second;
else
throw std::runtime_error("Unsupported DepthToSpaceMode");
}
std::string DepthToSpaceLayerTest::getTestCaseName(const testing::TestParamInfo<depthToSpaceParamsTuple> &obj) {
std::vector<InputShape> shapes;
DepthToSpace::DepthToSpaceMode mode;
std::size_t block_size;
ov::element::Type model_type;
std::string device_name;
std::tie(shapes, model_type, mode, block_size, device_name) = obj.param;
std::ostringstream result;
result << "IS=(";
for (size_t i = 0lu; i < shapes.size(); i++) {
result << ov::test::utils::partialShape2str({shapes[i].first}) << (i < shapes.size() - 1lu ? "_" : "");
}
result << ")_TS=";
for (size_t i = 0lu; i < shapes.front().second.size(); i++) {
result << "{";
for (size_t j = 0lu; j < shapes.size(); j++) {
result << ov::test::utils::vec2str(shapes[j].second[i]) << (j < shapes.size() - 1lu ? "_" : "");
}
result << "}_";
}
result << "inPrc=" << model_type.get_type_name() << "_";
result << "M=" << DepthToSpaceModeToString(mode) << "_";
result << "BS=" << block_size << "_";
result << "targetDevice=" << device_name << "_";
return result.str();
}
void DepthToSpaceLayerTest::SetUp() {
std::vector<InputShape> shapes;
DepthToSpace::DepthToSpaceMode mode;
std::size_t block_size;
ov::element::Type model_type;
std::tie(shapes, model_type, mode, block_size, targetDevice) = this->GetParam();
init_input_shapes(shapes);
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front());
auto d2s = std::make_shared<ov::op::v0::DepthToSpace>(param, mode, block_size);
auto result = std::make_shared<ov::op::v0::Result>(d2s);
function = std::make_shared<ov::Model>(result, ov::ParameterVector{param}, "DepthToSpace");
}
} // namespace test
} // namespace ov

View File

@ -158,52 +158,14 @@ inline void fill_data_roi(InferenceEngine::Blob::Ptr& blob,
fill_roi_raw_ptr<T>(data, blob->size(), range, height, width, omega, is_roi_max_mode, seed);
}
template <InferenceEngine::Precision::ePrecision PRC>
inline void fill_data_roi(ov::runtime::Tensor& tensor,
const uint32_t range,
const int height,
const int width,
const float omega,
const bool is_roi_max_mode,
const int seed = 1) {
using T = typename InferenceEngine::PrecisionTrait<PRC>::value_type;
auto* data = static_cast<T*>(tensor.data());
std::default_random_engine random(seed);
std::uniform_int_distribution<int32_t> distribution(0, range);
void fill_data_roi(ov::runtime::Tensor& tensor,
const uint32_t range,
const int height,
const int width,
const float omega,
const bool is_roi_max_mode,
const int seed = 1);
const int max_y = (is_roi_max_mode) ? (height - 1) : 1;
const int max_x = (is_roi_max_mode) ? (width - 1) : 1;
float center_h = (max_y) / 2.0f;
float center_w = (max_x) / 2.0f;
for (size_t i = 0; i < tensor.get_size(); i += 5) {
data[i] = static_cast<T>(distribution(random));
const float x0 = (center_w + width * 0.3f * sin(static_cast<float>(i + 1) * omega));
const float x1 = (center_w + width * 0.3f * sin(static_cast<float>(i + 3) * omega));
data[i + 1] = static_cast<T>(is_roi_max_mode ? std::floor(x0) : x0);
data[i + 3] = static_cast<T>(is_roi_max_mode ? std::floor(x1) : x1);
if (data[i + 3] < data[i + 1]) {
std::swap(data[i + 1], data[i + 3]);
}
if (data[i + 1] < 0)
data[i + 1] = 0;
if (data[i + 3] > max_x)
data[i + 3] = static_cast<T>(max_x);
const float y0 = (center_h + height * 0.3f * sin(static_cast<float>(i + 2) * omega));
const float y1 = (center_h + height * 0.3f * sin(static_cast<float>(i + 4) * omega));
data[i + 2] = static_cast<T>(is_roi_max_mode ? std::floor(y0) : y0);
data[i + 4] = static_cast<T>(is_roi_max_mode ? std::floor(y1) : y1);
if (data[i + 4] < data[i + 2]) {
std::swap(data[i + 2], data[i + 4]);
}
if (data[i + 2] < 0)
data[i + 2] = 0;
if (data[i + 4] > max_y)
data[i + 4] = static_cast<T>(max_y);
}
}
OPENVINO_SUPPRESS_DEPRECATED_END
template <class T>

View File

@ -250,6 +250,88 @@ size_t byte_size(const InferenceEngine::TensorDesc& tdesc) {
}
OPENVINO_SUPPRESS_DEPRECATED_END
template <ov::element::Type_t type>
inline void fill_data_roi_impl(ov::runtime::Tensor& tensor,
const uint32_t range,
const int height,
const int width,
const float omega,
const bool is_roi_max_mode,
const int seed = 1) {
using T = typename ov::fundamental_type_for<type>;
auto* data = static_cast<T*>(tensor.data());
std::default_random_engine random(seed);
std::uniform_int_distribution<int32_t> distribution(0, range);
const int max_y = (is_roi_max_mode) ? (height - 1) : 1;
const int max_x = (is_roi_max_mode) ? (width - 1) : 1;
float center_h = (max_y) / 2.0f;
float center_w = (max_x) / 2.0f;
for (size_t i = 0; i < tensor.get_size(); i += 5) {
data[i] = static_cast<T>(distribution(random));
const float x0 = (center_w + width * 0.3f * sin(static_cast<float>(i + 1) * omega));
const float x1 = (center_w + width * 0.3f * sin(static_cast<float>(i + 3) * omega));
data[i + 1] = static_cast<T>(is_roi_max_mode ? std::floor(x0) : x0);
data[i + 3] = static_cast<T>(is_roi_max_mode ? std::floor(x1) : x1);
if (data[i + 3] < data[i + 1]) {
std::swap(data[i + 1], data[i + 3]);
}
if (data[i + 1] < 0)
data[i + 1] = 0;
if (data[i + 3] > max_x)
data[i + 3] = static_cast<T>(max_x);
const float y0 = (center_h + height * 0.3f * sin(static_cast<float>(i + 2) * omega));
const float y1 = (center_h + height * 0.3f * sin(static_cast<float>(i + 4) * omega));
data[i + 2] = static_cast<T>(is_roi_max_mode ? std::floor(y0) : y0);
data[i + 4] = static_cast<T>(is_roi_max_mode ? std::floor(y1) : y1);
if (data[i + 4] < data[i + 2]) {
std::swap(data[i + 2], data[i + 4]);
}
if (data[i + 2] < 0)
data[i + 2] = 0;
if (data[i + 4] > max_y)
data[i + 4] = static_cast<T>(max_y);
}
}
void fill_data_roi(ov::runtime::Tensor& tensor,
const uint32_t range,
const int height,
const int width,
const float omega,
const bool is_roi_max_mode,
const int seed) {
#define CASE(X) \
case X: \
fill_data_roi_impl<X>(tensor, range, height, width, omega, is_roi_max_mode, seed); \
break;
auto element_type = tensor.get_element_type();
switch (element_type) {
CASE(ov::element::f64)
CASE(ov::element::f32)
CASE(ov::element::f16)
CASE(ov::element::bf16)
CASE(ov::element::u1)
CASE(ov::element::u4)
CASE(ov::element::u8)
CASE(ov::element::u32)
CASE(ov::element::u16)
CASE(ov::element::u64)
CASE(ov::element::i4)
CASE(ov::element::i8)
CASE(ov::element::i16)
CASE(ov::element::i32)
CASE(ov::element::i64)
default:
OPENVINO_THROW("Wrong precision specified: ", element_type);
}
#undef CASE
}
void fill_data_with_broadcast(ov::Tensor& tensor, ov::Tensor& values) {
constexpr size_t MAX_N_DIMS = 7; // Suppose it's enough