[GPU] Refactor (#23472)
### Details: - *experimental_detectron_prior_grid_generator* ### Tickets: - *CSV-131562*
This commit is contained in:
parent
98dee95096
commit
22bd6ff049
|
|
@ -2,73 +2,42 @@
|
|||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include <common_test_utils/data_utils.hpp>
|
||||
#include <common_test_utils/ov_tensor_utils.hpp>
|
||||
#include <single_layer_tests/experimental_detectron_prior_grid_generator.hpp>
|
||||
#include "single_op_tests/experimental_detectron_prior_grid_generator.hpp"
|
||||
|
||||
namespace {
|
||||
using ov::test::ExperimentalDetectronPriorGridGeneratorLayerTest;
|
||||
|
||||
const std::initializer_list<ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorTestParam> params{
|
||||
// flatten = true (output tensor is 2D)
|
||||
{{true, 0, 0, 4.0f, 4.0f},
|
||||
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 4, 5}, {1, 3, 100, 200}})},
|
||||
std::vector<std::vector<ov::test::InputShape>> shapes = {
|
||||
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 4, 5}, {1, 3, 100, 200}}),
|
||||
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 3, 7}, {1, 3, 100, 200}}),
|
||||
// task #72587
|
||||
//{
|
||||
// {true, 3, 6, 64.0f, 64.0f},
|
||||
// ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 100, 100}, {1, 3, 100, 200}})
|
||||
//},
|
||||
//// flatten = false (output tensor is 4D)
|
||||
{{false, 0, 0, 8.0f, 8.0f},
|
||||
ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 3, 7}, {1, 3, 100, 200}})},
|
||||
// task #72587
|
||||
//{
|
||||
// {false, 5, 3, 32.0f, 32.0f},
|
||||
// ov::test::static_shapes_to_test_representation({{3, 4}, {1, 16, 100, 100}, {1, 3, 100, 200}})
|
||||
//},
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
std::vector<std::pair<std::string, std::vector<ov::Tensor>>> getInputTensors() {
|
||||
std::vector<std::pair<std::string, std::vector<ov::Tensor>>> tensors{
|
||||
{"test#1",
|
||||
{ov::test::utils::create_tensor<T>(
|
||||
ov::element::from<T>(),
|
||||
{3, 4},
|
||||
std::vector<T>{-24.5, -12.5, 24.5, 12.5, -16.5, -16.5, 16.5, 16.5, -12.5, -24.5, 12.5, 24.5})}},
|
||||
{"test#2",
|
||||
{ov::test::utils::create_tensor<T>(
|
||||
ov::element::from<T>(),
|
||||
{3, 4},
|
||||
std::vector<T>{-44.5, -24.5, 44.5, 24.5, -32.5, -32.5, 32.5, 32.5, -24.5, -44.5, 24.5, 44.5})}},
|
||||
{"test#3",
|
||||
{ov::test::utils::create_tensor<T>(
|
||||
ov::element::from<T>(),
|
||||
{3, 4},
|
||||
std::
|
||||
vector<T>{-364.5, -184.5, 364.5, 184.5, -256.5, -256.5, 256.5, 256.5, -180.5, -360.5, 180.5, 360.5})}},
|
||||
{"test#4",
|
||||
{ov::test::utils::create_tensor<T>(
|
||||
ov::element::from<T>(),
|
||||
{3, 4},
|
||||
std::vector<T>{-180.5, -88.5, 180.5, 88.5, -128.5, -128.5, 128.5, 128.5, -92.5, -184.5, 92.5, 184.5})}}};
|
||||
return tensors;
|
||||
}
|
||||
|
||||
using ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorLayerTest;
|
||||
std::vector<ov::op::v6::ExperimentalDetectronPriorGridGenerator::Attributes> attributes = {
|
||||
// flatten = true (output tensor is 2D)
|
||||
{true, 0, 0, 4.0f, 4.0f},
|
||||
// flatten = false (output tensor is 4D)
|
||||
{false, 0, 0, 8.0f, 8.0f},
|
||||
// task #72587
|
||||
// {true, 3, 6, 64.0f, 64.0f},
|
||||
// {false, 5, 3, 32.0f, 32.0f},
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f32,
|
||||
ExperimentalDetectronPriorGridGeneratorLayerTest,
|
||||
testing::Combine(testing::ValuesIn(params),
|
||||
testing::ValuesIn(getInputTensors<float>()),
|
||||
testing::ValuesIn({ov::element::Type_t::f32}),
|
||||
testing::Combine(testing::ValuesIn(shapes),
|
||||
testing::ValuesIn(attributes),
|
||||
testing::Values(ov::element::f32),
|
||||
testing::Values(ov::test::utils::DEVICE_GPU)),
|
||||
ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName);
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f16,
|
||||
ExperimentalDetectronPriorGridGeneratorLayerTest,
|
||||
testing::Combine(testing::ValuesIn(params),
|
||||
testing::ValuesIn(getInputTensors<ov::float16>()),
|
||||
testing::ValuesIn({ov::element::Type_t::f16}),
|
||||
testing::Combine(testing::ValuesIn(shapes),
|
||||
testing::ValuesIn(attributes),
|
||||
testing::Values(ov::element::f16),
|
||||
testing::Values(ov::test::utils::DEVICE_GPU)),
|
||||
ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName);
|
||||
} // namespace
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp>
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace subgraph {
|
||||
|
||||
TEST_P(ExperimentalDetectronPriorGridGeneratorLayerTest, ExperimentalDetectronPriorGridGeneratorLayerTests) {
|
||||
run();
|
||||
}
|
||||
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "common_test_utils/common_utils.hpp"
|
||||
#include "shared_test_classes/base/ov_subgraph.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace subgraph {
|
||||
|
||||
class ExperimentalDetectronPriorGridGeneratorTestParam {
|
||||
public:
|
||||
ov::op::v6::ExperimentalDetectronPriorGridGenerator::Attributes attributes;
|
||||
std::vector<InputShape> inputShapes;
|
||||
};
|
||||
|
||||
typedef std::tuple<
|
||||
ExperimentalDetectronPriorGridGeneratorTestParam,
|
||||
std::pair<std::string, std::vector<ov::Tensor>>,
|
||||
ElementType, // Network precision
|
||||
std::string // Device name>;
|
||||
> ExperimentalDetectronPriorGridGeneratorTestParams;
|
||||
|
||||
class ExperimentalDetectronPriorGridGeneratorLayerTest :
|
||||
public testing::WithParamInterface<ExperimentalDetectronPriorGridGeneratorTestParams>,
|
||||
virtual public SubgraphBaseTest {
|
||||
protected:
|
||||
void SetUp() override;
|
||||
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override;
|
||||
|
||||
public:
|
||||
static std::string getTestCaseName(const testing::TestParamInfo<ExperimentalDetectronPriorGridGeneratorTestParams>& obj);
|
||||
};
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
// Copyright (C) 2018-2024 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "shared_test_classes/single_layer/experimental_detectron_prior_grid_generator.hpp"
|
||||
#include "common_test_utils/data_utils.hpp"
|
||||
#include <common_test_utils/ov_tensor_utils.hpp>
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
namespace subgraph {
|
||||
|
||||
namespace {
|
||||
std::ostream& operator <<(
|
||||
std::ostream& ss,
|
||||
const ov::op::v6::ExperimentalDetectronPriorGridGenerator::Attributes& attributes) {
|
||||
ss << "flatten=" << attributes.flatten << "_";
|
||||
ss << "h=" << attributes.h << "_";
|
||||
ss << "w=" << attributes.w << "_";
|
||||
ss << "stride_x=" << attributes.stride_x << "_";
|
||||
ss << "stride_y=" << attributes.stride_y;
|
||||
return ss;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::string ExperimentalDetectronPriorGridGeneratorLayerTest::getTestCaseName(
|
||||
const testing::TestParamInfo<ExperimentalDetectronPriorGridGeneratorTestParams>& obj) {
|
||||
ExperimentalDetectronPriorGridGeneratorTestParam param;
|
||||
std::pair<std::string, std::vector<ov::Tensor>> inputTensors;
|
||||
ElementType netPrecision;
|
||||
std::string targetName;
|
||||
std::tie(param, inputTensors, netPrecision, targetName) = obj.param;
|
||||
|
||||
std::ostringstream result;
|
||||
using ov::test::operator<<;
|
||||
result << "priors=" << param.inputShapes[0] << "_";
|
||||
result << "feature_map=" << param.inputShapes[1] << "_";
|
||||
result << "im_data=" << param.inputShapes[2] << "_";
|
||||
|
||||
using ov::test::subgraph::operator<<;
|
||||
result << "attributes=" << param.attributes << "_";
|
||||
result << "priorValues=" << inputTensors.first << "_";
|
||||
result << "netPRC=" << netPrecision << "_";
|
||||
result << "trgDev=" << targetName;
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void ExperimentalDetectronPriorGridGeneratorLayerTest::SetUp() {
|
||||
ExperimentalDetectronPriorGridGeneratorTestParam param;
|
||||
std::pair<std::string, std::vector<ov::Tensor>> inputTensors;
|
||||
ElementType netPrecision;
|
||||
std::string targetName;
|
||||
std::tie(param, inputTensors, netPrecision, targetName) = this->GetParam();
|
||||
|
||||
inType = outType = netPrecision;
|
||||
targetDevice = targetName;
|
||||
|
||||
init_input_shapes(param.inputShapes);
|
||||
|
||||
ov::ParameterVector params;
|
||||
for (auto&& shape : inputDynamicShapes)
|
||||
params.push_back(std::make_shared<ov::op::v0::Parameter>(netPrecision, shape));
|
||||
|
||||
auto experimentalDetectron = std::make_shared<op::v6::ExperimentalDetectronPriorGridGenerator>(
|
||||
params[0], // priors
|
||||
params[1], // feature_map
|
||||
params[2], // im_data
|
||||
param.attributes);
|
||||
function = std::make_shared<ov::Model>(
|
||||
ov::OutputVector{experimentalDetectron->output(0)},
|
||||
"ExperimentalDetectronPriorGridGenerator");
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename T>
|
||||
ov::Tensor generateTensorByShape(const Shape &shape) {
|
||||
return ov::test::utils::create_tensor<T>(
|
||||
ov::element::from<T>(),
|
||||
shape,
|
||||
std::vector<T>(0., shape_size(shape)));
|
||||
}
|
||||
}
|
||||
|
||||
void ExperimentalDetectronPriorGridGeneratorLayerTest::generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) {
|
||||
auto inputTensors = std::get<1>(GetParam());
|
||||
auto netPrecision = std::get<2>(GetParam());
|
||||
|
||||
inputs.clear();
|
||||
const auto& funcInputs = function->inputs();
|
||||
|
||||
auto i = 0ul;
|
||||
for (; i < inputTensors.second.size(); ++i) {
|
||||
if (targetInputStaticShapes[i] != inputTensors.second[i].get_shape()) {
|
||||
OPENVINO_THROW("input shape is different from tensor shape");
|
||||
}
|
||||
|
||||
inputs.insert({funcInputs[i].get_node_shared_ptr(), inputTensors.second[i]});
|
||||
}
|
||||
for (auto j = i; j < funcInputs.size(); ++j) {
|
||||
ov::Tensor inputTensor = (netPrecision == element::f16)
|
||||
? generateTensorByShape<ov::float16>(targetInputStaticShapes[j])
|
||||
: generateTensorByShape<float>(
|
||||
targetInputStaticShapes[j]);
|
||||
|
||||
inputs.insert({funcInputs[j].get_node_shared_ptr(), inputTensor});
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace subgraph
|
||||
} // namespace test
|
||||
} // namespace ov
|
||||
Loading…
Reference in New Issue