[TESTS] add test cases for nnapi properity
authorjijoong.moon <jijoong.moon@samsung.com>
Thu, 29 Aug 2019 02:36:37 +0000 (11:36 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 6 Sep 2019 01:12:36 +0000 (10:12 +0900)
Add test cases for reading nnapi property in tensorflow lite example.

**Self evaluation:**
1. Build test:  [X]Passed [ ]Failed [ ]Skipped
2. Run test:  [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h
tests/nnstreamer_filter_tensorflow_lite/runTest.sh

index 513ed72..01e5eff 100644 (file)
 #include "tensor_filter_tensorflow_lite_core.h"
 #include "tensor_common.h"
 
-/**
- * @brief nnapi hw type string
- */
-static const char *nnapi_hw_string[] = {
-  [NNAPI_CPU] = "cpu",
-  [NNAPI_GPU] = "gpu",
-  [NNAPI_NPU] = "npu",
-  [NNAPI_UNKNOWN] = "unknown",
-  NULL
-};
-
 void init_filter_tflite (void) __attribute__ ((constructor));
 void fini_filter_tflite (void) __attribute__ ((destructor));
 
index f391f8b..07fc9ab 100644 (file)
@@ -35,6 +35,7 @@
 #define DBG FALSE
 #endif
 
+
 /**
  * @brief      TFLiteCore creator
  * @param      _model_path     : the logical path to '{model_name}.tffile' file
@@ -145,8 +146,7 @@ TFLiteCore::loadModel ()
       }
     }
 #endif
-
-    g_message ("interpreter->UseNNAPI: %d" , use_nnapi);
+     g_message ("interpreter->UseNNAPI( %s : %s )" , use_nnapi?"true":"false", nnapi_hw_string[accel]);
 
     /** set allocation type to dynamic for in/out tensors */
     int tensor_idx;
index d38a4ce..19b478c 100644 (file)
@@ -81,6 +81,16 @@ private:
 extern "C"
 {
 #endif
+/**
+ * @brief nnapi hw type string
+ */
+  static const char *nnapi_hw_string[] = {
+    [NNAPI_CPU] = "cpu",
+    [NNAPI_GPU] = "gpu",
+    [NNAPI_NPU] = "npu",
+    [NNAPI_UNKNOWN] = "unknown",
+    NULL
+  };
 
   void *tflite_core_new (const char *_model_path, nnapi_hw hw);
   void tflite_core_delete (void * tflite);
index c5e3c3b..3d09e07 100644 (file)
@@ -78,4 +78,19 @@ gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} !
 # Fail test for invalid output properties
 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,framerate=0/1 ! tensor_converter ! tensor_filter framework=tensorflow-lite model=${PATH_TO_MODEL} output=1:7 outputtype=int8 ! filesink location=tensorfilter.out.log" 3F_n 0 1 $PERFORMANCE
 
+# Property reading test for nnapi
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,framerate=0/1 ! tensor_converter ! tensor_filter framework=tensorflow-lite model=${PATH_TO_MODEL} nnapi=true:cpu ! filesink location=tensorfilter.out.log" 2-1 1 0 $PERFORMANCE 2> info
+cat info | grep "true : cpu"
+testResult $? 2-1 "Golden test comparison" 0 1
+
+# Property reading test for nnapi
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,framerate=0/1 ! tensor_converter ! tensor_filter framework=tensorflow-lite model=${PATH_TO_MODEL} nnapi=true ! filesink location=tensorfilter.out.log" 2-2 1 0 $PERFORMANCE 2> info
+cat info | grep "true : cpu"
+testResult $? 2-2 "Golden test comparison" 0 1
+
+# Property reading test for nnapi
+gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,framerate=0/1 ! tensor_converter ! tensor_filter framework=tensorflow-lite model=${PATH_TO_MODEL} nnapi=true:gpu ! filesink location=tensorfilter.out.log" 2-3 1 0 $PERFORMANCE 2> info
+cat info | grep "true : gpu"
+testResult $? 2-3 "Golden test comparison" 0 1
+
 report