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.
Refactor ComparisonLayerTest, ClampLayerTest (openvinotoolkit#19681)
* Refactor ClampLayerTest * Refactor ComparisonLayerTest
- Loading branch information
1 parent
5e93fbf
commit 67f64f7
Showing
8 changed files
with
303 additions
and
34 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
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
15 changes: 15 additions & 0 deletions
15
src/tests/functional/plugin/shared/include/single_op_tests/clamp.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,15 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/single_op/clamp.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
TEST_P(ClampLayerTest, Inference) { | ||
run(); | ||
} | ||
} // namespace test | ||
} // namespace ov |
15 changes: 15 additions & 0 deletions
15
src/tests/functional/plugin/shared/include/single_op_tests/comparison.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,15 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <shared_test_classes/single_op/comparison.hpp> | ||
|
||
namespace ov { | ||
namespace test { | ||
TEST_P(ComparisonLayerTest, Inference) { | ||
run(); | ||
} | ||
} // namespace test | ||
} // namespace ov |
30 changes: 30 additions & 0 deletions
30
src/tests/functional/shared_test_classes/include/shared_test_classes/single_op/clamp.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,30 @@ | ||
// 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 { | ||
|
||
using clampParamsTuple = std::tuple< | ||
std::vector<InputShape>, // Input shape | ||
std::pair<float, float>, // Interval [min, max] | ||
ov::element::Type, // Model precision | ||
std::string>; // Device name | ||
|
||
class ClampLayerTest : public testing::WithParamInterface<clampParamsTuple>, | ||
virtual public ov::test::SubgraphBaseTest { | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<clampParamsTuple>& obj); | ||
protected: | ||
void SetUp() override; | ||
}; | ||
|
||
} // namespace test | ||
} // namespace ov |
37 changes: 37 additions & 0 deletions
37
...tests/functional/shared_test_classes/include/shared_test_classes/single_op/comparison.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,37 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
|
||
#include <map> | ||
|
||
#include "gtest/gtest.h" | ||
#include "shared_test_classes/base/ov_subgraph.hpp" | ||
#include "common_test_utils/test_constants.hpp" | ||
#include "ngraph_functions/utils/ngraph_helpers.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
|
||
typedef std::tuple< | ||
std::vector<InputShape>, // Input shapes tuple | ||
ngraph::helpers::ComparisonTypes, // Comparison op type | ||
ngraph::helpers::InputLayerType, // Second input type | ||
ov::element::Type, // Model type | ||
std::string, // Device name | ||
std::map<std::string, std::string> // Additional network configuration | ||
> ComparisonTestParams; | ||
|
||
class ComparisonLayerTest : public testing::WithParamInterface<ComparisonTestParams>, | ||
virtual public ov::test::SubgraphBaseTest { | ||
ngraph::helpers::ComparisonTypes comparison_op_type; | ||
protected: | ||
void SetUp() override; | ||
void generate_inputs(const std::vector<ov::Shape>& targetInputStaticShapes) override; | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<ComparisonTestParams> &obj); | ||
}; | ||
} // namespace test | ||
} // namespace ov |
50 changes: 50 additions & 0 deletions
50
src/tests/functional/shared_test_classes/src/single_op/clamp.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (C) 2018-2023 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "shared_test_classes/single_op/clamp.hpp" | ||
|
||
namespace ov { | ||
namespace test { | ||
std::string ClampLayerTest::getTestCaseName(const testing::TestParamInfo<clampParamsTuple>& obj) { | ||
std::vector<InputShape> shapes; | ||
std::pair<float, float> interval; | ||
ov::element::Type model_type; | ||
std::string target_device; | ||
|
||
std::tie(shapes, interval, model_type, target_device) = 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 << "min=" << interval.first << "_"; | ||
result << "max=" << interval.second << "_"; | ||
result << "netPrc=" << model_type.get_type_name() << "_"; | ||
result << "trgDev=" << target_device; | ||
return result.str(); | ||
} | ||
|
||
void ClampLayerTest::SetUp() { | ||
std::vector<InputShape> shapes; | ||
std::pair<float, float> interval; | ||
ov::element::Type model_type; | ||
std::tie(shapes, interval, model_type, targetDevice) = this->GetParam(); | ||
init_input_shapes(shapes); | ||
|
||
auto input = std::make_shared<ov::op::v0::Parameter>(model_type, inputDynamicShapes.front()); | ||
auto clamp = std::make_shared<ov::op::v0::Clamp>(input, interval.first, interval.second); | ||
auto result = std::make_shared<ov::op::v0::Result>(clamp); | ||
function = std::make_shared<ov::Model>(result, ngraph::ParameterVector{input}); | ||
} | ||
} // namespace test | ||
} // namespace ov |
Oops, something went wrong.