Change inference_engine_layer_property sandbox/tyzeroy/dev
authorTae-Young Chung <ty83.chung@samsung.com>
Mon, 11 Jan 2021 06:40:37 +0000 (15:40 +0900)
committerTae-Young Chung <ty83.chung@samsung.com>
Mon, 11 Jan 2021 06:40:44 +0000 (15:40 +0900)
Change inference_engine_layer_property to get
map<string, inference_engine_tensor_info>.
Using the name of layer, tensor_info can be accessed.

Change-Id: Iaaca014507363d77705c13bb2c4e7c855d9f4847
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
include/inference_engine_type.h
src/inference_engine_common_impl.cpp

index 0e42792a65315f0b02283c6a44185421a6406319..0ec4e7d6457b5143faf78a7060a4da892e5c2579 100644 (file)
@@ -17,6 +17,9 @@
 #ifndef __INFERENCE_ENGINE_TYPE_H__
 #define __INFERENCE_ENGINE_TYPE_H__
 
+#include <map>
+#include <vector>
+
 #ifdef __cplusplus
 extern "C"
 {
@@ -191,8 +194,7 @@ extern "C"
         * @since_tizen 6.0
         */
        typedef struct _inference_engine_layer_property {
-               std::vector<std::string> layer_names; /**< names of layers. */
-               std::vector<inference_engine_tensor_info> tensor_infos; /**< information of tensors. */
+               std::map<std::string, inference_engine_tensor_info> layers;
                // TODO.
        } inference_engine_layer_property;
 
index ebb0f9fb526d3f7b62a25d4da147f56907170c97..3fdacb72df56f334f22e2ab2e6ba4c7b878dd6d9 100644 (file)
@@ -165,10 +165,15 @@ out:
                        inference_engine_layer_property &property)
        {
                // Verity tensor info values.
-               std::vector<inference_engine_tensor_info>::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<std::string>::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;
                }