[newrt] Support Concat from acl_cl backend (#2010)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Thu, 19 Jul 2018 06:38:57 +0000 (15:38 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Thu, 19 Jul 2018 06:38:57 +0000 (15:38 +0900)
Enable Concat from acl_cl backend. So now we can run inception v3
with acl_cl backend only.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
runtimes/neurun/src/internal/arm_compute/StageGenerator.cc
runtimes/neurun/src/internal/kernel/acl_cl/ConcatLayer.cc
tools/test_driver/newruntime_frameworktest_list.txt

index 333a2bd..ca4c858 100644 (file)
@@ -7,6 +7,8 @@
 #include <arm_compute/runtime/CL/functions/CLFullyConnectedLayer.h>
 #include <arm_compute/runtime/CL/functions/CLSoftmaxLayer.h>
 
+#include "internal/kernel/acl_cl/ConcatLayer.h"
+
 #include "internal/Padding.h"
 #include "internal/Model.h"
 
@@ -355,11 +357,42 @@ Stage StageGenerator::generate(const ::internal::tflite::op::AvgPool2D::implicit
 
 Stage StageGenerator::generate(const ::internal::tflite::op::Concat::Node &node)
 {
-  throw std::runtime_error{"NYI - StageGenerator::generate for 'Concat'"};
+  const ::internal::tflite::operand::Index ofm_index{node.param().ofm_index};
+  const ::internal::tflite::operand::Index axis_index{node.param().axis_index};
+
+  struct Param
+  {
+    int32_t output_index;
+    std::vector<int32_t> input_indexes;
+
+    int32_t axis;
+  };
+
+  Param param;
+
+  param.output_index = node.param().ofm_index;
+  param.input_indexes = node.param().ifm_indexes;
+  param.axis = _ctx.at(axis_index).asScalar<int32_t>();
+
+  VERBOSE(Concat) << param.axis << std::endl;
 
-  return [](IExecutionBuilder &builder) {
-    // NOTE arm_compute does not have Concat operation
-    // TODO Implement
+  auto tensors = _tensor_builder;
+
+  return [tensors, param](IExecutionBuilder &builder) {
+    auto output_alloc = tensors->at(::internal::tflite::operand::Index{param.output_index}).get();
+
+    std::vector<::arm_compute::ICLTensor *> input_allocs;
+    for (auto ifm_ind : param.input_indexes)
+    {
+      input_allocs.emplace_back(tensors->at(::internal::tflite::operand::Index{ifm_ind}).get());
+    }
+
+    std::unique_ptr<::internal::kernel::acl_cl::ConcatLayer> fn{
+        new ::internal::kernel::acl_cl::ConcatLayer};
+
+    fn->configure(input_allocs, param.axis, output_alloc);
+
+    builder.append(std::move(fn));
   };
 }
 
index 2b98059..55649cc 100644 (file)
@@ -34,7 +34,7 @@ bool matchSizeExceptAxis(const ::arm_compute::ICLTensor *t1, const ::arm_compute
   {
     if (axis == i)
       continue;
-    if (t1->info()->dimension(i) == t2->info()->dimension(i))
+    if (t1->info()->dimension(i) != t2->info()->dimension(i))
       return false;
   }
   return true;