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] Added support for network inputs and outputs with the same name. (
- Loading branch information
Showing
7 changed files
with
190 additions
and
68 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
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
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
14 changes: 14 additions & 0 deletions
14
...ne/tests/functional/plugin/cpu/shared_tests_instances/subgraph_tests/parameter_result.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,14 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "subgraph_tests/parameter_result.hpp" | ||
#include "common_test_utils/test_constants.hpp" | ||
|
||
using namespace SubgraphTestsDefinitions; | ||
|
||
namespace { | ||
INSTANTIATE_TEST_CASE_P(smoke_Check, ParameterResultSubgraphTest, | ||
::testing::Values(CommonTestUtils::DEVICE_CPU), | ||
ParameterResultSubgraphTest::getTestCaseName); | ||
} // namespace |
88 changes: 88 additions & 0 deletions
88
inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/param_result_custom_blob.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,88 @@ | ||
// Copyright (C) 2021 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#include "shared_test_classes/subgraph/parameter_result.hpp" | ||
#include "common_test_utils/test_constants.hpp" | ||
|
||
using namespace SubgraphTestsDefinitions; | ||
using namespace InferenceEngine; | ||
|
||
namespace CPULayerTestsDefinitions { | ||
|
||
class ParameterResultCustomBlobTest : public ParameterResultSubgraphTest { | ||
protected: | ||
void Infer() override { | ||
constexpr size_t inferIterations = 10lu; | ||
|
||
inferRequest = executableNetwork.CreateInferRequest(); | ||
|
||
auto inputBlob = inputs.front(); | ||
const size_t elementsCount = inputBlob->size(); | ||
for (size_t i = 0; i < inferIterations; ++i) { | ||
CommonTestUtils::fill_data_random<Precision::FP32>(inputBlob, 10, 0, 1, i); | ||
const auto& inputsInfo = cnnNetwork.getInputsInfo().begin()->second; | ||
std::string inputName = cnnNetwork.getInputsInfo().begin()->first; | ||
|
||
float* customInpData = new float[elementsCount]; | ||
auto inpBlobData = inputBlob->buffer().as<const float *>(); | ||
std::copy(inpBlobData, inpBlobData + elementsCount, customInpData); | ||
|
||
auto& tensorDesc = inputsInfo->getTensorDesc(); | ||
auto customBlob = make_shared_blob<float>(tensorDesc, customInpData, elementsCount * sizeof(float)); | ||
inferRequest.SetBlob(inputName, customBlob); | ||
|
||
inferRequest.Infer(); | ||
|
||
ParameterResultSubgraphTest::Validate(); | ||
|
||
delete[] customInpData; | ||
} | ||
} | ||
void Validate() override { | ||
//Do nothing. We call Validate() in the Infer() method | ||
} | ||
}; | ||
|
||
TEST_P(ParameterResultCustomBlobTest, CompareWithRefs) { | ||
SKIP_IF_CURRENT_TEST_IS_DISABLED() | ||
|
||
// Just to show that it is not possible to set different precisions for inputs and outputs with the same name. | ||
// If it was possible, the input would have I8 precision and couldn't store data from the custom blob. | ||
inPrc = Precision::I8; | ||
outPrc = Precision::FP32; | ||
|
||
Run(); | ||
} | ||
namespace { | ||
INSTANTIATE_TEST_CASE_P(smoke_Check_Custom_Blob, ParameterResultCustomBlobTest, | ||
::testing::Values(CommonTestUtils::DEVICE_CPU), | ||
ParameterResultSubgraphTest::getTestCaseName); | ||
} // namespace | ||
|
||
class ParameterResultSameBlobTest : public ParameterResultSubgraphTest { | ||
protected: | ||
void Infer() override { | ||
constexpr size_t inferIterations = 10lu; | ||
|
||
for (size_t i = 0; i < inferIterations; ++i) { | ||
ParameterResultSubgraphTest::Infer(); | ||
ParameterResultSubgraphTest::Validate(); | ||
} | ||
} | ||
void Validate() override { | ||
//Do nothing. We call Validate() in the Infer() method | ||
} | ||
}; | ||
|
||
TEST_P(ParameterResultSameBlobTest, CompareWithRefs) { | ||
SKIP_IF_CURRENT_TEST_IS_DISABLED() | ||
|
||
Run(); | ||
} | ||
namespace { | ||
INSTANTIATE_TEST_CASE_P(smoke_Check_Same_Blob, ParameterResultSameBlobTest, | ||
::testing::Values(CommonTestUtils::DEVICE_CPU), | ||
ParameterResultSubgraphTest::getTestCaseName); | ||
} // namespace | ||
} // namespace CPULayerTestsDefinitions |