test: Add Vivante NPU test case
authorInki Dae <inki.dae@samsung.com>
Mon, 22 Jun 2020 02:31:34 +0000 (11:31 +0900)
committerInki Dae <inki.dae@samsung.com>
Mon, 22 Jun 2020 02:31:34 +0000 (11:31 +0900)
Change-Id: Ifa54daac72b9d34a15c199d5c8fa6a2cbbea7374
Signed-off-by: Inki Dae <inki.dae@samsung.com>
test/testsuites/inference/inference_test_suite.c

index 4a8bc527b5ae3327cbeeb4c74b15b09c8ac0c9df..6415c3facf4c76ac2fd3452669db816fa1409ee7 100644 (file)
 #define IC_Q_TFLITE_WEIGHT_PATH \
        "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_tflite_model.tflite"
 
+#define IC_VIVANTE_LABEL_PATH "/usr/share/capi-media-vision/models/IC/vivante/ic_label.txt"
+#define IC_VIVANTE_WEIGHT_PATH "/usr/share/capi-media-vision/models/IC/vivante/ic_vivante_model.nb"
+#define IC_VIVANTE_CONFIG_PATH "/usr/share/capi-media-vision/models/IC/vivante/ic_vivante_model.so"
+
 #define IC_OPENCV_LABEL_CAFFE_PATH "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_label_squeezenet.txt"
 #define IC_OPENCV_WEIGHT_CAFFE_PATH "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_model_squeezenet.caffemodel"
 #define IC_OPENCV_CONFIG_CAFFE_PATH "/usr/share/capi-media-vision/models/IC/caffe/ic_caffe_model_squeezenet.prototxt"
@@ -889,6 +893,88 @@ int perform_armnn_mobilenetv1_config(mv_engine_config_h *engine_cfg)
     return err;
 }
 
+int perform_vivante_inceptionv3_config(mv_engine_config_h *engine_cfg)
+{
+    int err = MEDIA_VISION_ERROR_NONE;
+
+    mv_engine_config_h handle = NULL;
+    err = mv_create_engine_config(&handle);
+    if (err != MEDIA_VISION_ERROR_NONE) {
+        printf("Fail to create engine configuration handle.\n");
+        if (handle) {
+            int err2 = mv_destroy_engine_config(handle);
+            if (err2 != MEDIA_VISION_ERROR_NONE) {
+                printf("Fail to destroy engine cofniguration.\n");
+            }
+        }
+        return err;
+    }
+
+    char *inputNodeName = "input";
+    char *outputNodeName[1] = {"InceptionV3/Predictions/Peshape_1"};
+
+    mv_engine_config_set_string_attribute(handle,
+                        MV_INFERENCE_MODEL_WEIGHT_FILE_PATH,
+                        IC_VIVANTE_WEIGHT_PATH);
+
+    mv_engine_config_set_string_attribute(handle,
+                        MV_INFERENCE_MODEL_CONFIGURATION_FILE_PATH,
+                        IC_VIVANTE_CONFIG_PATH);
+
+       mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_INPUT_DATA_TYPE,
+                        MV_INFERENCE_DATA_UINT8);
+
+    mv_engine_config_set_string_attribute(handle,
+                        MV_INFERENCE_MODEL_USER_FILE_PATH,
+                        IC_VIVANTE_LABEL_PATH);
+
+    mv_engine_config_set_double_attribute(handle,
+                        MV_INFERENCE_MODEL_MEAN_VALUE,
+                        0.0);
+
+    mv_engine_config_set_double_attribute(handle,
+                        MV_INFERENCE_MODEL_STD_VALUE,
+                        1.0);
+
+    mv_engine_config_set_double_attribute(handle,
+                        MV_INFERENCE_CONFIDENCE_THRESHOLD,
+                        0.6);
+
+    mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_BACKEND_TYPE,
+                        MV_INFERENCE_BACKEND_VIVANTE);
+
+    mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_TARGET_DEVICE_TYPE,
+                        MV_INFERENCE_TARGET_DEVICE_CUSTOM);
+
+    mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_INPUT_TENSOR_WIDTH,
+                        299);
+
+    mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+                        299);
+
+    mv_engine_config_set_int_attribute(handle,
+                        MV_INFERENCE_INPUT_TENSOR_CHANNELS,
+                        3);
+
+    mv_engine_config_set_string_attribute(handle,
+                        MV_INFERENCE_INPUT_NODE_NAME,
+                        inputNodeName);
+
+    mv_engine_config_set_array_string_attribute(handle,
+                        MV_INFERENCE_OUTPUT_NODE_NAMES,
+                        outputNodeName,
+                        1);
+
+
+    *engine_cfg = handle;
+    return err;
+}
+
 int perform_nnfw_mobilenetv1_quant_config(mv_engine_config_h *engine_cfg)
 {
        int err = MEDIA_VISION_ERROR_NONE;
@@ -1045,6 +1131,7 @@ int perform_image_classification()
                              "TFLite(cpu + Mobilenet)",
                              "OpenCV(cpu + Squeezenet)",
                              "ARMNN(cpu + Mobilenet)",
+                                                        "Vivante(NPU + Inceptionv3)",
                                                         "NNFW(cpu + Mobilenet_Q)",
                              "Prepare",
                              "Run",
@@ -1055,7 +1142,7 @@ int perform_image_classification()
     mv_source_h mvSource = NULL;
 
     while(sel_opt == 0) {
-        sel_opt = show_menu("Select Action:", options, names, 7);
+        sel_opt = show_menu("Select Action:", options, names, 8);
         switch (sel_opt) {
         case 1:
         {
@@ -1109,7 +1196,19 @@ int perform_image_classification()
             err = perform_armnn_mobilenetv1_config(&engine_cfg);
         }
             break;
-               case 5:
+         case 5:
+         {
+            // perform Vivante
+            if (engine_cfg) {
+                int err2 = mv_destroy_engine_config(engine_cfg);
+                if (err2 != MEDIA_VISION_ERROR_NONE)
+                    printf("Fail to destroy engine_cfg [err:%i]\n", err2);
+            }
+
+            err = perform_vivante_inceptionv3_config(&engine_cfg);
+        }
+            break;
+               case 6:
                {
                        // perform NNFW
                        if (engine_cfg) {
@@ -1121,7 +1220,7 @@ int perform_image_classification()
                        err = perform_nnfw_mobilenetv1_quant_config(&engine_cfg);
                }
                        break;
-        case 6:
+        case 7:
         {
             //create - configure - prepare
             if (infer) {
@@ -1154,7 +1253,7 @@ int perform_image_classification()
             }
         }
             break;
-        case 7:
+        case 8:
         {
             if (mvSource) {
                 int err2 = mv_destroy_source(mvSource);
@@ -1202,7 +1301,7 @@ int perform_image_classification()
 
         }
             break;
-        case 8:
+        case 9:
         {
             //perform destroy
             if (engine_cfg) {