Enable acl layout test again (#5650)
author장지섭/On-Device Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Tue, 16 Jul 2019 08:10:06 +0000 (17:10 +0900)
committer이한종/On-Device Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Tue, 16 Jul 2019 08:10:06 +0000 (17:10 +0900)
* Enable acl layout test again

This commit enables acl layout test again.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
* Apply layout for padding data of PadLayer

This commit applies layout for padding data of PadLayer.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
runtimes/neurun/backend/acl_cl/KernelGenerator.cc
scripts/standalone/test_arm_neurun_mixed.sh

index 2834ae5..a3e905e 100644 (file)
@@ -2207,15 +2207,6 @@ void KernelGenerator::visit(const model::operation::PadNode &node)
 
   auto rank = _ctx.at(pad_index).shape().dim(0);
   auto pad_base = _ctx.at(pad_index).data().base();
-  ::arm_compute::PaddingList padding_list;
-  padding_list.resize(rank);
-  for (int32_t n = 0; n < rank; ++n)
-  {
-    const int32_t *from = reinterpret_cast<const int32_t *>(pad_base) + (n * 2);
-    auto axis = acl_common::ToARMComputeAxis(rank, n).value();
-
-    padding_list[axis] = ::arm_compute::PaddingInfo{from[0], from[1]};
-  }
 
   auto input_type = _ctx.at(input_index).typeInfo();
   auto data_type = acl_common::asDataType(input_type.type());
@@ -2225,6 +2216,24 @@ void KernelGenerator::visit(const model::operation::PadNode &node)
   auto input = _tensor_builder->at(input_index).get()->handle();
   auto output = _tensor_builder->at(output_index).get()->handle();
 
+  ::arm_compute::PaddingList padding_list;
+  padding_list.resize(rank);
+  for (int32_t n = 0; n < rank; ++n)
+  {
+
+    const int32_t *from = reinterpret_cast<const int32_t *>(pad_base) + (n * 2);
+
+    auto axis = acl_common::ToARMComputeAxis(rank, n).value();
+    auto fixed_axis = axis;
+    if (input->info()->num_dimensions() == 4 &&
+        input->info()->data_layout() == ::arm_compute::DataLayout::NCHW)
+    {
+      // CWHN -> WHCN
+      const int permutation[4] = {2, 0, 1, 3};
+      fixed_axis = permutation[fixed_axis];
+    }
+    padding_list[fixed_axis] = ::arm_compute::PaddingInfo{from[0], from[1]};
+  }
   auto fn = nnfw::cpp14::make_unique<::arm_compute::CLPadLayer>();
   fn->configure(input, output, padding_list, pixel_value);
 
index 0cdc9a4..7ba9d20 100755 (executable)
@@ -24,7 +24,7 @@ unset OP_BACKEND_ALLOPS
 export OP_BACKEND_Conv2DNode=cpu
 export OP_BACKEND_MaxPool2DNode=acl_cl
 export OP_BACKEND_AvgPool2DNode=acl_neon
-export ACL_DEFAULT_LAYOUT=NCHW
+export ACL_LAYOUT=NCHW
 
 # Get the intersect of framework test list files(each backend has a lsit)
 TESTLIST_PREFIX="tests/scripts/neurun_frameworktest_list.armv7l"