summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInki Dae <inki.dae@samsung.com>2020-06-11 18:08:39 +0900
committerInki Dae <inki.dae@samsung.com>2020-06-26 08:58:22 +0900
commitd92b31574bffdb68a29c2277f2c365d8dcabe839 (patch)
treee750041af557b2c63bc1e9690a78080d9b57805c
parent2eb7a667f69da6ebbe4c75078c7aa1c61f08535b (diff)
downloadmediavision-d92b31574bffdb68a29c2277f2c365d8dcabe839.tar.gz
mediavision-d92b31574bffdb68a29c2277f2c365d8dcabe839.tar.bz2
mediavision-d92b31574bffdb68a29c2277f2c365d8dcabe839.zip
test: Add NNFW backend test case
Change-Id: I779467941a3cf5c4fc260e4ad7edb4a97f4558e7 Signed-off-by: Inki Dae <inki.dae@samsung.com>
-rw-r--r--test/testsuites/inference/inference_test_suite.c89
1 files changed, 84 insertions, 5 deletions
diff --git a/test/testsuites/inference/inference_test_suite.c b/test/testsuites/inference/inference_test_suite.c
index 3b4d52f8..4929301a 100644
--- a/test/testsuites/inference/inference_test_suite.c
+++ b/test/testsuites/inference/inference_test_suite.c
@@ -39,6 +39,11 @@
"/usr/share/capi-media-vision/models/IC/tflite/ic_label.txt"
#define IC_TFLITE_WEIGHT_PATH \
"/usr/share/capi-media-vision/models/IC/tflite/ic_tflite_model.tflite"
+#define IC_Q_LABEL_PATH \
+ "/usr/share/capi-media-vision/models/IC_Q/tflite/ic_label.txt"
+#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"
@@ -651,6 +656,69 @@ int perform_armnn_mobilenetv1_config(mv_engine_config_h *engine_cfg)
return err;
}
+int perform_nnfw_mobilenetv1_quant_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] = { "MobilenetV1/Predictions/Reshape_1" };
+
+ mv_engine_config_set_string_attribute(
+ handle, MV_INFERENCE_MODEL_WEIGHT_FILE_PATH, IC_Q_TFLITE_WEIGHT_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_Q_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_NNFW);
+
+ mv_engine_config_set_int_attribute(handle, MV_INFERENCE_TARGET_TYPE,
+ MV_INFERENCE_TARGET_CPU);
+
+ mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_TENSOR_WIDTH,
+ 224);
+
+ mv_engine_config_set_int_attribute(handle, MV_INFERENCE_INPUT_TENSOR_HEIGHT,
+ 224);
+
+ 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_vivante_inceptionv3_config(mv_engine_config_h *engine_cfg)
{
int err = MEDIA_VISION_ERROR_NONE;
@@ -793,11 +861,12 @@ int perform_image_classification()
int err = MEDIA_VISION_ERROR_NONE;
int sel_opt = 0;
- const int options[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
- const char *names[8] = { "Configuration",
+ const int options[9] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ const char *names[9] = { "Configuration",
"TFLite(cpu + Mobilenet)",
"OpenCV(cpu + Squeezenet)",
"ARMNN(cpu + Mobilenet)",
+ "NNFW(cpu + Mobilenet_Q)",
"Vivante(NPU + Inceptionv3)",
"Prepare",
"Run",
@@ -856,6 +925,16 @@ int perform_image_classification()
err = perform_armnn_mobilenetv1_config(&engine_cfg);
} break;
case 5: {
+ // perform NNFW
+ 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_nnfw_mobilenetv1_quant_config(&engine_cfg);
+ } break;
+ case 6: {
// perform Vivante
if (engine_cfg) {
int err2 = mv_destroy_engine_config(engine_cfg);
@@ -865,7 +944,7 @@ int perform_image_classification()
err = perform_vivante_inceptionv3_config(&engine_cfg);
} break;
- case 6: {
+ case 7: {
//create - configure - prepare
if (infer) {
int err2 = mv_inference_destroy(infer);
@@ -896,7 +975,7 @@ int perform_image_classification()
break;
}
} break;
- case 7: {
+ case 8: {
if (mvSource) {
int err2 = mv_destroy_source(mvSource);
if (err2 != MEDIA_VISION_ERROR_NONE)
@@ -944,7 +1023,7 @@ int perform_image_classification()
printf("elased time : %lu(ms)\n", timeDiff);
} break;
- case 8: {
+ case 9: {
//perform destroy
if (engine_cfg) {
err = mv_destroy_engine_config(engine_cfg);