Apply CL Kernel of SpaceToBatchND to PACL (#3731)
author장지섭/동작제어Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Wed, 28 Nov 2018 01:04:11 +0000 (10:04 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Wed, 28 Nov 2018 01:04:11 +0000 (10:04 +0900)
This commit applies CL Kernel of SpaceToBatchND to PACL.

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

index dfa04c4..579f569 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/CLSpaceToBatchND.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>
@@ -4216,12 +4217,28 @@ void Planner::visit(const ::internal::tflite::op::SpaceToBatchND::Node &node)
     auto block_size_alloc = ctx.at(::internal::tflite::operand::Index{param.block_size_index});
     auto padding_size_alloc = ctx.at(::internal::tflite::operand::Index{param.padding_size_index});
 
-    auto fn = nnfw::make_unique<SimpleSpaceToBatchND>();
+    // NOTE SimpleSpaceToBatchND is quite slow
+    if (from_env<bool>(std::getenv("USE_SIMPLE_SPACE_TO_BATCH_ND")))
+    {
+      auto fn = nnfw::make_unique<SimpleSpaceToBatchND>();
 
-    fn->configure(input_alloc, block_size_alloc, padding_size_alloc, output_alloc,
-                  getARMComputeAxises(param.rank));
-    builder.append("SpaceToBatchND", std::move(fn));
+      fn->configure(input_alloc, block_size_alloc, padding_size_alloc, output_alloc,
+                    getARMComputeAxises(param.rank));
+      builder.append("SpaceToBatchND", std::move(fn));
+    }
+    else if (::internal::arm_compute::isGpuMode())
+    {
+      auto fn = nnfw::make_unique<::arm_compute::CLSpaceToBatchND>();
 
+      fn->configure(CAST_CL(input_alloc), CAST_CL(block_size_alloc), CAST_CL(padding_size_alloc),
+                    CAST_CL(output_alloc));
+      builder.append("SpaceToBatchND", std::move(fn));
+    }
+    else
+    {
+      // TODO Enable NEON Support
+      throw std::runtime_error("Not supported, yet");
+    }
   };
 
   _builder.addStage(stage);