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
165 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...gine/tests/functional/plugin/gpu/shared_tests_instances/subgraph_tests/reduce_eltwise.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,47 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <vector> | ||
|
||
#include "subgraph_tests/reduce_eltwise.hpp" | ||
|
||
using namespace SubgraphTestsDefinitions; | ||
|
||
namespace { | ||
|
||
const std::vector<InferenceEngine::Precision> netPrecisions = { | ||
InferenceEngine::Precision::FP32, | ||
}; | ||
|
||
INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise6D, ReduceEltwiseTest, | ||
testing::Combine( | ||
testing::Values(std::vector<size_t>{2, 3, 4, 5, 6, 7}), | ||
testing::Values(std::vector<int>{2, 3, 4}), | ||
testing::Values(CommonTestUtils::OpType::VECTOR), | ||
testing::Values(false), | ||
testing::ValuesIn(netPrecisions), | ||
testing::Values(CommonTestUtils::DEVICE_GPU)), | ||
ReduceEltwiseTest::getTestCaseName); | ||
|
||
INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise5D, ReduceEltwiseTest, | ||
testing::Combine( | ||
testing::Values(std::vector<size_t>{2, 3, 4, 5, 6}), | ||
testing::Values(std::vector<int>{2, 3}), | ||
testing::Values(CommonTestUtils::OpType::VECTOR), | ||
testing::Values(false), | ||
testing::ValuesIn(netPrecisions), | ||
testing::Values(CommonTestUtils::DEVICE_GPU)), | ||
ReduceEltwiseTest::getTestCaseName); | ||
|
||
INSTANTIATE_TEST_CASE_P(smoke_ReduceEltwise4D, ReduceEltwiseTest, | ||
testing::Combine( | ||
testing::Values(std::vector<size_t>{2, 3, 4, 5}), | ||
testing::Values(std::vector<int>{2}), | ||
testing::Values(CommonTestUtils::OpType::VECTOR), | ||
testing::Values(false), | ||
testing::ValuesIn(netPrecisions), | ||
testing::Values(CommonTestUtils::DEVICE_GPU)), | ||
ReduceEltwiseTest::getTestCaseName); | ||
|
||
} // namespace |
15 changes: 15 additions & 0 deletions
15
inference-engine/tests/functional/plugin/shared/include/subgraph_tests/reduce_eltwise.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-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/subgraph/reduce_eltwise.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
TEST_P(ReduceEltwiseTest, CompareWithRefs) { | ||
Run(); | ||
}; | ||
|
||
} // namespace SubgraphTestsDefinitions |
36 changes: 36 additions & 0 deletions
36
...ts/functional/shared_test_classes/include/shared_test_classes/subgraph/reduce_eltwise.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,36 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
#include "shared_test_classes/base/layer_test_utils.hpp" | ||
#include "ngraph_functions/builders.hpp" | ||
#include "ngraph_functions/utils/ngraph_helpers.hpp" | ||
#include "common_test_utils/test_constants.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
using ReduceEltwiseParamsTuple = typename std::tuple< | ||
std::vector<size_t>, // Input shapes | ||
std::vector<int>, // Axis to reduce order | ||
CommonTestUtils::OpType, // Scalar or vector type axis | ||
bool, // Keep dims | ||
InferenceEngine::Precision, // Network precision | ||
std::string>; // Device name | ||
|
||
class ReduceEltwiseTest: | ||
public testing::WithParamInterface<ReduceEltwiseParamsTuple>, | ||
public LayerTestsUtils::LayerTestsCommon{ | ||
public: | ||
std::shared_ptr<ngraph::Function> fn; | ||
static std::string getTestCaseName(const testing::TestParamInfo<ReduceEltwiseParamsTuple> &obj); | ||
protected: | ||
void SetUp() override; | ||
}; | ||
|
||
} // namespace SubgraphTestsDefinitions |
67 changes: 67 additions & 0 deletions
67
inference-engine/tests/functional/shared_test_classes/src/subgraph/reduce_eltwise.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,67 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "ngraph_functions/builders.hpp" | ||
#include "shared_test_classes/subgraph/reduce_eltwise.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
std::string ReduceEltwiseTest::getTestCaseName(const testing::TestParamInfo<ReduceEltwiseParamsTuple> &obj) { | ||
std::vector<size_t> inputShapes; | ||
std::vector<int> axes; | ||
CommonTestUtils::OpType opType; | ||
bool keepDims; | ||
InferenceEngine::Precision netPrecision; | ||
std::string targetName; | ||
std::tie(inputShapes, axes, opType, keepDims, netPrecision, targetName) = obj.param; | ||
|
||
std::ostringstream result; | ||
result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; | ||
result << "axes=" << CommonTestUtils::vec2str(axes) << "_"; | ||
result << "opType=" << opType << "_"; | ||
if (keepDims) result << "KeepDims_"; | ||
result << "netPRC=" << netPrecision.name() << "_"; | ||
result << "targetDevice=" << targetName; | ||
return result.str(); | ||
} | ||
|
||
void ReduceEltwiseTest::SetUp() { | ||
std::vector<size_t> inputShape; | ||
std::vector<int> axes; | ||
CommonTestUtils::OpType opType; | ||
bool keepDims; | ||
InferenceEngine::Precision netPrecision; | ||
std::string targetName; | ||
std::tie(inputShape, axes, opType, keepDims, netPrecision, targetName) = this->GetParam(); | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
auto params = ngraph::builder::makeParams(ngPrc, {inputShape}); | ||
auto paramOuts = ngraph::helpers::convert2OutputVector( | ||
ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params)); | ||
|
||
std::vector<size_t> shapeAxes; | ||
switch (opType) { | ||
case CommonTestUtils::OpType::SCALAR: { | ||
if (axes.size() > 1) | ||
FAIL() << "In reduce op if op type is scalar, 'axis' input's must contain 1 element"; | ||
break; | ||
} | ||
case CommonTestUtils::OpType::VECTOR: { | ||
shapeAxes.push_back(axes.size()); | ||
break; | ||
} | ||
default: | ||
FAIL() << "Reduce op doesn't support operation type: " << opType; | ||
} | ||
auto reductionAxesNode = std::dynamic_pointer_cast<ngraph::Node>( | ||
std::make_shared<ngraph::opset3::Constant>(ngraph::element::Type_t::i64, ngraph::Shape(shapeAxes), axes)); | ||
|
||
auto reduce = std::make_shared<ngraph::opset3::ReduceSum>(paramOuts[0], reductionAxesNode, keepDims); | ||
|
||
std::vector<size_t> constShape(3, 1); | ||
constShape[2] = inputShape.back(); | ||
auto constant = ngraph::builder::makeConstant<float>(ngPrc, constShape, {}, true); | ||
auto eltw = ngraph::builder::makeEltwise(reduce, constant, ngraph::helpers::EltwiseTypes::MULTIPLY); | ||
ngraph::ResultVector results{std::make_shared<ngraph::opset3::Result>(eltw)}; | ||
function = std::make_shared<ngraph::Function>(results, params, "ReduceEltwise"); | ||
} | ||
} // namespace SubgraphTestsDefinitions |