Extended test infrastructure to call per plugin configure function before running...
[platform/upstream/dldt.git] / inference-engine / tests / ie_test_utils / functional_test_utils / layer_test_utils.cpp
index b03361f..ebcbb3f 100644 (file)
@@ -2,10 +2,11 @@
 // SPDX-License-Identifier: Apache-2.0
 //
 
-#include <transformations/convert_batch_to_space.hpp>
-#include <transformations/convert_space_to_batch.hpp>
+#include <transformations/op_conversions/convert_batch_to_space.hpp>
+#include <transformations/op_conversions/convert_space_to_batch.hpp>
 
 #include "layer_test_utils.hpp"
+#include "plugin_config.hpp"
 
 namespace LayerTestsUtils {
 
@@ -16,18 +17,11 @@ LayerTestsCommon::LayerTestsCommon() : threshold(1e-2f) {
 void LayerTestsCommon::Run() {
     SKIP_IF_CURRENT_TEST_IS_DISABLED()
 
-    ConfigurePlugin();
     LoadNetwork();
     Infer();
     Validate();
 }
 
-LayerTestsCommon::~LayerTestsCommon() {
-    if (!configuration.empty()) {
-        PluginCache::get().reset();
-    }
-}
-
 InferenceEngine::Blob::Ptr LayerTestsCommon::GenerateInput(const InferenceEngine::InputInfo &info) const {
     return FuncTestUtils::createAndFillBlob(info.getTensorDesc());
 }
@@ -42,14 +36,7 @@ void LayerTestsCommon::Compare(const std::vector<std::uint8_t> &expected, const
     const auto actualBuffer = lockedMemory.as<const std::uint8_t *>();
 
     const auto &precision = actual->getTensorDesc().getPrecision();
-    auto bufferSize = actual->size();
-    // With dynamic batch, you need to size
-    if (configuration.count(InferenceEngine::PluginConfigParams::KEY_DYN_BATCH_ENABLED)) {
-        auto batchSize = actual->getTensorDesc().getDims()[0];
-        auto halfBatchSize = batchSize > 1 ? batchSize/ 2 : 1;
-        bufferSize = (actual->size() * halfBatchSize / batchSize);
-    }
-    const auto &size = bufferSize;
+    const auto &size = actual->size();
     switch (precision) {
         case InferenceEngine::Precision::FP32:
             Compare(reinterpret_cast<const float *>(expectedBuffer), reinterpret_cast<const float *>(actualBuffer),
@@ -90,12 +77,6 @@ void LayerTestsCommon::Compare(const InferenceEngine::Blob::Ptr &expected, const
     }
 }
 
-void LayerTestsCommon::ConfigurePlugin() {
-    if (!configuration.empty()) {
-        core->SetConfig(configuration, targetDevice);
-    }
-}
-
 void LayerTestsCommon::ConfigureNetwork() const {
     for (const auto &in : cnnNetwork.getInputsInfo()) {
         if (inLayout != InferenceEngine::Layout::ANY) {
@@ -118,8 +99,9 @@ void LayerTestsCommon::ConfigureNetwork() const {
 
 void LayerTestsCommon::LoadNetwork() {
     cnnNetwork = InferenceEngine::CNNNetwork{function};
+    PreparePluginConfiguration(this);
     ConfigureNetwork();
-    executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice);
+    executableNetwork = core->LoadNetwork(cnnNetwork, targetDevice, configuration);
 }
 
 void LayerTestsCommon::Infer() {
@@ -232,4 +214,12 @@ void LayerTestsCommon::Validate() {
 void LayerTestsCommon::SetRefMode(RefMode mode) {
     refMode = mode;
 }
+
+std::shared_ptr<ngraph::Function> LayerTestsCommon::GetFunction() {
+    return function;
+}
+
+std::map<std::string, std::string>& LayerTestsCommon::GetConfiguration() {
+    return configuration;
+}
 }  // namespace LayerTestsUtils