From 10217cf843f83003d9b18bed1a6dce09e52ae5fd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9C=A4=EC=A7=80=EC=98=81/=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: Tue, 21 Aug 2018 16:28:09 +0900 Subject: [PATCH] Set parameter for Floor operation in pureACL (#2383) This commit supports Floor operation for the GPU mode by using OpenCL in acl. It sets appropriate parameters and invoke the acl floor function. Signed-off-by: Jiyoung Yun --- runtimes/pure_arm_compute/src/compilation.cc | 41 ++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/runtimes/pure_arm_compute/src/compilation.cc b/runtimes/pure_arm_compute/src/compilation.cc index 0f714e6..39976f1 100644 --- a/runtimes/pure_arm_compute/src/compilation.cc +++ b/runtimes/pure_arm_compute/src/compilation.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -3009,8 +3010,44 @@ void Planner::visit(const ::internal::tflite::op::RNN::Node &node) void Planner::visit(const ::internal::tflite::op::Floor::Node &node) { VERBOSE(Floor) << "Configure Floor operation" << std::endl; - // TODO Implement Floor op - throw std::runtime_error{"Not supported operation"}; + + const ::internal::tflite::operand::Index ofm_index{node.param().output_index}; + const ::internal::tflite::operand::Index ifm_index{node.param().input_index}; + + // Set shape constraints + _builder.addShapeConstr(ofm_index, + asTensorInfo(_ctx.at(ofm_index).shape(), _ctx.at(ofm_index).type())); + _builder.addShapeConstr(ifm_index, + asTensorInfo(_ctx.at(ifm_index).shape(), _ctx.at(ifm_index).type())); + + struct Param + { + int ofm_index; + int ifm_index; + }; + + Param param; + + param.ofm_index = ofm_index.asInt(); + param.ifm_index = ifm_index.asInt(); + + auto stage = [param](const IAllocationContext &ctx, IExecutionBuilder &builder) { + auto ofm_alloc = ctx.at(::internal::tflite::operand::Index{param.ofm_index}); + auto ifm_alloc = ctx.at(::internal::tflite::operand::Index{param.ifm_index}); + + if (::internal::arm_compute::isGpuMode()) + { + auto fn = nnfw::make_unique<::arm_compute::CLFloor>(); + + fn->configure(CAST_CL(ifm_alloc), CAST_CL(ofm_alloc)); + + builder.append("Floor", std::move(fn)); + } + else + throw std::runtime_error("Not supported, yet"); + }; + + _builder.addStage(stage); } class AllocationContext final : public IAllocationContext -- 2.7.4