Skip to content

Commit

Permalink
Restore some GPU tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vurusovs committed Feb 1, 2024
1 parent 854468a commit ddd5186
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#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 {

const std::initializer_list<ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorTestParam> params{
const std::initializer_list<ov::test::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}})},
Expand Down Expand Up @@ -54,7 +54,7 @@ std::vector<std::pair<std::string, std::vector<ov::Tensor>>> getInputTensors() {
return tensors;
}

using ov::test::subgraph::ExperimentalDetectronPriorGridGeneratorLayerTest;
using ov::test::ExperimentalDetectronPriorGridGeneratorLayerTest;

INSTANTIATE_TEST_SUITE_P(smoke_ExperimentalDetectronPriorGridGenerator_f32,
ExperimentalDetectronPriorGridGeneratorLayerTest,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "single_layer_tests/group_normalization.hpp"
#include "single_op_tests/group_normalization.hpp"

using namespace ov::test::subgraph;
using namespace ov::test;

namespace {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "shared_test_classes/single_layer/group_normalization.hpp"

namespace ov {
namespace test {

TEST_P(GroupNormalizationTest, CompareWithRefs) {
run();
}

TEST_P(GroupNormalizationTest, CompareQueryModel) {
query_model();
}

} // namespace test
} // namespace ov
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// Copyright (C) 2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "ov_models/builders.hpp"
#include "common_test_utils/common_utils.hpp"
#include "shared_test_classes/base/ov_subgraph.hpp"

namespace ov {
namespace test {

using GroupNormalizationTestParams = std::tuple<ElementType, // netPrecision
ElementType, // inPrecision
ElementType, // outPrecision
InputShape, // Dynamic shape + Target static shapes
std::int64_t, // num_groups
double, // epsilon
TargetDevice, // targetDevice
Config // config
>;

class GroupNormalizationTest : public testing::WithParamInterface<GroupNormalizationTestParams>,
virtual public ov::test::SubgraphBaseTest {
public:
static std::string getTestCaseName(const testing::TestParamInfo<GroupNormalizationTestParams> &obj) {
ElementType netType, inType, outType;
InputShape shapes;
std::int64_t num_groups;
double epsilon;
TargetDevice targetDevice;
Config config;
std::tie(netType, inType, outType, shapes, num_groups, epsilon, targetDevice, config) = obj.param;

std::ostringstream result;
result << "NetType=" << netType << "_";
result << "InType=" << inType << "_";
result << "OutType=" << outType << "_";
result << "IS=" << ov::test::utils::partialShape2str({shapes.first}) << "_";
result << "TS=";
for (const auto& item : shapes.second) {
result << ov::test::utils::vec2str(item) << "_";
}
result << "NumGroups=" << num_groups << "_";
result << "Epsilon=" << epsilon << "_";
result << "Device=" << targetDevice;

return result.str();
}

protected:
void SetUp() override {
InputShape shapes;
ElementType ngPrc;
std::int64_t num_groups;
double epsilon;

std::tie(ngPrc, inType, outType, shapes, num_groups, epsilon, targetDevice, configuration) = this->GetParam();
InputShape biasInputShape = ExtractBiasShape(shapes);
init_input_shapes({shapes, biasInputShape, biasInputShape});
ov::ParameterVector params;
for (auto&& shape : inputDynamicShapes)
params.push_back(std::make_shared<ov::op::v0::Parameter>(ngPrc, shape));

const auto groupNormalization = std::make_shared<ov::op::v12::GroupNormalization>(
params.at(0),
params.at(1),
params.at(2),
num_groups,
epsilon);
const ov::ResultVector results{std::make_shared<ov::op::v0::Result>(groupNormalization)};

// TODO: This workaround is needed as there is no full support for f16 type in the reference implementation
if (ngPrc == element::Type_t::f16) {
abs_threshold = 0.007;
}

function = std::make_shared<ov::Model>(results, params, "GroupNormalization");
}

InputShape ExtractBiasShape(const InputShape& shape) {
std::vector<ov::Shape> biasShape;
std::transform(shape.second.cbegin(), shape.second.cend(), std::back_inserter(biasShape),
[](const ov::Shape& s)->ov::Shape { return {s[1]}; });
InputShape biasInputShape {
shape.first.is_dynamic() ? ov::PartialShape{shape.first[1]} : shape.first,
std::move(biasShape)
};
return biasInputShape;
}
};

} // namespace test
} // namespace ov

0 comments on commit ddd5186

Please sign in to comment.