[Transform/Orc] replace memcpy
authorJaeyun <jy1210.jung@samsung.com>
Tue, 27 Nov 2018 09:39:22 +0000 (18:39 +0900)
committerMyungJoo Ham <myungjoo.ham@gmail.com>
Thu, 29 Nov 2018 00:50:51 +0000 (00:50 +0000)
1. define macro nns_memcpy/nns_memset
2. include liborc and use orc_memcpy instead in plugin tensor-transform and tensor-aggregator.

TODO check cmake to use orc lib

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
CMakeLists.txt
debian/control
gst/nnstreamer/tensor_common.h
gst/tensor_aggregator/tensor_aggregator.c
gst/tensor_transform/tensor_transform.c
packaging/nnstreamer.spec

index ea80275..9356af0 100644 (file)
@@ -6,6 +6,7 @@ OPTION(ENABLE_TENSORFLOW_LITE "Enable tensorflow-lite support" ON)
 OPTION(ENABLE_TENSORFLOW "Enable tensorflow support" OFF)
 OPTION(INSTALL_EXAMPLE_APP "Install example applications" OFF)
 OPTION(ENABLE_TEST "Enable tests" ON)
+OPTION(ENABLE_ORC "Enable ORC" ON)
 
 IF(INSTALL_EXAMPLE_APP)
        IF(EXAMPLE_EXEC_PREFIX)
@@ -42,6 +43,16 @@ SET(PKG_MODULES
        glib-2.0
 )
 
+IF(ENABLE_ORC)
+       FIND_LIBRARY(ORC_LIB orc-0.4)
+       IF(ORC_LIB)
+               SET(PKG_MODULES ${PKG_MODULES} orc-0.4)
+               ADD_DEFINITIONS(-DHAVE_ORC)
+       ELSE(ORC_LIB)
+               MESSAGE("Cannot find orc library")
+       ENDIF(ORC_LIB)
+ENDIF(ENABLE_ORC)
+
 pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
 
 INCLUDE_DIRECTORIES(
index 0377309..981d24e 100644 (file)
@@ -7,7 +7,7 @@ Build-Depends: gcc, cmake, libgstreamer1.0-dev, libgstreamer-plugins-base1.0-dev
  debhelper (>=9),
  gstreamer1.0-tools, gstreamer1.0-plugins-base, gstreamer1.0-plugins-good,
  libpng-dev, tensorflow-lite-dev, tensorflow-dev [amd64 arm64], libcairo2-dev, libopencv-dev,
- ssat, python, python-numpy
liborc-0.4-dev, ssat, python, python-numpy
 Standards-Version: 3.9.6
 Homepage: https://github.com/nnsuite/nnstreamer
 
index 5ea7530..9c5ab53 100644 (file)
 #include <gst/base/gstcollectpads.h>
 #include <gst/gstplugin.h>
 
+#ifdef HAVE_ORC
+#include <orc/orc.h>
+
+#define nns_memcpy(d,s,n) do { \
+    if ((n) > 100) orc_memcpy ((d), (s), (n)); \
+    else memcpy ((d), (s), (n)); \
+  } while (0)
+
+#define nns_memset orc_memset
+#else
+#define nns_memcpy memcpy
+#define nns_memset memset
+#endif
+
 G_BEGIN_DECLS
 
 /**
index 7cdc0f4..c207c20 100644 (file)
@@ -757,7 +757,7 @@ gst_tensor_aggregator_concat (GstTensorAggregator * self, GstBuffer * outbuf,
 
   do {
     for (f = 0; f < self->frames_out; f++) {
-      memcpy (dest_info.data + dest_idx,
+      nns_memcpy (dest_info.data + dest_idx,
           src_info.data + src_idx + (frame_size * f), block_size);
       dest_idx += block_size;
     }
index 53eac31..bf85c69 100644 (file)
@@ -865,7 +865,8 @@ gst_tensor_transform_dimchg (GstTensorTransform * filter,
 
   if (from == to) {
     /** Useless memcpy. Do not call this or @todo do "IP" operation */
-    memcpy (outptr, inptr, gst_tensor_info_get_size (&filter->in_config.info));
+    nns_memcpy (outptr, inptr,
+        gst_tensor_info_get_size (&filter->in_config.info));
     GST_WARNING_OBJECT (filter,
         "Calling tensor_transform with high memcpy overhead WITHOUT any effects! Check your stream wheter you really need tensor_transform.\n");
     return GST_FLOW_OK;
@@ -900,7 +901,7 @@ gst_tensor_transform_dimchg (GstTensorTransform * filter,
       for (j = 0; j < toDim[to]; j++) {
         uint8_t *j_destptr = destptr + loopBlockSize * j;
         for (k = 0; k < copyblocklimit; k++) {
-          memcpy (j_destptr + copyblocksize * k,
+          nns_memcpy (j_destptr + copyblocksize * k,
               srcptr + k * copyblocksize * toDim[to] + j * copyblocksize,
               copyblocksize);
         }
@@ -1033,7 +1034,7 @@ gst_tensor_transform_arithmetic (GstTensorTransform * filter,
            inidx = SK*SJ*SI*l + SJ*SI*k + SI*j + i; \
            const uint8_t *_in = inptr+inidx*typesize; \
            uint8_t *_out = outptr + outidx *typesize; \
-           memcpy(_out, _in, typesize); \
+           nns_memcpy(_out, _in, typesize); \
          }                                                      \
   } while(0);
 
@@ -1064,7 +1065,8 @@ gst_tensor_transform_transpose (GstTensorTransform * filter,
   }
 
   if (!checkdim) {
-    memcpy (outptr, inptr, gst_tensor_info_get_size (&filter->in_config.info));
+    nns_memcpy (outptr, inptr,
+        gst_tensor_info_get_size (&filter->in_config.info));
     GST_WARNING_OBJECT (filter,
         "Calling tensor_transform with high memcpy overhead WITHOUT any effects!");
     return GST_FLOW_OK;
index 30b86c6..af6c1b1 100644 (file)
@@ -49,6 +49,9 @@ BuildRequires: lcov
 # Unit Testing Uses SSAT (hhtps://github.com/myungjoo/SSAT.git)
 BuildRequires: ssat
 
+# For ORC (Oil Runtime Compiler)
+BuildRequires: orc-devel
+
 %package unittest-coverage
 Summary:       NNStreamer UnitTest Coverage Analysis Result
 %description unittest-coverage