ROIPooling, ROIAlign layer tests to API2.0 (#20086)
* `ROIPoolingLayerTest` to API2.0 * `ROIAlignLayerTest` to API2.0
This commit is contained in:
committed by
GitHub
parent
e87d147f4c
commit
8fff47caf9
@@ -4,30 +4,32 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/roi_align.hpp"
|
||||
#include "single_op_tests/roi_align.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
using ov::test::ROIAlignLayerTest;
|
||||
|
||||
namespace {
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPRCs = {
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::FP32
|
||||
const std::vector<ov::element::Type> model_types = {
|
||||
ov::element::f16,
|
||||
ov::element::f32
|
||||
};
|
||||
|
||||
const auto ROIAlignCases_average = ::testing::Combine(
|
||||
::testing::ValuesIn(
|
||||
std::vector<std::vector<size_t>> {
|
||||
{ 3, 8, 16, 16 },
|
||||
{ 2, 1, 16, 16 },
|
||||
{ 2, 1, 8, 16 }}),
|
||||
::testing::Values(std::vector<size_t>{ 2, 4 }),
|
||||
ov::test::static_shapes_to_test_representation(
|
||||
std::vector<std::vector<ov::Shape>>{
|
||||
{{ 3, 8, 16, 16 }},
|
||||
{{ 2, 1, 16, 16 }},
|
||||
{{ 2, 1, 8, 16 }}})),
|
||||
::testing::Values(ov::Shape{ 2, 4 }),
|
||||
::testing::Values(2),
|
||||
::testing::Values(2),
|
||||
::testing::ValuesIn(std::vector<float> { 1, 0.625 }),
|
||||
::testing::Values(2),
|
||||
::testing::Values("avg"),
|
||||
::testing::ValuesIn(netPRCs),
|
||||
::testing::ValuesIn(model_types),
|
||||
::testing::Values(ov::test::utils::DEVICE_CPU)
|
||||
);
|
||||
|
||||
@@ -35,18 +37,21 @@ INSTANTIATE_TEST_SUITE_P(smoke_TestsROIAlign_average, ROIAlignLayerTest, ROIAlig
|
||||
|
||||
const auto ROIAlignCases_max = ::testing::Combine(
|
||||
::testing::ValuesIn(
|
||||
std::vector<std::vector<size_t>> {
|
||||
{ 2, 8, 20, 20 },
|
||||
{ 2, 1, 20, 20 },
|
||||
{ 2, 1, 10, 20 }}),
|
||||
::testing::Values(std::vector<size_t>{ 2, 4 }),
|
||||
ov::test::static_shapes_to_test_representation(
|
||||
std::vector<std::vector<ov::Shape>>{
|
||||
{{ 2, 8, 20, 20 }},
|
||||
{{ 2, 1, 20, 20 }},
|
||||
{{ 2, 1, 10, 20 }}})),
|
||||
::testing::Values(ov::Shape{ 2, 4 }),
|
||||
::testing::Values(2),
|
||||
::testing::Values(2),
|
||||
::testing::ValuesIn(std::vector<float> { 1, 0.625 }),
|
||||
::testing::Values(2),
|
||||
::testing::Values("max"),
|
||||
::testing::ValuesIn(netPRCs),
|
||||
::testing::ValuesIn(model_types),
|
||||
::testing::Values(ov::test::utils::DEVICE_CPU)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_TestsROIAlign_max, ROIAlignLayerTest, ROIAlignCases_max, ROIAlignLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -4,62 +4,72 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "single_layer_tests/roi_pooling.hpp"
|
||||
#include "single_op_tests/roi_pooling.hpp"
|
||||
#include "common_test_utils/test_constants.hpp"
|
||||
|
||||
using namespace LayerTestsDefinitions;
|
||||
using ov::test::ROIPoolingLayerTest;
|
||||
|
||||
const std::vector<std::vector<size_t>> inShapes = {
|
||||
{1, 3, 8, 8},
|
||||
{3, 4, 50, 50}
|
||||
namespace {
|
||||
|
||||
const std::vector<ov::Shape> param_shapes = {
|
||||
{{1, 3, 8, 8}},
|
||||
{{3, 4, 50, 50}}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> pooledShapes_max = {
|
||||
{1, 1},
|
||||
{2, 2},
|
||||
{3, 3},
|
||||
{6, 6}
|
||||
const std::vector<ov::Shape> coord_shapes = {
|
||||
{{1, 5}},
|
||||
{{3, 5}},
|
||||
{{5, 5}}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> pooledShapes_bilinear = {
|
||||
{1, 1},
|
||||
{2, 2},
|
||||
{3, 3},
|
||||
{6, 6}
|
||||
auto input_shapes = [](const std::vector<ov::Shape>& in1, const std::vector<ov::Shape>& in2) {
|
||||
std::vector<std::vector<ov::test::InputShape>> res;
|
||||
for (const auto& sh1 : in1)
|
||||
for (const auto& sh2 : in2)
|
||||
res.push_back(ov::test::static_shapes_to_test_representation({sh1, sh2}));
|
||||
return res;
|
||||
}(param_shapes, coord_shapes);
|
||||
|
||||
const std::vector<ov::Shape> pooled_shapes_max = {
|
||||
{{1, 1}},
|
||||
{{2, 2}},
|
||||
{{3, 3}},
|
||||
{{6, 6}}
|
||||
};
|
||||
|
||||
const std::vector<std::vector<size_t>> coordShapes = {
|
||||
{1, 5},
|
||||
{3, 5},
|
||||
{5, 5}
|
||||
const std::vector<ov::Shape> pooled_shapes_bilinear = {
|
||||
{{1, 1}},
|
||||
{{2, 2}},
|
||||
{{3, 3}},
|
||||
{{6, 6}}
|
||||
};
|
||||
|
||||
const std::vector<InferenceEngine::Precision> netPRCs = {
|
||||
InferenceEngine::Precision::FP16,
|
||||
InferenceEngine::Precision::FP32
|
||||
const std::vector<ov::element::Type> model_types = {
|
||||
ov::element::f16,
|
||||
ov::element::f32
|
||||
};
|
||||
|
||||
const std::vector<float> spatial_scales = {0.625f, 1.f};
|
||||
|
||||
const auto test_ROIPooling_max = ::testing::Combine(
|
||||
::testing::ValuesIn(inShapes),
|
||||
::testing::ValuesIn(coordShapes),
|
||||
::testing::ValuesIn(pooledShapes_max),
|
||||
::testing::ValuesIn(input_shapes),
|
||||
::testing::ValuesIn(pooled_shapes_max),
|
||||
::testing::ValuesIn(spatial_scales),
|
||||
::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_MAX),
|
||||
::testing::ValuesIn(netPRCs),
|
||||
::testing::Values(ov::test::utils::ROIPoolingTypes::ROI_MAX),
|
||||
::testing::ValuesIn(model_types),
|
||||
::testing::Values(ov::test::utils::DEVICE_CPU)
|
||||
);
|
||||
|
||||
const auto test_ROIPooling_bilinear = ::testing::Combine(
|
||||
::testing::ValuesIn(inShapes),
|
||||
::testing::ValuesIn(coordShapes),
|
||||
::testing::ValuesIn(pooledShapes_bilinear),
|
||||
::testing::ValuesIn(input_shapes),
|
||||
::testing::ValuesIn(pooled_shapes_bilinear),
|
||||
::testing::Values(spatial_scales[1]),
|
||||
::testing::Values(ngraph::helpers::ROIPoolingTypes::ROI_BILINEAR),
|
||||
::testing::ValuesIn(netPRCs),
|
||||
::testing::Values(ov::test::utils::ROIPoolingTypes::ROI_BILINEAR),
|
||||
::testing::ValuesIn(model_types),
|
||||
::testing::Values(ov::test::utils::DEVICE_CPU)
|
||||
);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_TestsROIPooling_max, ROIPoolingLayerTest, test_ROIPooling_max, ROIPoolingLayerTest::getTestCaseName);
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_TestsROIPooling_bilinear, ROIPoolingLayerTest, test_ROIPooling_bilinear, ROIPoolingLayerTest::getTestCaseName);
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared_test_classes/single_op/roi_align.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
TEST_P(ROIAlignLayerTest, Inference) {
|
||||
run();
|
||||
}
|
||||
|
||||
TEST_P(ROIAlignV9LayerTest, Inference) {
|
||||
run();
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared_test_classes/single_op/roi_pooling.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
TEST_P(ROIPoolingLayerTest, Inference) {
|
||||
run();
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
@@ -0,0 +1,54 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
using roialignParams = std::tuple<
|
||||
std::vector<InputShape>, // Feature map shape
|
||||
ov::Shape, // Proposal coords shape
|
||||
int, // Bin's row count
|
||||
int, // Bin's column count
|
||||
float, // Spatial scale
|
||||
int, // Pooling ratio
|
||||
std::string, // Pooling mode
|
||||
ov::element::Type, // Model type
|
||||
ov::test::TargetDevice>; // Device name
|
||||
|
||||
class ROIAlignLayerTest : public testing::WithParamInterface<roialignParams>,
|
||||
virtual public ov::test::SubgraphBaseTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<roialignParams>& obj);
|
||||
static void fillCoordTensor(std::vector<float>& coords, int height, int width,
|
||||
float spatialScale, int pooledRatio, int pooledH, int pooledW);
|
||||
static void fillIdxTensor(std::vector<int>& idx, int batchSize);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
|
||||
using roialignV9Params = std::tuple<
|
||||
std::vector<InputShape>, // Feature map shape
|
||||
ov::Shape, // Proposal coords shape
|
||||
int, // Bin's row count
|
||||
int, // Bin's column count
|
||||
float, // Spatial scale
|
||||
int, // Pooling ratio
|
||||
std::string, // Pooling mode
|
||||
std::string, // ROI aligned mode
|
||||
ov::element::Type, // Model type
|
||||
ov::test::TargetDevice>; // Device name
|
||||
class ROIAlignV9LayerTest : public testing::WithParamInterface<roialignV9Params>,
|
||||
virtual public ov::test::SubgraphBaseTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<roialignV9Params>& obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
@@ -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 roiPoolingParamsTuple = std::tuple<
|
||||
std::vector<InputShape>, // Input, coords shapes
|
||||
ov::Shape, // Pooled shape {pooled_h, pooled_w}
|
||||
float, // Spatial scale
|
||||
ov::test::utils::ROIPoolingTypes, // ROIPooling method
|
||||
ov::element::Type, // Model type
|
||||
ov::test::TargetDevice>; // Device name
|
||||
|
||||
class ROIPoolingLayerTest : public testing::WithParamInterface<roiPoolingParamsTuple>,
|
||||
virtual public ov::test::SubgraphBaseTest {
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<roiPoolingParamsTuple>& obj);
|
||||
|
||||
protected:
|
||||
void SetUp() override;
|
||||
};
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "common_test_utils/ov_tensor_utils.hpp"
|
||||
|
||||
#include "shared_test_classes/single_layer/roi_align.hpp"
|
||||
#include "shared_test_classes/single_op/roi_align.hpp"
|
||||
#include "shared_test_classes/single_layer/psroi_pooling.hpp"
|
||||
#include "shared_test_classes/base/utils/generate_inputs.hpp"
|
||||
#include "shared_test_classes/base/utils/ranges.hpp"
|
||||
@@ -537,13 +537,13 @@ ov::runtime::Tensor generate(const std::shared_ptr<ov::op::v3::ROIAlign>& node,
|
||||
if (node->get_sampling_ratio() != 0) {
|
||||
const auto &inputShape = node->get_input_shape(0);
|
||||
std::vector<float> blobData(node->get_shape()[0] * 4);
|
||||
LayerTestsDefinitions::ROIAlignLayerTest::fillCoordTensor(blobData,
|
||||
inputShape[2],
|
||||
inputShape[3],
|
||||
node->get_spatial_scale(),
|
||||
node->get_sampling_ratio(),
|
||||
node->get_pooled_h(),
|
||||
node->get_pooled_w());
|
||||
ov::test::ROIAlignLayerTest::fillCoordTensor(blobData,
|
||||
inputShape[2],
|
||||
inputShape[3],
|
||||
node->get_spatial_scale(),
|
||||
node->get_sampling_ratio(),
|
||||
node->get_pooled_h(),
|
||||
node->get_pooled_w());
|
||||
return ov::test::utils::create_tensor<float>(ov::element::f32, targetShape, blobData);
|
||||
} else {
|
||||
return generate(std::dynamic_pointer_cast<ov::Node>(node), port, elemType, targetShape);
|
||||
@@ -551,7 +551,7 @@ ov::runtime::Tensor generate(const std::shared_ptr<ov::op::v3::ROIAlign>& node,
|
||||
}
|
||||
case 2: {
|
||||
std::vector<int> roiIdxVector(node->get_shape()[0]);
|
||||
LayerTestsDefinitions::ROIAlignLayerTest::fillIdxTensor(roiIdxVector, node->get_shape()[0]);
|
||||
ov::test::ROIAlignLayerTest::fillIdxTensor(roiIdxVector, node->get_shape()[0]);
|
||||
return ov::test::utils::create_tensor<int>(elemType, targetShape, roiIdxVector);
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,203 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <random>
|
||||
|
||||
#include "shared_test_classes/single_op/roi_align.hpp"
|
||||
|
||||
#include "openvino/core/enum_names.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
std::string ROIAlignLayerTest::getTestCaseName(const testing::TestParamInfo<roialignParams>& obj) {
|
||||
std::vector<InputShape> input_shapes;
|
||||
ov::Shape coords_shape;
|
||||
int pooled_h;
|
||||
int pooled_w;
|
||||
float spatial_scale;
|
||||
int pooling_ratio;
|
||||
std::string pooling_mode;
|
||||
ov::element::Type model_type;
|
||||
std::string target_device;
|
||||
std::tie(input_shapes, coords_shape, pooled_h, pooled_w, spatial_scale,
|
||||
pooling_ratio, pooling_mode, model_type, 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 << "coordShape=" << ov::test::utils::vec2str(coords_shape) << "_";
|
||||
result << "pooledH=" << pooled_h << "_";
|
||||
result << "pooledW=" << pooled_w << "_";
|
||||
result << "spatialScale=" << spatial_scale << "_";
|
||||
result << "poolingRatio=" << pooling_ratio << "_";
|
||||
result << "poolingMode=" << pooling_mode << "_";
|
||||
result << "modelType=" << model_type.to_string() << "_";
|
||||
result << "trgDev=" << target_device;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
static int randInt(int low, int high) {
|
||||
std::random_device rd;
|
||||
std::mt19937 gen(rd());
|
||||
std::uniform_int_distribution<int> dis(low, high);
|
||||
return dis(gen);
|
||||
}
|
||||
|
||||
void ROIAlignLayerTest::fillCoordTensor(std::vector<float>& coords, int height, int width,
|
||||
float spatial_scale, int pooled_ratio, int pooled_h, int pooled_w) {
|
||||
int min_roi_width = pooled_w;
|
||||
int max_roi_width = width / pooled_ratio;
|
||||
int min_roi_height = pooled_h;
|
||||
int max_roi_height = height / pooled_ratio;
|
||||
|
||||
for (int i = 0; i < coords.size() / 4; i++) {
|
||||
int size_x = std::min(width, randInt(min_roi_width, max_roi_width));
|
||||
int size_y = std::min(height, randInt(min_roi_height, max_roi_height));
|
||||
int start_x = randInt(0, std::max(1, width - size_x - 1));
|
||||
int start_y = randInt(0, std::max(1, height - size_y - 1));
|
||||
|
||||
coords[i * 4] = start_x / spatial_scale;
|
||||
coords[i * 4 + 1] = start_y / spatial_scale;
|
||||
coords[i * 4 + 2] = (start_x + size_x - 1) / spatial_scale;
|
||||
coords[i * 4 + 3] = (start_y + size_y - 1) / spatial_scale;
|
||||
}
|
||||
}
|
||||
void ROIAlignLayerTest::fillIdxTensor(std::vector<int>& idx, int batch_size) {
|
||||
int batch_id = 0;
|
||||
for (int i = 0; i < idx.size(); i++) {
|
||||
idx[i] = batch_id;
|
||||
batch_id = (batch_id + 1) % batch_size;
|
||||
}
|
||||
}
|
||||
|
||||
void ROIAlignLayerTest::SetUp() {
|
||||
std::vector<InputShape> input_shapes;
|
||||
ov::Shape coords_shape;
|
||||
int pooled_h;
|
||||
int pooled_w;
|
||||
float spatial_scale;
|
||||
int pooling_ratio;
|
||||
std::string pooling_mode;
|
||||
ov::element::Type model_type;
|
||||
std::tie(input_shapes, coords_shape, pooled_h, pooled_w, spatial_scale,
|
||||
pooling_ratio, pooling_mode, model_type, targetDevice) = this->GetParam();
|
||||
|
||||
init_input_shapes(input_shapes);
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[0]);
|
||||
std::vector<float> proposal_vector;
|
||||
std::vector<int> roi_idx_vector;
|
||||
proposal_vector.resize(coords_shape[0] * 4);
|
||||
roi_idx_vector.resize(coords_shape[0]);
|
||||
|
||||
fillCoordTensor(proposal_vector, inputDynamicShapes[0][2].get_length(), inputDynamicShapes[0][3].get_length(),
|
||||
spatial_scale, pooling_ratio, pooled_h, pooled_w);
|
||||
fillIdxTensor(roi_idx_vector, inputDynamicShapes[0][0].get_length());
|
||||
auto idx_shape = ov::Shape{coords_shape[0]};
|
||||
|
||||
auto coords = std::make_shared<ov::op::v0::Constant>(model_type, coords_shape, proposal_vector.data());
|
||||
auto rois_Idx = std::make_shared<ov::op::v0::Constant>(ov::element::i32, idx_shape, roi_idx_vector.data());
|
||||
auto roi_align = std::make_shared<ov::op::v3::ROIAlign>(param,
|
||||
coords,
|
||||
rois_Idx,
|
||||
pooled_h,
|
||||
pooled_w,
|
||||
pooling_ratio,
|
||||
spatial_scale,
|
||||
pooling_mode);
|
||||
function = std::make_shared<ov::Model>(roi_align->outputs(), ov::ParameterVector{param}, "roi_align");
|
||||
}
|
||||
|
||||
std::string ROIAlignV9LayerTest::getTestCaseName(const testing::TestParamInfo<roialignV9Params>& obj) {
|
||||
std::vector<InputShape> input_shapes;
|
||||
ov::Shape coords_shape;
|
||||
int pooled_h;
|
||||
int pooled_w;
|
||||
float spatial_scale;
|
||||
int pooling_ratio;
|
||||
std::string pooling_mode;
|
||||
std::string roi_aligned_mode;
|
||||
ov::element::Type model_type;
|
||||
std::string target_device;
|
||||
std::tie(input_shapes, coords_shape, pooled_h, pooled_w, spatial_scale,
|
||||
pooling_ratio, pooling_mode, roi_aligned_mode, model_type, 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 << "coordShape=" << ov::test::utils::vec2str(coords_shape) << "_";
|
||||
result << "pooledH=" << pooled_h << "_";
|
||||
result << "pooledW=" << pooled_w << "_";
|
||||
result << "spatialScale=" << spatial_scale << "_";
|
||||
result << "poolingRatio=" << pooling_ratio << "_";
|
||||
result << "poolingMode=" << pooling_mode << "_";
|
||||
result << "ROIMode=" << roi_aligned_mode << "_";
|
||||
result << "modelType=" << model_type.to_string() << "_";
|
||||
result << "trgDev=" << target_device;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ROIAlignV9LayerTest::SetUp() {
|
||||
std::vector<InputShape> input_shapes;
|
||||
ov::Shape coords_shape;
|
||||
int pooled_h;
|
||||
int pooled_w;
|
||||
float spatial_scale;
|
||||
int pooling_ratio;
|
||||
std::string pooling_mode;
|
||||
std::string roi_aligned_mode;
|
||||
ov::element::Type model_type;
|
||||
std::tie(input_shapes, coords_shape, pooled_h, pooled_w, spatial_scale,
|
||||
pooling_ratio, pooling_mode, roi_aligned_mode, model_type, targetDevice) = this->GetParam();
|
||||
|
||||
init_input_shapes(input_shapes);
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[0]);
|
||||
std::vector<float> proposal_vector;
|
||||
std::vector<int> roi_idx_vector;
|
||||
proposal_vector.resize(coords_shape[0] * 4);
|
||||
roi_idx_vector.resize(coords_shape[0]);
|
||||
|
||||
ROIAlignLayerTest::fillCoordTensor(proposal_vector, inputDynamicShapes[0][2].get_length(), inputDynamicShapes[0][3].get_length(),
|
||||
spatial_scale, pooling_ratio, pooled_h, pooled_w);
|
||||
ROIAlignLayerTest::fillIdxTensor(roi_idx_vector, inputDynamicShapes[0][0].get_length());
|
||||
auto idx_shape = ov::Shape{coords_shape[0]};
|
||||
|
||||
auto coords = std::make_shared<ov::op::v0::Constant>(model_type, coords_shape, proposal_vector.data());
|
||||
auto rois_Idx = std::make_shared<ov::op::v0::Constant>(ov::element::i32, idx_shape, roi_idx_vector.data());
|
||||
auto roi_align = std::make_shared<ov::op::v9::ROIAlign>(param,
|
||||
coords,
|
||||
rois_Idx,
|
||||
pooled_h,
|
||||
pooled_w,
|
||||
pooling_ratio,
|
||||
spatial_scale,
|
||||
ov::EnumNames<ov::op::v9::ROIAlign::PoolingMode>::as_enum(pooling_mode),
|
||||
ov::EnumNames<ov::op::v9::ROIAlign::AlignedMode>::as_enum(roi_aligned_mode));
|
||||
function = std::make_shared<ov::Model>(roi_align->outputs(), ov::ParameterVector{param}, "roi_align");
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2018-2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "shared_test_classes/single_op/roi_pooling.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
std::string ROIPoolingLayerTest::getTestCaseName(const testing::TestParamInfo<roiPoolingParamsTuple>& obj) {
|
||||
std::vector<InputShape> input_shapes;
|
||||
ov::Shape pool_shape;
|
||||
float spatial_scale;
|
||||
ov::test::utils::ROIPoolingTypes pool_method;
|
||||
ov::element::Type model_type;
|
||||
std::string target_device;
|
||||
std::tie(input_shapes, pool_shape, spatial_scale, pool_method, model_type, 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 << "PS=" << ov::test::utils::vec2str(pool_shape) << "_";
|
||||
result << "Scale=" << spatial_scale << "_";
|
||||
switch (pool_method) {
|
||||
case utils::ROIPoolingTypes::ROI_MAX:
|
||||
result << "Max_";
|
||||
break;
|
||||
case utils::ROIPoolingTypes::ROI_BILINEAR:
|
||||
result << "Bilinear_";
|
||||
break;
|
||||
}
|
||||
result << "modelType=" << model_type.to_string() << "_";
|
||||
result << "trgDev=" << target_device;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ROIPoolingLayerTest::SetUp() {
|
||||
std::vector<InputShape> input_shapes;
|
||||
ov::Shape pool_shape;
|
||||
float spatial_scale;
|
||||
ov::test::utils::ROIPoolingTypes pool_method;
|
||||
ov::element::Type model_type;
|
||||
std::string target_device;
|
||||
std::tie(input_shapes, pool_shape, spatial_scale, pool_method, model_type, targetDevice) = this->GetParam();
|
||||
|
||||
abs_threshold = 0.08f;
|
||||
|
||||
init_input_shapes(input_shapes);
|
||||
|
||||
auto param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[0]);
|
||||
auto coord_param = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes[1]);
|
||||
std::string pool_method_str;
|
||||
if (pool_method == ov::test::utils::ROIPoolingTypes::ROI_MAX) {
|
||||
pool_method_str = "max";
|
||||
} else if (pool_method == ov::test::utils::ROIPoolingTypes::ROI_BILINEAR) {
|
||||
pool_method_str = "bilinear";
|
||||
} else {
|
||||
FAIL() << "Incorrect type of ROIPooling operation";
|
||||
}
|
||||
auto roi_pooling = std::make_shared<ov::op::v0::ROIPooling>(param, coord_param, pool_shape, spatial_scale, pool_method_str);
|
||||
function = std::make_shared<ov::Model>(roi_pooling->outputs(), ov::ParameterVector{param, coord_param}, "roi_pooling");
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
Reference in New Issue
Block a user