-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
8 changed files
with
206 additions
and
9 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
41 changes: 41 additions & 0 deletions
41
...te_plugin/tests/functional/shared_tests_instances/single_layer_tests/custom_operation.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,41 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <vector> | ||
|
||
#include "single_layer_tests/custom_operation.hpp" | ||
|
||
using namespace LayerTestsDefinitions; | ||
|
||
namespace { | ||
const std::vector<InferenceEngine::Precision> netPrecisions = { | ||
InferenceEngine::Precision::FP32, | ||
InferenceEngine::Precision::FP16 | ||
}; | ||
|
||
const std::vector<std::vector<size_t>> inputShapes = { | ||
{1, 3}, | ||
{2, 5}, | ||
{1, 3, 10}, | ||
{1, 3, 1, 1}, | ||
{2, 5, 4, 4}, | ||
}; | ||
|
||
|
||
const auto customOpParams = testing::Combine( | ||
testing::ValuesIn(netPrecisions), | ||
testing::ValuesIn(inputShapes), | ||
testing::Values(CommonTestUtils::DEVICE_TEMPLATE) | ||
); | ||
|
||
INSTANTIATE_TEST_CASE_P( | ||
smoke_CustomOperation, | ||
CustomOpLayerTest, | ||
customOpParams, | ||
CustomOpLayerTest::getTestCaseName | ||
); | ||
|
||
} // namespace | ||
|
||
|
40 changes: 40 additions & 0 deletions
40
...ests/functional/plugin/cpu/shared_tests_instances/single_layer_tests/custom_operation.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,40 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include <vector> | ||
|
||
#include "single_layer_tests/custom_operation.hpp" | ||
|
||
using namespace LayerTestsDefinitions; | ||
|
||
namespace { | ||
const std::vector<InferenceEngine::Precision> netPrecisions = { | ||
InferenceEngine::Precision::FP32, | ||
InferenceEngine::Precision::FP16 | ||
}; | ||
|
||
const std::vector<std::vector<size_t>> inputShapes = { | ||
{1, 3}, | ||
{2, 5}, | ||
{1, 3, 10}, | ||
{1, 3, 1, 1}, | ||
{2, 5, 4, 4}, | ||
}; | ||
|
||
|
||
const auto customOpParams = testing::Combine( | ||
testing::ValuesIn(netPrecisions), | ||
testing::ValuesIn(inputShapes), | ||
testing::Values(CommonTestUtils::DEVICE_CPU) | ||
); | ||
|
||
INSTANTIATE_TEST_CASE_P( | ||
smoke_CustomOperation, | ||
CustomOpLayerTest, | ||
customOpParams, | ||
CustomOpLayerTest::getTestCaseName | ||
); | ||
|
||
} // namespace | ||
|
17 changes: 17 additions & 0 deletions
17
...nce-engine/tests/functional/plugin/shared/include/single_layer_tests/custom_operation.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,17 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/single_layer/custom_operation.hpp" | ||
#include "ngraph_functions/builders.hpp" | ||
|
||
namespace LayerTestsDefinitions { | ||
|
||
TEST_P(CustomOpLayerTest, CompareWithRefs) { | ||
Run(); | ||
} | ||
|
||
} // namespace LayerTestsDefinitions | ||
|
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
31 changes: 31 additions & 0 deletions
31
...ctional/shared_test_classes/include/shared_test_classes/single_layer/custom_operation.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,31 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include "shared_test_classes/base/layer_test_utils.hpp" | ||
#include "ngraph_functions/builders.hpp" | ||
|
||
namespace LayerTestsDefinitions { | ||
typedef std::tuple< | ||
InferenceEngine::Precision, // Net precision | ||
InferenceEngine::SizeVector, // Input shapes | ||
LayerTestsUtils::TargetDevice // Target device name | ||
> CustomOpLayerParams; | ||
|
||
class CustomOpLayerTest: public testing::WithParamInterface<CustomOpLayerParams>, | ||
public LayerTestsUtils::LayerTestsCommon { | ||
public: | ||
static std::string getTestCaseName(const testing::TestParamInfo<CustomOpLayerParams>& obj); | ||
|
||
InferenceEngine::Blob::Ptr GenerateInput(const InferenceEngine::InputInfo &info) const override; | ||
|
||
CustomOpLayerTest(); | ||
|
||
protected: | ||
void SetUp() override; | ||
}; | ||
|
||
} // namespace LayerTestsDefinitions | ||
|
64 changes: 64 additions & 0 deletions
64
inference-engine/tests/functional/shared_test_classes/src/single_layer/custom_operation.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,64 @@ | ||
// Copyright (C) 2018-2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "shared_test_classes/single_layer/custom_operation.hpp" | ||
#include <ngraph/ngraph.hpp> | ||
#include <ie_core.hpp> | ||
#include <file_utils.h> | ||
|
||
using namespace LayerTestsDefinitions; | ||
|
||
static std::string get_extension_path() { | ||
return FileUtils::makePluginLibraryName<char>({}, std::string("template_extension") + IE_BUILD_POSTFIX); | ||
} | ||
|
||
static const InferenceEngine::IExtensionPtr& get_extension(InferenceEngine::Core* core = nullptr) { | ||
static InferenceEngine::IExtensionPtr extension; | ||
if (!extension) { | ||
// Core is created from the cache, so create a singleton extension | ||
extension = std::make_shared<InferenceEngine::Extension>(get_extension_path()); | ||
if (core) { | ||
core->AddExtension(extension); | ||
} | ||
} | ||
return extension; | ||
} | ||
|
||
CustomOpLayerTest::CustomOpLayerTest(): LayerTestsUtils::LayerTestsCommon() { | ||
get_extension(core.get()); | ||
} | ||
|
||
std::string CustomOpLayerTest::getTestCaseName(const testing::TestParamInfo<CustomOpLayerParams>& obj) { | ||
InferenceEngine::Precision netPrecision; | ||
InferenceEngine::SizeVector inputShapes; | ||
std::string targetDevice; | ||
std::tie(netPrecision, inputShapes, targetDevice) = obj.param; | ||
|
||
std::ostringstream result; | ||
result << "IS=" << CommonTestUtils::vec2str(inputShapes) << "_"; | ||
result << "netPRC=" << netPrecision.name() << "_"; | ||
result << "trgDev=" << targetDevice; | ||
return result.str(); | ||
} | ||
|
||
InferenceEngine::Blob::Ptr CustomOpLayerTest::GenerateInput(const InferenceEngine::InputInfo &info) const { | ||
return FuncTestUtils::createAndFillBlobConsistently(info.getTensorDesc(), 3, 0, 1); | ||
} | ||
|
||
void CustomOpLayerTest::SetUp() { | ||
InferenceEngine::Precision netPrecision; | ||
InferenceEngine::SizeVector inputShapes; | ||
std::tie(netPrecision, inputShapes, targetDevice) = this->GetParam(); | ||
auto ngPrc = FuncTestUtils::PrecisionUtils::convertIE2nGraphPrc(netPrecision); | ||
|
||
auto params = ngraph::builder::makeParams(ngPrc, {inputShapes}); | ||
|
||
std::shared_ptr<ngraph::Node> customOp; | ||
ASSERT_NO_THROW(customOp.reset(get_extension()->getOpSets()["custom_opset"].create("Template"))); | ||
customOp->set_argument(0, params[0]); | ||
customOp->validate_and_infer_types(); | ||
|
||
ngraph::ResultVector results{std::make_shared<ngraph::opset4::Result>(customOp)}; | ||
function = std::make_shared<ngraph::Function>(results, params, "CustomOpInference"); | ||
} |