From 50a24f739d9131e63592b643398ffb6291cac521 Mon Sep 17 00:00:00 2001 From: Tae-Young Chung Date: Mon, 11 Jan 2021 15:40:37 +0900 Subject: [PATCH] Change inference_engine_layer_property Change inference_engine_layer_property to get map. Using the name of layer, tensor_info can be accessed. Change-Id: Iaaca014507363d77705c13bb2c4e7c855d9f4847 Signed-off-by: Tae-Young Chung --- include/inference_engine_type.h | 6 ++-- src/inference_engine_common_impl.cpp | 41 ++++++++++------------------ 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/include/inference_engine_type.h b/include/inference_engine_type.h index 0e42792..0ec4e7d 100644 --- a/include/inference_engine_type.h +++ b/include/inference_engine_type.h @@ -17,6 +17,9 @@ #ifndef __INFERENCE_ENGINE_TYPE_H__ #define __INFERENCE_ENGINE_TYPE_H__ +#include +#include + #ifdef __cplusplus extern "C" { @@ -191,8 +194,7 @@ extern "C" * @since_tizen 6.0 */ typedef struct _inference_engine_layer_property { - std::vector layer_names; /**< names of layers. */ - std::vector tensor_infos; /**< information of tensors. */ + std::map layers; // TODO. } inference_engine_layer_property; diff --git a/src/inference_engine_common_impl.cpp b/src/inference_engine_common_impl.cpp index ebb0f9f..3fdacb7 100644 --- a/src/inference_engine_common_impl.cpp +++ b/src/inference_engine_common_impl.cpp @@ -165,10 +165,15 @@ out: inference_engine_layer_property &property) { // Verity tensor info values. - std::vector::const_iterator info_iter; - for (info_iter = property.tensor_infos.begin(); - info_iter != property.tensor_infos.end(); ++info_iter) { - inference_engine_tensor_info tensor_info = *info_iter; + for (auto iter = property.layers.begin(); iter != property.layers.end(); ++iter) { + std::string name = iter->first; + + if (name.length() == 0) { + LOGE("layer name is invalid."); + return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; + } + + inference_engine_tensor_info tensor_info = iter->second; if (tensor_info.shape.size() == 0 || tensor_info.size == 0) { LOGE("shape size of tensor info or size of it is 0."); return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; @@ -179,20 +184,6 @@ out: LOGE("tensor data type is invalid."); return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; } - - // TODO. we may need to check shape type also. - } - - // Verity layer names. - std::vector::const_iterator name_iter; - for (name_iter = property.layer_names.begin(); - name_iter != property.layer_names.end(); ++name_iter) { - std::string name = *name_iter; - - if (name.length() == 0) { - LOGE("layer name is invalid."); - return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; - } } return INFERENCE_ENGINE_ERROR_NONE; @@ -527,8 +518,7 @@ out: // If backend engine doesn't provide input layer property information then just return. // In this case, user has to provide the information manually. - if (property.layer_names.size() == 0 && - property.tensor_infos.size() == 0) { + if (property.layers.size() == 0) { LOGI("backend doesn't provide input layer property."); return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; } @@ -549,8 +539,7 @@ out: // If backend engine doesn't provide output layer property information then just return. // In this case, user has to provide the information manually. - if (property.layer_names.size() == 0 && - property.tensor_infos.size() == 0) { + if (property.layers.size() == 0) { LOGI("backend doesn't provide output layer property."); return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; } @@ -563,8 +552,8 @@ out: { CHECK_ENGINE_INSTANCE(mBackendHandle); - if (property.layer_names.empty() || property.tensor_infos.empty()) { - LOGE("layer_names or tensor_infos vector of a given property is empty."); + if (property.layers.empty()) { + LOGE("property is empty."); return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; } @@ -582,8 +571,8 @@ out: { CHECK_ENGINE_INSTANCE(mBackendHandle); - if (property.layer_names.empty()) { - LOGE("layer_names vector of a given property is empty."); + if (property.layers.empty()) { + LOGE("property is empty."); return INFERENCE_ENGINE_ERROR_INVALID_PARAMETER; } -- 2.34.1