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.
[CPU][IE TESTS] Added VariadicSplit and Pad subgraph tests (openvinot…
…oolkit#4583) * [IE TESTS] Added VariadicSplit and Pad subgraph tests * Added more connectedIndexes
- Loading branch information
1 parent
5bb8571
commit 704278e
Showing
4 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
.../tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/variadic_split_pad.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,63 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "subgraph_tests/variadic_split_pad.hpp" | ||
|
||
using namespace SubgraphTestsDefinitions; | ||
|
||
namespace { | ||
|
||
const std::vector<InferenceEngine::Precision> netPrecision = { | ||
InferenceEngine::Precision::FP32 | ||
}; | ||
|
||
const std::vector<InferenceEngine::SizeVector> shapes = { | ||
{1, 8, 3, 2}, | ||
{3, 8, 8, 8}, | ||
}; | ||
|
||
const std::vector<std::vector<size_t>> connectedIndexes = { | ||
{0}, | ||
{0, 2}, | ||
{0, 1, 3}, | ||
{0, 1, 1, 0}, | ||
{0, 0, 0, 1}, | ||
}; | ||
|
||
const std::vector<std::vector<size_t>> numSplits = { | ||
{2, 2, 2, 2}, | ||
{1, 2, 4, 1}, | ||
{3, 2, 2, 1} | ||
}; | ||
|
||
const std::vector<std::vector<int64_t>> padsBegin = { | ||
{0, 0, 0, 0}, | ||
{0, 0, 1, 1}, | ||
}; | ||
|
||
const std::vector<std::vector<int64_t>> padsEnd = { | ||
{0, 0, 0, 0}, | ||
{0, 0, 1, 1}, | ||
}; | ||
|
||
const std::vector<ngraph::helpers::PadMode> padMode = { | ||
ngraph::helpers::PadMode::CONSTANT, | ||
ngraph::helpers::PadMode::EDGE, | ||
ngraph::helpers::PadMode::REFLECT, | ||
ngraph::helpers::PadMode::SYMMETRIC | ||
}; | ||
|
||
INSTANTIATE_TEST_CASE_P(smoke_CPU, VariadicSplitPad, | ||
::testing::Combine( | ||
::testing::ValuesIn(shapes), | ||
::testing::Values(1), | ||
::testing::ValuesIn(numSplits), | ||
::testing::ValuesIn(connectedIndexes), | ||
::testing::ValuesIn(padsBegin), | ||
::testing::ValuesIn(padsEnd), | ||
::testing::ValuesIn(padMode), | ||
::testing::ValuesIn(netPrecision), | ||
::testing::Values(CommonTestUtils::DEVICE_CPU)), | ||
VariadicSplitPad::getTestCaseName); | ||
} // namespace |
14 changes: 14 additions & 0 deletions
14
...rence-engine/tests/functional/plugin/shared/include/subgraph_tests/variadic_split_pad.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,14 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
#pragma once | ||
|
||
#include "shared_test_classes/subgraph/variadic_split_pad.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
TEST_P(VariadicSplitPad, CompareWithRefs){ | ||
Run(); | ||
}; | ||
|
||
} // namespace SubgraphTestsDefinitions |
36 changes: 36 additions & 0 deletions
36
...unctional/shared_test_classes/include/shared_test_classes/subgraph/variadic_split_pad.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) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "shared_test_classes/base/layer_test_utils.hpp" | ||
#include "ngraph_functions/builders.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
typedef std::tuple< | ||
InferenceEngine::SizeVector, // Input shapes | ||
size_t, // Axis | ||
std::vector<size_t>, // Split number | ||
std::vector<size_t>, // Index connected layer | ||
std::vector<int64_t>, // Pad begin | ||
std::vector<int64_t>, // Pad end | ||
ngraph::helpers::PadMode, // Pad mode | ||
InferenceEngine::Precision, // Network precision | ||
std::string // Device name | ||
> SplitPadTuple; | ||
|
||
|
||
class VariadicSplitPad: public testing::WithParamInterface<SplitPadTuple>, | ||
public LayerTestsUtils::LayerTestsCommon{ | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<SplitPadTuple> &obj); | ||
protected: | ||
void SetUp() override; | ||
}; | ||
} // namespace SubgraphTestsDefinitions |
51 changes: 51 additions & 0 deletions
51
inference-engine/tests/functional/shared_test_classes/src/subgraph/variadic_split_pad.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,51 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "shared_test_classes/subgraph/variadic_split_pad.hpp" | ||
|
||
namespace SubgraphTestsDefinitions { | ||
|
||
std::string VariadicSplitPad::getTestCaseName(const testing::TestParamInfo<SplitPadTuple> &obj) { | ||
InferenceEngine::SizeVector inputShape; | ||
size_t axis; | ||
std::vector<size_t> numSplits, connectIndexes; | ||
std::vector<int64_t> padsBegin, padsEnd; | ||
ngraph::helpers::PadMode padMode; | ||
InferenceEngine::Precision netPrecision; | ||
std::string targetName; | ||
std::tie(inputShape, axis, numSplits, connectIndexes, padsBegin, padsEnd, padMode, netPrecision, targetName) = obj.param; | ||
std::ostringstream results; | ||
|
||
results << "IS=" << CommonTestUtils::vec2str(inputShape) << "_"; | ||
results << "Axis=" << axis << "_"; | ||
results << "NumSplits=" << CommonTestUtils::vec2str(numSplits) << "_"; | ||
results << "ConnectIndexes=" << CommonTestUtils::vec2str(connectIndexes) << "_"; | ||
results << "padsBegin=" << CommonTestUtils::vec2str(padsBegin) << "_"; | ||
results << "padsEnd=" << CommonTestUtils::vec2str(padsEnd) << "_"; | ||
results << "PadMode=" << padMode << "_"; | ||
results << "netPRC=" << netPrecision.name() << "_"; | ||
results << "targetDevice=" << targetName << "_"; | ||
return results.str(); | ||
} | ||
|
||
void VariadicSplitPad::SetUp() { | ||
InferenceEngine::SizeVector inputs; | ||
size_t axis; | ||
std::vector<size_t> numSplits, connectIndexes; | ||
std::vector<int64_t> padBegin, padEnd; | ||
ngraph::helpers::PadMode padMode; | ||
InferenceEngine::Precision netPrecision; | ||
std::tie(inputs, axis, numSplits, connectIndexes, padBegin, padEnd, padMode, netPrecision, targetDevice) = this->GetParam(); | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
auto input = ngraph::builder::makeParams(ngPrc, {inputs}); | ||
auto split = ngraph::builder::makeVariadicSplit(input[0], numSplits, axis); | ||
ngraph::ResultVector results; | ||
|
||
for (size_t i : connectIndexes) { | ||
auto pad = ngraph::builder::makePad(split->output(i), padBegin, padEnd, 0, padMode); | ||
results.push_back(std::make_shared<ngraph::opset1::Result>(pad)); | ||
} | ||
function = std::make_shared<ngraph::Function>(results, input, "variadic_split_pad"); | ||
} | ||
} // namespace SubgraphTestsDefinitions |