From: Prasanna R/System SW /SRI-Bangalore/Engineer/삼성전자 Date: Wed, 14 Nov 2018 01:27:24 +0000 (+0530) Subject: Implement SQRT op in PACL (#3418) X-Git-Tag: 0.3~424 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=aed799ca35a96a79fe67fdd39df1fc2f86099fa6;p=platform%2Fcore%2Fml%2Fnnfw.git Implement SQRT op in PACL (#3418) This patch implements SQRT op in PACL. Related issue: #3341 Signed-off-by: prasannar --- diff --git a/runtimes/pure_arm_compute/src/compilation.cc b/runtimes/pure_arm_compute/src/compilation.cc index 2011efd..c42790e 100644 --- a/runtimes/pure_arm_compute/src/compilation.cc +++ b/runtimes/pure_arm_compute/src/compilation.cc @@ -3589,7 +3589,56 @@ void Planner::visit(const ::internal::tflite::op::SQRT::Node &node) { VERBOSE(SQRT) << "Configure SQRT operation" << std::endl; - throw std::runtime_error("Not supported, yet"); + const ::internal::tflite::operand::Index output_index{node.param().output_index}; + const ::internal::tflite::operand::Index input_index{node.param().input_index}; + + // Set shape constraints + _builder.addShapeConstr(output_index, + asTensorInfo(asTensorShape(_ctx.at(output_index).shape()), + _ctx.at(output_index).type(), _ctx.at(output_index).scale(), + _ctx.at(output_index).zeroPoint())); + _builder.addShapeConstr(input_index, + asTensorInfo(asTensorShape(_ctx.at(input_index).shape()), + _ctx.at(input_index).type(), _ctx.at(input_index).scale(), + _ctx.at(input_index).zeroPoint())); + + struct Param + { + int output_index; + int input_index; + }; + + Param param; + + param.output_index = output_index.asInt(); + param.input_index = input_index.asInt(); + + auto stage = [param](const IAllocationContext &ctx, IExecutionBuilder &builder) { + auto output_alloc = ctx.at(::internal::tflite::operand::Index{param.output_index}); + auto input_alloc = ctx.at(::internal::tflite::operand::Index{param.input_index}); + + const ::arm_compute::ActivationLayerInfo act_info{ + ::arm_compute::ActivationLayerInfo::ActivationFunction::SQRT}; + + if (::internal::arm_compute::isGpuMode()) + { + auto fn = nnfw::make_unique<::arm_compute::CLActivationLayer>(); + + fn->configure(CAST_CL(input_alloc), CAST_CL(output_alloc), act_info); + + builder.append("SQRT", std::move(fn)); + } + else + { + auto fn = nnfw::make_unique<::arm_compute::NEActivationLayer>(); + + fn->configure(input_alloc, output_alloc, act_info); + + builder.append("SQRT", std::move(fn)); + } + }; + + _builder.addStage(stage); } void Planner::visit(const ::internal::tflite::op::RSQRT::Node &node)