From 086a5c5b26cc67c8eaf5de95eb81502b50f8c035 Mon Sep 17 00:00:00 2001 From: Nikita Kudriavtsev Date: Wed, 10 Jun 2020 16:42:37 +0300 Subject: [PATCH] [IE Myriad] Added test InferWorksCorrectAfter9999Allocations (#709) --- .../behavior/stress_tests.cpp | 17 +++++++ .../shared/include/behavior/stress_tests.hpp | 33 ++++++++++++++ .../plugin/shared/src/behavior/stress_tests.cpp | 53 ++++++++++++++++++++++ .../functional_test_utils/layer_test_utils.cpp | 1 + .../functional_test_utils/layer_test_utils.hpp | 4 +- 5 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/behavior/stress_tests.hpp create mode 100644 inference-engine/tests/functional/plugin/shared/src/behavior/stress_tests.cpp diff --git a/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp new file mode 100644 index 0000000..9619f5d --- /dev/null +++ b/inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "behavior/stress_tests.hpp" + +using namespace LayerTestsDefinitions; + +const unsigned int g_BugAllocationLimit = 10000; + +namespace { + INSTANTIATE_TEST_CASE_P(BehaviorTests, MultipleAllocations, + ::testing::Combine( + ::testing::Values(CommonTestUtils::DEVICE_MYRIAD), + ::testing::Values(g_BugAllocationLimit)), + MultipleAllocations::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/stress_tests.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/stress_tests.hpp new file mode 100644 index 0000000..fe80423 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/stress_tests.hpp @@ -0,0 +1,33 @@ +// Copyright (C) 2018-2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include +#include +#include +#include + +#include "functional_test_utils/layer_test_utils.hpp" + +namespace LayerTestsDefinitions { + +typedef std::tuple< + LayerTestsUtils::TargetDevice, // Device name + unsigned int // Allocations count +> MultipleAllocationsParams; + +class MultipleAllocations : public testing::WithParamInterface, + public LayerTestsUtils::LayerTestsCommon { +public: + static std::string getTestCaseName(const testing::TestParamInfo& obj); + +protected: + void SetUp() override; + +protected: + unsigned int m_allocationsCount = 0; +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/shared/src/behavior/stress_tests.cpp b/inference-engine/tests/functional/plugin/shared/src/behavior/stress_tests.cpp new file mode 100644 index 0000000..58b1aeb --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/src/behavior/stress_tests.cpp @@ -0,0 +1,53 @@ +// Copyright (C) 2018-2020 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "behavior/stress_tests.hpp" +#include "ngraph_functions/subgraph_builders.hpp" + +namespace LayerTestsDefinitions { + +std::string MultipleAllocations::getTestCaseName(const testing::TestParamInfo& obj) { + LayerTestsUtils::TargetDevice targetDevice; + unsigned int allocationsCount; + + std::tie(targetDevice, allocationsCount) = obj.param; + std::ostringstream result; + result << "targetDevice=" << targetDevice << "_"; + result << "allocationsCount=" << allocationsCount; + return result.str(); +} + +void MultipleAllocations::SetUp() { + std::tie(targetDevice, m_allocationsCount) = this->GetParam(); + function = ngraph::builder::subgraph::makeSplitConvConcat(); +} + +TEST_P(MultipleAllocations, InferWorksCorrectAfterAllocations) { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + + ConfigurePlugin(); + + InferenceEngine::CNNNetwork cnnNet(function); + auto ie = PluginCache::get().ie(); + + std::cout << "Load the network " << m_allocationsCount << " times..." << std::flush; + for (int i = 0; i < m_allocationsCount; ++i) { + ie->LoadNetwork(cnnNet, targetDevice); + } + + std::cout << "\nCheck inference.\n"; + + // Experiments demonstrated that 10 cycles are enough to reproduce the issue + int infersCount = 10; + for (int j = 0; j < infersCount; ++j) { + LoadNetwork(); + + std::cout << "Infer(): " << j << std::flush; + + Infer(); + Validate(); + } +}; + +} // namespace LayerTestsDefinitions diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.cpp b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.cpp index 257976e..9815a2b 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.cpp +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.cpp @@ -88,6 +88,7 @@ void LayerTestsCommon::LoadNetwork() { void LayerTestsCommon::Infer() { inferRequest = executableNetwork.CreateInferRequest(); + inputs.clear(); for (const auto &input : cnnNetwork.getInputsInfo()) { const auto &info = input.second; diff --git a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.hpp b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.hpp index 1d0c3e2..7b105e6 100644 --- a/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.hpp +++ b/inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.hpp @@ -88,6 +88,8 @@ protected: void LoadNetwork(); + void Infer(); + TargetDevice targetDevice; std::shared_ptr function; std::map configuration; @@ -107,8 +109,6 @@ protected: private: void ConfigureNetwork() const; - void Infer(); - std::vector GetOutputs(); std::shared_ptr core; -- 2.7.4