Consider two and more models inference support 04/240604/1
authorInki Dae <inki.dae@samsung.com>
Mon, 10 Aug 2020 02:46:36 +0000 (11:46 +0900)
committerInki Dae <inki.dae@samsung.com>
Mon, 10 Aug 2020 02:51:06 +0000 (11:51 +0900)
This patch considers two and more models inference.

Mediavision has one backend engine context per a model.
However, ARMNN requires one runtime instance for all models.
So this patch makes it to use a same runtime instance
for two and more models.

Change-Id: Icc2a42fe20fefbc0b76806e7d107b5ad961bded0
Signed-off-by: Inki Dae <inki.dae@samsung.com>
src/inference_engine_armnn.cpp
src/inference_engine_armnn_private.h

index b041db80be7fb6d8adca36c9565ef3b4a10bd8d5..c2d30e4039d229f650a60746298a4329f11c519c 100644 (file)
@@ -30,8 +30,9 @@ namespace InferenceEngineImpl
 {
 namespace ARMNNImpl
 {
+       armnn::IRuntime *InferenceARMNN::mRuntime(nullptr);
+
        InferenceARMNN::InferenceARMNN(void) :
-               mRuntime(nullptr, &armnn::IRuntime::Destroy),
                mNetwork(armnn::INetworkPtr(nullptr, nullptr)),
                mNetworkIdentifier(-1)
        {
@@ -231,9 +232,13 @@ namespace ARMNNImpl
                int ret = INFERENCE_ENGINE_ERROR_NONE;
 
                armnn::IRuntime::CreationOptions creation_options;
-               mRuntime = armnn::IRuntime::Create(creation_options);
 
-               LOGI("Created ARMNN runtime");
+               if (mRuntime == nullptr) {
+                       mRuntime = armnn::IRuntime::CreateRaw(creation_options);
+                       LOGI("Created ARMNN runtime");
+               } else {
+                       LOGI("Shared ARMNN runtime");
+               }
 
                ret = CreateNetwork(model_paths, model_format);
                if (ret != INFERENCE_ENGINE_ERROR_NONE)
index 0fc599f4428139dd6868363d7d66c0b1a8128ade..8c326e52cc5b668868ccb3d72842620b8d056c23 100644 (file)
@@ -91,7 +91,7 @@ namespace ARMNNImpl
 
                std::vector<armnn::BackendId> mAccelType;
 
-               armnn::IRuntimePtr mRuntime;
+               static armnn::IRuntime *mRuntime;
                armnn::INetworkPtr mNetwork;
                armnn::NetworkId mNetworkIdentifier;