From 4c60b91490e144a7a43468e8421eb25e79e7b4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=98=A4=ED=98=95=EC=84=9D/On-Device=20Lab=28SR=29/Staff?= =?UTF-8?q?=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Tue, 3 Sep 2019 17:11:22 +0900 Subject: Enable acl neon backend mul operation (#7105) Update acl neon backend ShapeFixer's mul Remove exception in kernel generator for mul Change-Id: I3a104694e3ded74b1ac9a5cea013e65a47f0476d Signed-off-by: Hyeongseok Oh Signed-off-by: Chunseok Lee --- 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 9da0139ce..9e86783a7 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc @@ -598,9 +598,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)}; @@ -615,8 +612,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 90753c648..7901ba0c3 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 86daa1285..be5a45a17 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* -- cgit v1.2.3