forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...el_gpu/tests/functional/shared_tests_instances/single_layer_tests/group_normalization.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/tests/functional/plugin/shared/include/single_op_tests/group_normalization.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
93 changes: 93 additions & 0 deletions
93
...ctional/shared_test_classes/include/shared_test_classes/single_op/group_normalization.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |