mv_inference: Get layer propery only in required case
authorInki Dae <inki.dae@samsung.com>
Thu, 27 Feb 2020 04:27:53 +0000 (13:27 +0900)
committerInki Dae <inki.dae@samsung.com>
Tue, 14 Apr 2020 00:42:19 +0000 (09:42 +0900)
We don't have to get input/output layer property from a backend
always so get the property only in case input/output tensor buffer
vectors are empty.

Change-Id: Iaa38105a283bd768a9e392ee537621f19662c11d
Signed-off-by: Inki Dae <inki.dae@samsung.com>
mv_inference/inference/src/Inference.cpp

index dfab4bdc6be6f2af914304ed7401b585830e2684..2d10ede505a76cf83309390eb725bb15121036f5 100755 (executable)
@@ -415,15 +415,16 @@ int Inference::PrepareTenosrBuffers(void)
                return ConvertEngineErrorToVisionError(ret);
        }
 
-       ret = mBackend->GetInputLayerProperty(mInputLayerProperty);
-       if (ret != INFERENCE_ENGINE_ERROR_NONE) {
-               LOGE("Fail to get input layer property from backend engine.");
-               return ConvertEngineErrorToVisionError(ret);
-       }
-
        // If the backend engine isn't able to allocate input tensor buffers internally,
        // then allocate the buffers at here.
        if (mInputTensorBuffers.empty()) {
+               // Get input tensor information from backend to allocate input tensor buffers.
+               ret = mBackend->GetInputLayerProperty(mInputLayerProperty);
+               if (ret != INFERENCE_ENGINE_ERROR_NONE) {
+                       LOGE("Fail to get input layer property from backend engine.");
+                       return ConvertEngineErrorToVisionError(ret);
+               }
+
                for (int i = 0; i < mInputLayerProperty.tensor_infos.size(); ++i) {
                        inference_engine_tensor_info tensor_info = mInputLayerProperty.tensor_infos[i];
                        inference_engine_tensor_buffer tensor_buffer;
@@ -456,15 +457,16 @@ int Inference::PrepareTenosrBuffers(void)
                return ConvertEngineErrorToVisionError(ret);
        }
 
-       ret = mBackend->GetOutputLayerProperty(mOutputLayerProperty);
-       if (ret != INFERENCE_ENGINE_ERROR_NONE) {
-               LOGE("Fail to get output layer property from backend engine.");
-               return ConvertEngineErrorToVisionError(ret);
-       }
-
        // If the backend engine isn't able to allocate output tensor buffers internally,
        // then allocate the buffers at here.
        if (mOutputTensorBuffers.empty()) {
+               // Get output tensor information from backend to allocate output tensor buffers.
+               ret = mBackend->GetOutputLayerProperty(mOutputLayerProperty);
+               if (ret != INFERENCE_ENGINE_ERROR_NONE) {
+                       LOGE("Fail to get output layer property from backend engine.");
+                       return ConvertEngineErrorToVisionError(ret);
+               }
+
                for (int i = 0; i < mOutputLayerProperty.tensor_infos.size(); ++i) {
                        inference_engine_tensor_info tensor_info = mOutputLayerProperty.tensor_infos[i];
                        inference_engine_tensor_buffer tensor_buffer;