From f987fbc2c304ad5ee36ddf4c7cc4df1fc8e9d2c9 Mon Sep 17 00:00:00 2001 From: "jijoong.moon" Date: Thu, 29 Aug 2019 11:36:37 +0900 Subject: [PATCH] [TESTS] add test cases for nnapi properity 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 --- .../tensor_filter/tensor_filter_tensorflow_lite.c | 11 ----------- .../tensor_filter/tensor_filter_tensorflow_lite_core.cc | 4 ++-- .../tensor_filter/tensor_filter_tensorflow_lite_core.h | 10 ++++++++++ tests/nnstreamer_filter_tensorflow_lite/runTest.sh | 15 +++++++++++++++ 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c index 513ed72..01e5eff 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite.c @@ -32,17 +32,6 @@ #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)); diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc index f391f8b..07fc9ab 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc @@ -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; diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h index d38a4ce..19b478c 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h @@ -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); diff --git a/tests/nnstreamer_filter_tensorflow_lite/runTest.sh b/tests/nnstreamer_filter_tensorflow_lite/runTest.sh index c5e3c3b..3d09e07 100644 --- a/tests/nnstreamer_filter_tensorflow_lite/runTest.sh +++ b/tests/nnstreamer_filter_tensorflow_lite/runTest.sh @@ -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 -- 2.7.4