Apply CL Kernel of HashtableLookup for PACL (#3701)
author장지섭/동작제어Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Mon, 26 Nov 2018 10:55:40 +0000 (19:55 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Mon, 26 Nov 2018 10:55:40 +0000 (19:55 +0900)
This commit applies CL Kernel of HashtableLookup for PACL.

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

index 8f9cf58..3b5a110 100644 (file)
@@ -43,6 +43,7 @@
 #include <arm_compute/runtime/CL/functions/CLStridedSlice.h>
 #include <arm_compute/runtime/CL/functions/CLSoftmaxLayer.h>
 #include <arm_compute/runtime/CL/functions/CLGather.h>
+#include <arm_compute/runtime/CL/functions/CLHashtableLookup.h>
 #include <arm_compute/runtime/CL/functions/CLTopKV2.h>
 #include <arm_compute/runtime/CL/functions/CLCast.h>
 #include <arm_compute/runtime/CL/functions/CLConvolutionLayer.h>
@@ -4737,11 +4738,28 @@ void Planner::visit(const ::internal::tflite::op::HashtableLookup::Node &node)
     auto values_alloc = ctx.at(::internal::tflite::operand::Index{param.values_index});
     auto keys_alloc = ctx.at(::internal::tflite::operand::Index{param.keys_index});
 
-    auto fn = nnfw::make_unique<HashtableLookupLayer>();
+    if (from_env<bool>(std::getenv("USE_SIMPLE_HASHTABLELOOKUP")))
+    {
+      auto fn = nnfw::make_unique<HashtableLookupLayer>();
+
+      fn->configure(lookups_alloc, keys_alloc, values_alloc, output_alloc, hits_alloc);
+
+      builder.append("HashtableLookup", std::move(fn));
+    }
+    else if (::internal::arm_compute::isGpuMode()) // GPU
+    {
+      auto fn = nnfw::make_unique<::arm_compute::CLHashtableLookup>();
 
-    fn->configure(lookups_alloc, keys_alloc, values_alloc, output_alloc, hits_alloc);
+      fn->configure(CAST_CL(lookups_alloc), CAST_CL(keys_alloc), CAST_CL(values_alloc),
+                    CAST_CL(output_alloc), CAST_CL(hits_alloc));
 
-    builder.append("HashtableLookup", std::move(fn));
+      builder.append("HashtableLookup", std::move(fn));
+    }
+    else // NEON
+    {
+      // TODO Enable NEON Support
+      throw std::runtime_error("Not supported, yet");
+    }
   };
 
   _builder.addStage(stage);