Add CL Kernel Calls for SpaceToDepth from runtime. (#3267)
authorShubham Gupta/System SW /SRI-Bangalore/Engineer/삼성전자 <shub98.gupta@samsung.com>
Wed, 24 Oct 2018 07:25:48 +0000 (12:55 +0530)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 24 Oct 2018 07:25:48 +0000 (16:25 +0900)
This patch adds CL Kernel Calls for SpaceToDepth from runtime

Signed-off-by: shubham <shub98.gupta@samsung.com>
runtimes/pure_arm_compute/src/compilation.cc

index 564fb74..1957d98 100644 (file)
@@ -38,6 +38,7 @@
 #include <arm_compute/runtime/CL/functions/CLActivationLayer.h>
 #include <arm_compute/runtime/CL/functions/CLActivationLayerEx.h>
 #include <arm_compute/runtime/CL/functions/CLScale.h>
+#include <arm_compute/runtime/CL/functions/CLSpaceToDepth.h>
 #include <arm_compute/runtime/CL/functions/CLReshapeLayer.h>
 #include <arm_compute/runtime/CL/functions/CLStridedSlice.h>
 #include <arm_compute/runtime/CL/functions/CLSoftmaxLayer.h>
@@ -3811,13 +3812,33 @@ void Planner::visit(const ::internal::tflite::op::SpaceToDepth::Node &node)
   auto stage = [param](const IAllocationContext &ctx, IExecutionBuilder &builder) {
     auto output_alloc = ctx.at(::internal::tflite::operand::Index{param.output_index});
     auto input_alloc = ctx.at(::internal::tflite::operand::Index{param.input_index});
-    auto rank = 4;
 
-    auto fn = nnfw::make_unique<SimpleSpaceToDepth>();
+    if (from_env<bool>(std::getenv("USE_SIMPLE_SPACETODEPTH")))
+    {
+      // USE CPU VERSION OF SPACETODEPTH
+      auto rank = 4;
+      auto fn = nnfw::make_unique<SimpleSpaceToDepth>();
+
+      fn->configure(input_alloc, output_alloc, param.block_size, getARMComputeAxises(rank));
+
+      builder.append("SpaceToDepth", std::move(fn));
+    }
+    else
+    {
+      if (::internal::arm_compute::isGpuMode()) // GPU
+      {
+        auto fn = nnfw::make_unique<::arm_compute::CLSpaceToDepth>();
 
-    fn->configure(input_alloc, output_alloc, param.block_size, getARMComputeAxises(rank));
-    builder.append("SpaceToDepth", std::move(fn));
+        fn->configure(CAST_CL(input_alloc), CAST_CL(output_alloc), param.block_size);
 
+        builder.append("SpaceToDepth", std::move(fn));
+      }
+      else // NEON
+      {
+        // TODO Enable NEON Support
+        throw std::runtime_error("Not supported, yet");
+      }
+    }
   };
 
   _builder.addStage(stage);