[filter plugins] Remove dependency on gst headers
authorParichay Kapoor <pk.kapoor@samsung.com>
Wed, 28 Aug 2019 08:02:22 +0000 (17:02 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 29 Aug 2019 01:20:08 +0000 (10:20 +0900)
Remove dependency of tensor_filter plugins and tensor_subplugin on gst headers

Signed-off-by: Parichay Kapoor <pk.kapoor@samsung.com>
ext/nnstreamer/tensor_filter/tensor_filter_python_core.h
ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.h
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc
ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h
gst/nnstreamer/nnstreamer_subplugin.c
gst/nnstreamer/tensor_filter/tensor_filter_custom.c

index 37059fd..38f6901 100644 (file)
@@ -29,7 +29,6 @@
 #include <numpy/arrayobject.h>
 
 #include <glib.h>
-#include <gst/gst.h>
 #include <string.h>
 #include <dlfcn.h>
 #include <pthread.h>
index d2b0c7d..8e2b807 100644 (file)
@@ -16,7 +16,7 @@
 /**
  * @file   tensor_filter_pytorch_core.cc
  * @author Parichay Kapoor <pk.kapoor@samsung.com>
- * @date        24 April 2019
+ * @date   24 April 2019
  * @brief  connection with pytorch libraries
  * @bug    No known bugs except for NYI items
  */
@@ -74,7 +74,7 @@ TorchCore::init (const GstTensorFilterProperties * prop,
   gst_tensors_info_copy (&outputTensorMeta, &prop->output_meta);
 
   if (loadModel ()) {
-    GST_ERROR ("Failed to load model\n");
+    g_critical ("Failed to load model\n");
     return -1;
   }
   return 0;
@@ -209,14 +209,14 @@ TorchCore::validateOutputTensor (const at::Tensor output)
   auto tensor_shape = output.sizes ();
 
   if (tensor_shape[0] != 0 && outputTensorMeta.num_tensors != tensor_shape[0]) {
-    GST_ERROR ("Invalid output meta: different size");
+    g_critical ("Invalid output meta: different size");
     return -1;
   }
 
   if (tensor_shape[0] == 0) {
     tensor_type otype = getTensorTypeFromTorch (output.scalar_type ());
     if (outputTensorMeta.info[0].type != otype) {
-      GST_ERROR ("Invalid output meta: different type");
+      g_critical ("Invalid output meta: different type");
       return -2;
     }
     goto done;
@@ -239,12 +239,12 @@ TorchCore::validateOutputTensor (const at::Tensor output)
     }
 
     if (outputTensorMeta.info[i].type != otype) {
-      GST_ERROR ("Invalid output meta: different type");
+      g_critical ("Invalid output meta: different type");
       return -2;
     }
 
     if (num_gst_tensor != num_torch_tensor) {
-      GST_ERROR ("Invalid output meta: different element size");
+      g_critical ("Invalid output meta: different element size");
       return -3;
     }
   }
index e613b89..50cf6a6 100644 (file)
@@ -27,7 +27,6 @@
 #define TENSOR_FILTER_TENSORFLOW_CORE_H
 
 #include <glib.h>
-#include <gst/gst.h>
 
 #include "nnstreamer_plugin_api_filter.h"
 
index f70fff2..3030815 100644 (file)
@@ -71,15 +71,15 @@ int
 TFLiteCore::init ()
 {
   if (loadModel ()) {
-    GST_ERROR ("Failed to load model\n");
+    g_critical ("Failed to load model\n");
     return -1;
   }
   if (setInputTensorProp ()) {
-    GST_ERROR ("Failed to initialize input tensor\n");
+    g_critical ("Failed to initialize input tensor\n");
     return -2;
   }
   if (setOutputTensorProp ()) {
-    GST_ERROR ("Failed to initialize output tensor\n");
+    g_critical ("Failed to initialize output tensor\n");
     return -3;
   }
   return 0;
@@ -135,7 +135,7 @@ TFLiteCore::loadModel ()
     if(use_nnapi){
       nnfw_delegate.reset(new ::nnfw::tflite::NNAPIDelegate);
       if(nnfw_delegate->BuildGraph(interpreter.get()) != kTfLiteOk){
-       GST_ERROR("Fail to BuildGraph");
+       g_critical("Fail to BuildGraph");
        return -3;
       }
     }
@@ -210,7 +210,7 @@ TFLiteCore::setInputTensorProp ()
 
   for (int i = 0; i < inputTensorMeta.num_tensors; ++i) {
     if (getTensorDim (input_idx_list[i], inputTensorMeta.info[i].dimension)) {
-      GST_ERROR ("failed to get the dimension of input tensors");
+      g_critical ("failed to get the dimension of input tensors");
       return -1;
     }
     inputTensorMeta.info[i].type =
@@ -239,7 +239,7 @@ TFLiteCore::setOutputTensorProp ()
 
   for (int i = 0; i < outputTensorMeta.num_tensors; ++i) {
     if (getTensorDim (output_idx_list[i], outputTensorMeta.info[i].dimension)) {
-      GST_ERROR ("failed to get the dimension of output tensors");
+      g_critical ("failed to get the dimension of output tensors");
       return -1;
     }
     outputTensorMeta.info[i].type =
@@ -344,18 +344,18 @@ TFLiteCore::invoke (const GstTensorMemory * input, GstTensorMemory * output)
 #ifdef ENABLE_NNFW
   if(use_nnapi){
     if(nnfw_delegate->Invoke(interpreter.get()) != kTfLiteOk){
-      GST_ERROR ("Failed to invoke");
+      g_critical ("Failed to invoke");
       return -3;
     }
   }else{
     if (interpreter->Invoke () != kTfLiteOk) {
-      GST_ERROR ("Failed to invoke");
+      g_critical ("Failed to invoke");
       return -3;
     }
   }
 #else
   if (interpreter->Invoke () != kTfLiteOk) {
-    GST_ERROR ("Failed to invoke");
+    g_critical ("Failed to invoke");
     return -3;
   }
 #endif
index 3cf882d..5ee21e9 100644 (file)
@@ -24,7 +24,6 @@
 #define TENSOR_FILTER_TENSORFLOW_LITE_CORE_H
 
 #include <glib.h>
-#include <gst/gst.h>
 
 #include "nnstreamer_plugin_api_filter.h"
 
index 5cbbcf0..b45acd9 100644 (file)
@@ -26,7 +26,6 @@
 #include <dlfcn.h>
 #include <glib.h>
 #include <gmodule.h>
-#include <gst/gstinfo.h>
 #include "nnstreamer_subplugin.h"
 #include "nnstreamer_conf.h"
 
@@ -86,7 +85,7 @@ get_subplugin (subpluginType type, const char *name)
     dlerror ();
     handle = dlopen (fullpath, RTLD_NOW);
     if (NULL == handle) {
-      GST_ERROR ("Cannot dlopen %s (%s) with error %s.", name, fullpath,
+      g_critical ("Cannot dlopen %s (%s) with error %s.", name, fullpath,
           dlerror ());
       return NULL;
     }
@@ -96,7 +95,7 @@ get_subplugin (subpluginType type, const char *name)
     /* If a subplugin's constructor has called register_subplugin, skip the rest */
     data = g_hash_table_lookup (table, name);
     if (data == NULL) {
-      GST_ERROR
+      g_critical
           ("nnstreamer_subplugin of %s (%s) is broken. It does not call register_subplugin with its init function.",
           name, fullpath);
       goto error_handle;
@@ -146,7 +145,7 @@ register_subplugin (subpluginType type, const char *name, const void *data)
 
     if (data) {
       /* already exists */
-      GST_ERROR ("Subplugin %s is already registered.", name);
+      g_critical ("Subplugin %s is already registered.", name);
       return FALSE;
     }
   }
index d6f671a..e399cdc 100644 (file)
@@ -26,7 +26,6 @@
  *
  */
 
-#include <gst/gst.h>
 #include <glib.h>
 #include <dlfcn.h>
 
@@ -92,7 +91,7 @@ custom_loadlib (const GstTensorFilterProperties * prop, void **private_data)
       *((NNStreamer_custom_class **) dlsym (ptr->handle, "NNStreamer_custom"));
   dlsym_error = dlerror ();
   if (dlsym_error) {
-    GST_ERROR ("tensor_filter_custom:loadlib error: %s\n", dlsym_error);
+    g_critical ("tensor_filter_custom:loadlib error: %s\n", dlsym_error);
     dlclose (ptr->handle);
     g_free (ptr);
     *private_data = NULL;