[IE Myriad] Added test InferWorksCorrectAfter9999Allocations (#709)
authorNikita Kudriavtsev <nikita.kudriavtsev@intel.com>
Wed, 10 Jun 2020 13:42:37 +0000 (16:42 +0300)
committerGitHub <noreply@github.com>
Wed, 10 Jun 2020 13:42:37 +0000 (16:42 +0300)
inference-engine/tests/functional/plugin/myriad/shared_tests_instances/behavior/stress_tests.cpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/shared/include/behavior/stress_tests.hpp [new file with mode: 0644]
inference-engine/tests/functional/plugin/shared/src/behavior/stress_tests.cpp [new file with mode: 0644]
inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.cpp
inference-engine/tests/ie_test_utils/functional_test_utils/layer_test_utils.hpp

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 (file)
index 0000000..9619f5d
--- /dev/null
@@ -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 (file)
index 0000000..fe80423
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright (C) 2018-2020 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <tuple>
+#include <vector>
+#include <string>
+#include <memory>
+
+#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<MultipleAllocationsParams>,
+                        public LayerTestsUtils::LayerTestsCommon {
+public:
+    static std::string getTestCaseName(const testing::TestParamInfo<MultipleAllocationsParams>& 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 (file)
index 0000000..58b1aeb
--- /dev/null
@@ -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<MultipleAllocationsParams>& 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
index 257976e..9815a2b 100644 (file)
@@ -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;
index 1d0c3e2..7b105e6 100644 (file)
@@ -88,6 +88,8 @@ protected:
 
     void LoadNetwork();
 
+    void Infer();
+
     TargetDevice targetDevice;
     std::shared_ptr<ngraph::Function> function;
     std::map<std::string, std::string> configuration;
@@ -107,8 +109,6 @@ protected:
 private:
     void ConfigureNetwork() const;
 
-    void Infer();
-
     std::vector<InferenceEngine::Blob::Ptr> GetOutputs();
 
     std::shared_ptr<InferenceEngine::Core> core;