[PACL] Support TransposeConv for GPU (#4223)
author장지섭/On-Device Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Thu, 17 Jan 2019 01:06:59 +0000 (10:06 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 17 Jan 2019 01:06:59 +0000 (10:06 +0900)
This commit supports TransposeConv operation for GPU.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
runtimes/pure_arm_compute/src/compilation.cc

index a80ab16..b0da882 100644 (file)
@@ -50,6 +50,7 @@
 #include <arm_compute/runtime/CL/functions/CLArgMinMax.h>
 #include <arm_compute/runtime/CL/functions/CLCast.h>
 #include <arm_compute/runtime/CL/functions/CLConvolutionLayer.h>
+#include <arm_compute/runtime/CL/functions/CLDeconvolutionLayerEx.h>
 #include <arm_compute/runtime/CL/functions/CLDepthwiseConvolutionLayer.h>
 #include <arm_compute/runtime/CL/functions/CLDequantizationLayer.h>
 #include <arm_compute/runtime/CL/functions/CLDepthToSpace.h>
@@ -4060,16 +4061,39 @@ void Planner::visit(const ::internal::tflite::op::TransposeConv::Node &node)
     auto ifm_alloc = ctx.at(::internal::tflite::operand::Index{param.ifm_index});
     auto ker_alloc = ctx.at(::internal::tflite::operand::Index{param.ker_index});
 
-    auto fn = nnfw::cpp14::make_unique<SimpleTransposeConv>();
-
     // Only rank 4 is supported
     const int rank = 4;
 
-    auto tconv_info = asPadStrideInfo(param.padding, param.stride);
+    if (from_env<bool>(std::getenv("USE_SIMPLE_TRANSPOSECONV")))
+    {
+      auto fn = nnfw::cpp14::make_unique<SimpleTransposeConv>();
+
+      auto tconv_info = asPadStrideInfo(param.padding, param.stride);
+      fn->configure(ifm_alloc, ker_alloc, ofm_alloc, tconv_info, getARMComputeAxises(rank));
+
+      builder.append("TransposeConv", std::move(fn));
+    }
+    else if (::internal::arm_compute::isGpuMode())
+    {
+      auto fn = nnfw::cpp14::make_unique<::arm_compute::CLDeconvolutionLayerEx>();
 
-    fn->configure(ifm_alloc, ker_alloc, ofm_alloc, tconv_info, getARMComputeAxises(rank));
+      auto padding = param.padding;
+      auto inner_border_right = padding.right - padding.left;
+      auto inner_border_top = padding.bottom - padding.top;
 
-    builder.append("TransposeConv", std::move(fn));
+      padding.left = padding.right;
+      padding.top = padding.bottom;
+      auto symmetric_tconv_info = asPadStrideInfo(padding, param.stride);
+
+      // TODO Support WeightInfo in some cases in order to performance improvement
+      fn->configure(CAST_CL(ifm_alloc), CAST_CL(ker_alloc), nullptr, CAST_CL(ofm_alloc),
+                    symmetric_tconv_info, inner_border_right, inner_border_top);
+      builder.append("TransposeConv", std::move(fn));
+    }
+    else
+    {
+      throw std::runtime_error("Not supported, yet");
+    }
   };
   _builder.addStage(stage);
 }