[Filter/tflite]Add skeleton for tflite sub-plugin
authorjinhyuck <jinhyuck83.park@samsung.com>
Thu, 5 Jul 2018 04:32:51 +0000 (13:32 +0900)
committer함명주/동작제어Lab(SR)/Principal Engineer/삼성전자 <myungjoo.ham@samsung.com>
Thu, 5 Jul 2018 05:27:33 +0000 (14:27 +0900)
add skelton code for tflite sub-plugin
"open", "close" and "setinputdimension"

Signed-off-by: jinhyuck <jinhyuck83.park@samsung.com>
gst/tensor_filter/tensor_filter_tensorflow_lite.c

index 051b103..65931ef 100644 (file)
@@ -53,6 +53,7 @@
  */
 
 #include "tensor_filter.h"
+#include <glib.h>
 
 /**
  * @brief Load tensorflow lite modelfile
@@ -66,17 +67,34 @@ tflite_loadModelFile (const GstTensor_Filter * filter, void **private_data)
    * need to load tensorflow lite model file by FlatBufferModel::BuildFromFile
    * after configuration of c->cpp api of tflite works done
    */
+
+  /* @TODO call tflite core api "tflite_new"  */
   return 0;
 }
 
 /**
+ * @brief The open callback for GstTensor_Filter_Framework. Called before anything else
+ */
+static void
+tflite_open (const GstTensor_Filter * filter, void **private_data)
+{
+  int retval = tflite_loadModelFile (filter, private_data);
+
+  g_assert (retval == 0);       /* This must be called only once */
+}
+
+/**
  * @brief The mandatory callback for GstTensor_Filter_Framework
  */
 static int
 tflite_invoke (const GstTensor_Filter * filter, void **private_data,
     const uint8_t * inptr, uint8_t * outptr)
 {
-  return 0;                     /* NYI */
+  int retval = tflite_loadModelFile (filter, private_data);
+  /* @TODO fill in *outputDimension (uint32_t[MAX_RANK]), *type */
+  /* @TODO call tflite core apis */
+
+  return retval;                /* NYI */
 }
 
 /**
@@ -88,6 +106,7 @@ tflite_getInputDim (const GstTensor_Filter * filter, void **private_data,
 {
   int retval = tflite_loadModelFile (filter, private_data);
   /* @TODO fill in *inputDimension (uint32_t[MAX_RANK]), *type */
+  /* @TODO call tflite core api "tflite_getInputDim" */
 
   return retval;                /* NYI */
 }
@@ -101,14 +120,42 @@ tflite_getOutputDim (const GstTensor_Filter * filter, void **private_data,
 {
   int retval = tflite_loadModelFile (filter, private_data);
   /* @TODO fill in *outputDimension (uint32_t[MAX_RANK]), *type */
+  /* @TODO call tflite core api "tflite_getOutputDim" */
 
   return retval;                /* NYI */
 }
 
+/**
+ * @brief The set-input-dim callback for GstTensor_Filter_Framework
+ */
+static int
+tflite_setInputDim (const GstTensor_Filter * filter, void **private_data,
+    const tensor_dim iDimension, const tensor_type iType,
+    tensor_dim oDimension, tensor_type * oType)
+{
+
+  int retval = tflite_loadModelFile (filter, private_data);
+  /* @TODO call tflite core apis */
+  return retval;                /* NYI */
+}
+
+/**
+ * @brief Free privateData and move on.
+ */
+static void
+tflite_close (const GstTensor_Filter * filter, void **private_data)
+{
+
+  /* @TODO call tflite core api "tflite_delete" */
+}
+
 GstTensor_Filter_Framework NNS_support_tensorflow_lite = {
   .name = "tensorflow-lite",
   .allow_in_place = FALSE,      /* Let's not do this yet. @TODO: support this to optimize performance later. */
   .invoke_NN = tflite_invoke,
   .getInputDimension = tflite_getInputDim,
   .getOutputDimension = tflite_getOutputDim,
+  .setInputDimension = tflite_setInputDim,
+  .open = tflite_open,
+  .close = tflite_close,
 };