[Test/CodeClean] macro to handle tensor info
authorJaeyun Jung <jy1210.jung@samsung.com>
Thu, 9 Nov 2023 10:28:22 +0000 (19:28 +0900)
committerwooksong <wook16.song@samsung.com>
Mon, 13 Nov 2023 04:19:40 +0000 (13:19 +0900)
Code clean, use valid macro in test.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
tests/nnstreamer_example/custom_example_LSTM/dummy_LSTM.c
tests/nnstreamer_filter_openvino/unittest_openvino.cc

index 662eb8c..24276e6 100644 (file)
@@ -25,6 +25,7 @@
 #include <glib.h>
 
 #define TSIZE   (4)
+#define MAX_INFO (3)
 
 /**
  * @brief _pt_data
@@ -33,7 +34,7 @@ typedef struct _pt_data
 {
   uint32_t id; /***< Just for testing */
   uint32_t counter; /**< Internal frame counter for debugging/demo */
-  GstTensorInfo info[3]; /**< tensor info. 0:new frame / 1:recurring frame 2:recurring frame*/
+  GstTensorInfo info[MAX_INFO]; /**< tensor info. 0:new frame / 1:recurring frame 2:recurring frame*/
 } pt_data;
 
 /**
@@ -69,12 +70,14 @@ static void
 pt_exit (void *private_data, const GstTensorFilterProperties * prop)
 {
   pt_data *data = private_data;
+  int i;
+
   UNUSED (prop);
   assert (data);
 
-  g_free (data->info[0].name);
-  g_free (data->info[1].name);
-  g_free (data->info[2].name);
+  for (i = 0; i < MAX_INFO; i++)
+    gst_tensor_info_free (&data->info[i]);
+
   free (data);
 }
 
@@ -86,10 +89,9 @@ pt_exit (void *private_data, const GstTensorFilterProperties * prop)
     unsigned int i = 0; \
     unsigned int num_tensors = 0; \
     num_tensors = _info->num_tensors; \
-    assert (0 < num_tensors && num_tensors <= NNS_TENSOR_SIZE_LIMIT); \
+    assert (0 < num_tensors && num_tensors <= MAX_INFO); \
     for (i = 0; i < num_tensors; ++i) { \
-      _info->info[i] = _data->info[i]; \
-      _info->info[i].name = g_strdup (_data->info[i].name); \
+      gst_tensor_info_copy (&_info->info[i], &_data->info[i]); \
     } \
   } while (0)
 
index a88e401..2468988 100644 (file)
 const static gchar MODEL_BASE_NAME_MOBINET_V2[] = "openvino_mobilenetv2-int8-tf-0001";
 
 const static uint32_t MOBINET_V2_IN_NUM_TENSOR = 1;
-const static uint32_t MOBINET_V2_IN_DIMS[NNS_TENSOR_SIZE_LIMIT] = {
+const static uint32_t MOBINET_V2_IN_DIMS[NNS_TENSOR_RANK_LIMIT] = {
   224,
   224,
   3,
   1,
+  0,
 };
 const static uint32_t MOBINET_V2_OUT_NUM_TENSOR = 1;
-const static uint32_t MOBINET_V2_OUT_DIMS[NNS_TENSOR_SIZE_LIMIT] = {
+const static uint32_t MOBINET_V2_OUT_DIMS[NNS_TENSOR_RANK_LIMIT] = {
   1001,
   1,
   1,
   1,
+  0,
 };
 
 /** @brief wooksong: please fill in */