From 6602c75f0275f2a64222b2ce10ff4511634770c8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?utf8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 3 Sep 2019 17:11:22 +0900 Subject: [PATCH] Enable acl neon backend mul operation (#7105) Update acl neon backend ShapeFixer's mul Remove exception in kernel generator for mul Signed-off-by: Hyeongseok Oh --- runtimes/neurun/backend/acl_neon/KernelGenerator.cc | 6 ++---- runtimes/neurun/backend/acl_neon/ShapeFixer.cc | 14 ++++---------- tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon | 1 - 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc index 4a5b741..2862392 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc @@ -583,9 +583,6 @@ void KernelGenerator::visit(const model::operation::FullyConnectedNode &node) void KernelGenerator::visit(const model::operation::MulNode &node) { - // TODO: fix, tests are failing - throw std::runtime_error("NYI"); - const auto ofm_index{node.getOutputs().at(0)}; const auto lhs_index{node.getInputs().at(model::operation::MulNode::Input::LHS)}; const auto rhs_index{node.getInputs().at(model::operation::MulNode::Input::RHS)}; @@ -600,8 +597,9 @@ void KernelGenerator::visit(const model::operation::MulNode &node) auto l = nnfw::cpp14::make_unique<::arm_compute::NEPixelWiseMultiplication>(); + // RoundingPolicy for scale:1.0 is only allowed RoundingPolicy::TO_ZERO l->configure(lhs_alloc->handle(), rhs_alloc->handle(), ofm_alloc->handle(), 1.0, // scale - arm_compute::ConvertPolicy::SATURATE, arm_compute::RoundingPolicy::TO_NEAREST_EVEN); + arm_compute::ConvertPolicy::SATURATE, arm_compute::RoundingPolicy::TO_ZERO); fn = std::move(l); diff --git a/runtimes/neurun/backend/acl_neon/ShapeFixer.cc b/runtimes/neurun/backend/acl_neon/ShapeFixer.cc index 90753c6..7901ba0 100644 --- a/runtimes/neurun/backend/acl_neon/ShapeFixer.cc +++ b/runtimes/neurun/backend/acl_neon/ShapeFixer.cc @@ -105,17 +105,11 @@ void ShapeFixer::visit(const model::operation::MulNode &node) { const auto broadcast_rank = std::max(_ctx.at(lhs_index).shape().rank(), _ctx.at(rhs_index).shape().rank()); - auto lhs_shape = _ctx.at(lhs_index).shape(); - auto rhs_shape = _ctx.at(rhs_index).shape(); - lhs_shape.extendRank(broadcast_rank); - rhs_shape.extendRank(broadcast_rank); - } - - // Nontrivial broadcasting isn't supported yet - if (!(_ctx.at(lhs_index).shape() == _ctx.at(rhs_index).shape())) - { - throw std::runtime_error("NYI"); + // TODO remove const_cast later. For example, _ctx may need to be a non const variable or + // a node to extend shape may be inserted in front of this operation + const_cast<::neurun::model::Shape &>(_ctx.at(lhs_index).shape()).extendRank(broadcast_rank); + const_cast<::neurun::model::Shape &>(_ctx.at(rhs_index).shape()).extendRank(broadcast_rank); } } diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon index 86daa12..be5a45a 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon @@ -20,7 +20,6 @@ GeneratedTests.logistic* GeneratedTests.lsh_projection* GeneratedTests.lstm* GeneratedTests.mobilenet* -GeneratedTests.mul* GeneratedTests.neg* GeneratedTests.notequal* GeneratedTests.prelu_ex* -- 2.7.4