forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for squared difference op (#115)
Co-authored-by: Tim Zerrell <[email protected]>
- Loading branch information
1 parent
0628d3d
commit 34bdf2b
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...unctional/plugin/plaidml/shared_tests_instances/single_layer_tests/squared_difference.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,28 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <cstddef> | ||
#include <map> | ||
#include <vector> | ||
|
||
#include "common_test_utils/test_constants.hpp" | ||
#include "single_layer_tests/squared_difference.hpp" | ||
|
||
using LayerTestsDefinitions::SquaredDifferenceLayerTest; | ||
|
||
namespace { | ||
const std::vector<InferenceEngine::Precision> netPrecisions = { | ||
InferenceEngine::Precision::FP32, | ||
}; | ||
|
||
const std::vector<std::vector<std::size_t>> inputShapes = { | ||
{1, 30}, {1, 10, 30} | ||
}; | ||
|
||
INSTANTIATE_TEST_CASE_P(CompareWithRefs, SquaredDifferenceLayerTest, | ||
::testing::Combine(::testing::ValuesIn(netPrecisions), ::testing::Values(inputShapes), | ||
::testing::Values(CommonTestUtils::DEVICE_PLAIDML)), | ||
SquaredDifferenceLayerTest::getTestCaseName); | ||
|
||
} // namespace |
33 changes: 33 additions & 0 deletions
33
...e-engine/tests/functional/plugin/shared/include/single_layer_tests/squared_difference.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,33 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
|
||
#include "functional_test_utils/layer_test_utils.hpp" | ||
#include "ngraph_functions/builders.hpp" | ||
#include "ngraph_functions/utils/ngraph_helpers.hpp" | ||
|
||
namespace LayerTestsDefinitions { | ||
|
||
using squaredDifferenceParams = std::tuple< | ||
InferenceEngine::Precision, // Net precision | ||
std::vector<std::vector<size_t>>, // Input shapes | ||
std::string // Target device name | ||
>; | ||
|
||
class SquaredDifferenceLayerTest : public testing::WithParamInterface<squaredDifferenceParams>, | ||
virtual public LayerTestsUtils::LayerTestsCommon { | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<squaredDifferenceParams> obj); | ||
|
||
protected: | ||
void SetUp() override; | ||
}; | ||
|
||
} // namespace LayerTestsDefinitions |
60 changes: 60 additions & 0 deletions
60
...rence-engine/tests/functional/plugin/shared/src/single_layer_tests/squared_difference.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,60 @@ | ||
// Copyright (C) 2020 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <tuple> | ||
#include <string> | ||
#include <vector> | ||
#include <memory> | ||
#include <functional> | ||
#include <functional_test_utils/skip_tests_config.hpp> | ||
|
||
#include "ie_core.hpp" | ||
#include "ngraph_functions/utils/ngraph_helpers.hpp" | ||
|
||
#include "ngraph/op/squared_difference.hpp" | ||
|
||
#include "common_test_utils/common_utils.hpp" | ||
#include "functional_test_utils/precision_utils.hpp" | ||
#include "functional_test_utils/blob_utils.hpp" | ||
#include "functional_test_utils/plugin_cache.hpp" | ||
#include "functional_test_utils/layer_test_utils.hpp" | ||
|
||
#include "single_layer_tests/squared_difference.hpp" | ||
|
||
namespace LayerTestsDefinitions { | ||
|
||
std::string SquaredDifferenceLayerTest::getTestCaseName(testing::TestParamInfo<squaredDifferenceParams> obj) { | ||
InferenceEngine::Precision netPrecision; | ||
std::vector<std::vector<size_t>> inputShapes; | ||
std::string targetDevice; | ||
std::tie(netPrecision, inputShapes, targetDevice) = obj.param; | ||
std::ostringstream result; | ||
result << "IS_" << CommonTestUtils::vec2str(inputShapes) << "_"; | ||
result << "netPRC_" << netPrecision.name() << "_"; | ||
result << "targetDevice_" << targetDevice; | ||
return result.str(); | ||
} | ||
|
||
void SquaredDifferenceLayerTest::SetUp() { | ||
InferenceEngine::Precision netPrecision; | ||
std::vector<InferenceEngine::SizeVector> inputShapes; | ||
std::tie(netPrecision, inputShapes, targetDevice) = this->GetParam(); | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
auto params = ngraph::builder::makeParams(ngPrc, {inputShapes}); | ||
|
||
auto paramOuts = ngraph::helpers::convert2OutputVector( | ||
ngraph::helpers::castOps2Nodes<ngraph::op::Parameter>(params)); | ||
IE_ASSERT(paramOuts.size() == 2); | ||
const auto squared_difference = std::make_shared<ngraph::opset1::SquaredDifference>(paramOuts.at(0), paramOuts.at(1)); | ||
|
||
ngraph::ResultVector results; | ||
results.push_back(std::make_shared<ngraph::opset1::Result>(squared_difference)); | ||
function = std::make_shared<ngraph::Function>(results, params, "squared_difference"); | ||
} | ||
|
||
TEST_P(SquaredDifferenceLayerTest, CompareWithRefs) { | ||
Run(); | ||
}; | ||
|
||
} // namespace LayerTestsDefinitions |