[Filter] Add skeleton for Intel Movidius Neural Compute Stick support
authorWook Song <wook16.song@samsung.com>
Mon, 13 May 2019 08:23:00 +0000 (17:23 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 16 May 2019 06:01:38 +0000 (15:01 +0900)
This patch adds skeleton code of a tensor_filter sub-plugin using Neural
Compute SDK ver.2 for Intel Movidius Neural Compute Stick support. The
build tree is also revised to include this sub-plugin.

Signed-off-by: Wook Song <wook16.song@samsung.com>
ext/nnstreamer/tensor_filter/meson.build
ext/nnstreamer/tensor_filter/tensor_filter_movidius_ncsdk2.c [new file with mode: 0644]
meson_options.txt

index 4cf6b84..b94597e 100644 (file)
@@ -57,3 +57,32 @@ if get_option('enable-tensorflow-lite')
     install_dir: nnstreamer_libdir
   )
 endif
+
+if get_option('enable-movidius-ncsdk2')
+  filter_sub_mvncsdk2_sources = [
+    'tensor_filter_movidius_ncsdk2.c'
+  ]
+
+  nnstreamer_filter_mvncsdk2_sources = []
+  foreach s : filter_sub_mvncsdk2_sources
+    nnstreamer_filter_mvncsdk2_sources += join_paths(meson.current_source_dir(), s)
+  endforeach
+
+  nnstreamer_filter_mvncsdk2_deps = [glib_dep, gst_dep, nnstreamer_dep]
+
+  shared_library('nnstreamer_filter_movidius-ncsdk2',
+    nnstreamer_filter_mvncsdk2_sources,
+    c_args: ['-Wno-sign-compare'],
+    dependencies: nnstreamer_filter_mvncsdk2_deps,
+    install: false,
+    install_dir: filter_subplugin_install_dir
+  )
+
+  static_library('nnstreamer_filter_movidius-ncsdk2',
+    nnstreamer_filter_mvncsdk2_sources,
+    c_args: ['-Wno-sign-compare'],
+    dependencies: nnstreamer_filter_mvncsdk2_deps,
+    install: false,
+    install_dir: nnstreamer_libdir
+  )
+endif
diff --git a/ext/nnstreamer/tensor_filter/tensor_filter_movidius_ncsdk2.c b/ext/nnstreamer/tensor_filter/tensor_filter_movidius_ncsdk2.c
new file mode 100644 (file)
index 0000000..de52f74
--- /dev/null
@@ -0,0 +1,135 @@
+/**
+ * A Tensor Filter Extension for NCSDK Ver.2 (Intel Movidius Neural Compute Stick)
+ * Copyright (C) 2019 Wook Song <wook16.song@samsung.com>
+ * Copyright (C) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ */
+
+/**
+ * @file    tensor_filter_movidius_ncsdk2.c
+ * @date    13 May 2019
+ * @brief   NCSDK2 module for tensor_filter gstreamer plugin
+ * @see     http://github.com/nnsuite/nnstreamer
+ * @author  Wook16.song <wook16.song@samsung.com>
+ * @bug     No known bugs except for NYI items
+ *
+ * This is the per-NN-framework plugin (Intel Movidius NCSDK2) for tensor_filter.
+ * TODO: Fill in "GstTensorFilterFramework" for tensor_filter.h/c
+ *
+ */
+
+#include <glib.h>
+#include <nnstreamer_plugin_api_filter.h>
+
+void init_filter_mvncsdk2 (void) __attribute__ ((constructor));
+void fini_filter_mvncsdk2 (void) __attribute__ ((destructor));
+
+/**
+ * @brief internal data of mvncsdk2
+ */
+typedef struct _mvncsdk2_data
+{
+  void *private_data;
+} mvncsdk2_data;
+
+/**
+ * @brief Free privateData and move on.
+ */
+static void
+_mvncsdk2_close (const GstTensorFilterProperties * prop, void **private_data)
+{
+  return;
+}
+
+/**
+ * @brief The open callback for GstTensorFilterFramework. Called before anything else
+ * @param prop : property of tensor_filter instance
+ * @param private_data : movidius-ncsdk2  plugin's private data
+ * @todo : fill this function
+ */
+static int
+_mvncsdk2_open (const GstTensorFilterProperties * prop, void **private_data)
+{
+  return 0;
+}
+
+/**
+ * @brief The mandatory callback for GstTensorFilterFramework
+ * @param prop : property of tensor_filter instance
+ * @param private_data : movidius-ncsdk2 plugin's private data
+ * @param[in] input : The array of input tensors
+ * @param[out] output : The array of output tensors
+ * @return 0 if OK. non-zero if error.
+ * @todo : fill this function
+ */
+static int
+_mvncsdk2_invoke (const GstTensorFilterProperties * prop, void **private_data,
+    const GstTensorMemory * input, GstTensorMemory * output)
+{
+  return 0;
+}
+
+/**
+ * @brief The optional callback for GstTensorFilterFramework
+ * @param prop : property of tensor_filter instance
+ * @param private_data : movidius-ncsdk2 plugin's private data
+ * @param[out] info : The dimesions and types of input tensors
+ * @todo : fill this function
+ */
+static int
+_mvncsdk2_getInputDim (const GstTensorFilterProperties * prop, void **private_data,
+    GstTensorsInfo * info)
+{
+  return 0;
+}
+
+/**
+ * @brief The optional callback for GstTensorFilterFramework
+ * @param prop : property of tensor_filter instance
+ * @param private_data : tensorflow lite plugin's private data
+ * @param[out] info : The dimesions and types of output tensors
+ * @todo : fill this function
+ */
+static int
+_mvncsdk2_getOutputDim (const GstTensorFilterProperties * prop,
+    void **private_data, GstTensorsInfo * info)
+{
+  return 0;
+}
+
+static gchar filter_subplugin_movidius_ncsdk2[] = "movidius-ncsdk2";
+
+static GstTensorFilterFramework NNS_support_movidius_ncsdk2 = {
+  .name = filter_subplugin_movidius_ncsdk2,
+  .allow_in_place = FALSE,
+  .allocate_in_invoke = FALSE,
+  .invoke_NN = _mvncsdk2_invoke,
+  .getInputDimension = _mvncsdk2_getInputDim,
+  .getOutputDimension = _mvncsdk2_getOutputDim,
+  .open = _mvncsdk2_open,
+  .close = _mvncsdk2_close,
+};
+
+/** @brief Initialize this object for tensor_filter subplugin runtime register */
+void
+init_filter_mvncsdk2 (void)
+{
+  nnstreamer_filter_probe (&NNS_support_movidius_ncsdk2);
+}
+
+/** @brief Destruct the subplugin */
+void
+fini_filter_mvncsdk2 (void)
+{
+  nnstreamer_filter_exit (NNS_support_movidius_ncsdk2.name);
+}
index 878e319..7608e83 100644 (file)
@@ -3,6 +3,7 @@ option('install-test', type: 'boolean', value: false)
 option('enable-opencv-test', type: 'boolean', value: true)
 option('enable-tensorflow-lite', type: 'boolean', value: true)
 option('enable-tensorflow', type: 'boolean', value: true)
+option('enable-movidius-ncsdk2', type: 'boolean', value: false)
 option('enable-tensorflow-mem-optmz', type: 'boolean', value: true)
 option('install-example', type: 'boolean', value: false)
 option('disable-video-support', type: 'boolean', value: false)