From 2ba1235cad86432f61deb3bddd46b40e7b163c31 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Thu, 19 Jul 2018 15:38:57 +0900 Subject: [PATCH] [newrt] Support Concat from acl_cl backend (#2010) Enable Concat from acl_cl backend. So now we can run inception v3 with acl_cl backend only. Signed-off-by: Hanjoung Lee --- .../src/internal/arm_compute/StageGenerator.cc | 41 +++++++++++++++++++--- .../src/internal/kernel/acl_cl/ConcatLayer.cc | 2 +- .../test_driver/newruntime_frameworktest_list.txt | 1 + 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/runtimes/neurun/src/internal/arm_compute/StageGenerator.cc b/runtimes/neurun/src/internal/arm_compute/StageGenerator.cc index 333a2bd..ca4c858 100644 --- a/runtimes/neurun/src/internal/arm_compute/StageGenerator.cc +++ b/runtimes/neurun/src/internal/arm_compute/StageGenerator.cc @@ -7,6 +7,8 @@ #include #include +#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 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(); + + 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)); }; } diff --git a/runtimes/neurun/src/internal/kernel/acl_cl/ConcatLayer.cc b/runtimes/neurun/src/internal/kernel/acl_cl/ConcatLayer.cc index 2b98059..55649cc 100644 --- a/runtimes/neurun/src/internal/kernel/acl_cl/ConcatLayer.cc +++ b/runtimes/neurun/src/internal/kernel/acl_cl/ConcatLayer.cc @@ -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; diff --git a/tools/test_driver/newruntime_frameworktest_list.txt b/tools/test_driver/newruntime_frameworktest_list.txt index 80c8173..a5f612b 100644 --- a/tools/test_driver/newruntime_frameworktest_list.txt +++ b/tools/test_driver/newruntime_frameworktest_list.txt @@ -5,3 +5,4 @@ convolution2 maxpool1 maxpool2 softmax +inception -- 2.7.4