From c9f55a365697193bc95bd27b1a7ba39eeb5d41aa Mon Sep 17 00:00:00 2001 From: Parichay Kapoor Date: Wed, 28 Aug 2019 17:02:22 +0900 Subject: [PATCH] [filter plugins] Remove dependency on gst headers Remove dependency of tensor_filter plugins and tensor_subplugin on gst headers Signed-off-by: Parichay Kapoor --- .../tensor_filter/tensor_filter_python_core.h | 1 - .../tensor_filter/tensor_filter_pytorch_core.cc | 12 ++++++------ .../tensor_filter/tensor_filter_pytorch_core.h | 1 - .../tensor_filter/tensor_filter_tensorflow_core.h | 1 - .../tensor_filter_tensorflow_lite_core.cc | 18 +++++++++--------- .../tensor_filter/tensor_filter_tensorflow_lite_core.h | 1 - gst/nnstreamer/nnstreamer_subplugin.c | 7 +++---- gst/nnstreamer/tensor_filter/tensor_filter_custom.c | 3 +-- 8 files changed, 19 insertions(+), 25 deletions(-) diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_python_core.h b/ext/nnstreamer/tensor_filter/tensor_filter_python_core.h index 37059fd..38f6901 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_python_core.h +++ b/ext/nnstreamer/tensor_filter/tensor_filter_python_core.h @@ -29,7 +29,6 @@ #include #include -#include #include #include #include diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.cc b/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.cc index d2b0c7d..8e2b807 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.cc +++ b/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.cc @@ -16,7 +16,7 @@ /** * @file tensor_filter_pytorch_core.cc * @author Parichay Kapoor - * @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; } } diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.h b/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.h index a52151a..8428a4e 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.h +++ b/ext/nnstreamer/tensor_filter/tensor_filter_pytorch_core.h @@ -25,7 +25,6 @@ #include -#include #include "nnstreamer_plugin_api_filter.h" diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h index e613b89..50cf6a6 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_core.h @@ -27,7 +27,6 @@ #define TENSOR_FILTER_TENSORFLOW_CORE_H #include -#include #include "nnstreamer_plugin_api_filter.h" 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 f70fff2..3030815 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.cc @@ -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 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 3cf882d..5ee21e9 100644 --- a/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h +++ b/ext/nnstreamer/tensor_filter/tensor_filter_tensorflow_lite_core.h @@ -24,7 +24,6 @@ #define TENSOR_FILTER_TENSORFLOW_LITE_CORE_H #include -#include #include "nnstreamer_plugin_api_filter.h" diff --git a/gst/nnstreamer/nnstreamer_subplugin.c b/gst/nnstreamer/nnstreamer_subplugin.c index 5cbbcf0..b45acd9 100644 --- a/gst/nnstreamer/nnstreamer_subplugin.c +++ b/gst/nnstreamer/nnstreamer_subplugin.c @@ -26,7 +26,6 @@ #include #include #include -#include #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; } } diff --git a/gst/nnstreamer/tensor_filter/tensor_filter_custom.c b/gst/nnstreamer/tensor_filter/tensor_filter_custom.c index d6f671a..e399cdc 100644 --- a/gst/nnstreamer/tensor_filter/tensor_filter_custom.c +++ b/gst/nnstreamer/tensor_filter/tensor_filter_custom.c @@ -26,7 +26,6 @@ * */ -#include #include #include @@ -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; -- 2.7.4