Move unused code for Conv2D (#677)
author박세희/동작제어Lab(SR)/Principal Engineer/삼성전자 <saehie.park@samsung.com>
Mon, 16 Apr 2018 00:15:46 +0000 (09:15 +0900)
committer김정현/동작제어Lab(SR)/Senior Engineer/삼성전자 <jh0822.kim@samsung.com>
Mon, 16 Apr 2018 00:15:46 +0000 (09:15 +0900)
This will remove and move unused code from Conv2D using ACL kernel

Signed-off-by: SaeHie Park <saehie.park@samsung.com>
src/kernel/acl/src/cl/Conv2D.cpp
src/kernel/acl/src/cl/Conv2D.test.cpp
src/kernel/acl/src/util.cpp
src/kernel/acl/src/util.h

index 2af174e..0d07d27 100644 (file)
@@ -17,36 +17,6 @@ namespace nnfw {
 namespace kernel {
 namespace acl {
 
-// TODO move to separate file
-uint32_t getNumItems(const android::nn::Shape& shape)
-{
-  uint32_t items = 1;
-  for (uint32_t d = 0; d < shape.dimensions.size(); d++) {
-    items *= android::nn::getSizeOfDimension(shape, d);
-  }
-  return items;
-}
-
-void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape)
-{
-  uint32_t N = android::nn::getSizeOfDimension(shape, 0);
-  uint32_t H = android::nn::getSizeOfDimension(shape, 1);
-  uint32_t W = android::nn::getSizeOfDimension(shape, 2);
-  uint32_t C = android::nn::getSizeOfDimension(shape, 3);
-
-  for (uint32_t n = 0; n < N; n++) {
-    for (uint32_t c = 0; c < C; c++) {
-      for (uint32_t h = 0; h < H; h++) {
-        for (uint32_t w = 0; w < W; w++) {
-          uint32_t soffset = w + (h * W) + (c * W * H) + (n * W * H * C);
-          uint32_t doffset = c + (w * C) + (h * C * W) + (n * C * W * H);
-          *(nhwc + doffset) = *(nchw + soffset);
-        }
-      }
-    }
-  }
-}
-
 class Flag
 {
 public:
index 0bd912c..f0d1dd3 100644 (file)
@@ -6,17 +6,6 @@
 // TODO: fix include path in CMakeFiles
 #include "../util.h"
 
-namespace nnfw {
-namespace kernel {
-namespace acl {
-
-// TODO move to separate header
-void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape);
-
-} // namespace acl
-} // namespace kernel
-} // namespace nnfw
-
 using namespace nnfw::kernel::acl;
 
 TEST(KernelACL_TC, convFloat32_3x3to1x1)
@@ -191,7 +180,7 @@ TEST(KernelACL_TC, convFloat32_3x5to3x3)
     73.0f, 115.0f, 127.0f, 139.0f, 97.0f
   };
   float expectData[30];
-  NCHW2NHWC(expectNCHW, expectData, outputShape);
+  util::NCHW2NHWC(expectNCHW, expectData, outputShape);
   bret = util::compareData(outputData, expectData, outputShape);
   EXPECT_EQ(bret, true);
 }
@@ -368,7 +357,7 @@ TEST(KernelACL_TC, neon_convFloat32_3x5to3x3)
     73.0f, 115.0f, 127.0f, 139.0f, 97.0f
   };
   float expectData[30];
-  NCHW2NHWC(expectNCHW, expectData, outputShape);
+  util::NCHW2NHWC(expectNCHW, expectData, outputShape);
   bret = util::compareData(outputData, expectData, outputShape);
   EXPECT_EQ(bret, true);
 }
index 35dc6b2..90f4327 100644 (file)
@@ -44,6 +44,26 @@ bool compareData(const float* result, const float* expected, const android::nn::
   return true;
 }
 
+void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape)
+{
+  uint32_t N = android::nn::getSizeOfDimension(shape, 0);
+  uint32_t H = android::nn::getSizeOfDimension(shape, 1);
+  uint32_t W = android::nn::getSizeOfDimension(shape, 2);
+  uint32_t C = android::nn::getSizeOfDimension(shape, 3);
+
+  for (uint32_t n = 0; n < N; n++) {
+    for (uint32_t c = 0; c < C; c++) {
+      for (uint32_t h = 0; h < H; h++) {
+        for (uint32_t w = 0; w < W; w++) {
+          uint32_t soffset = w + (h * W) + (c * W * H) + (n * W * H * C);
+          uint32_t doffset = c + (w * C) + (h * C * W) + (n * C * W * H);
+          *(nhwc + doffset) = *(nchw + soffset);
+        }
+      }
+    }
+  }
+}
+
 } // namespace util
 } // namespace acl
 } // namespace kernel
index 64253b0..33f3a9d 100644 (file)
@@ -167,6 +167,8 @@ void initData(float* data, int num, float value);
 bool compareData(const float* result, const float* expected, const android::nn::Shape& shape);
 void initData_Increasing(float* data, int num, float value);
 
+void NCHW2NHWC(const float* nchw, float* nhwc, const android::nn::Shape& shape);
+
 } // namespace util
 } // namespace acl
 } // namespace kernel