From 440892ead2cd68e2593606e0eb4b23cc37a9c720 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9E=A5=EC=A7=80=EC=84=AD/On-Device=20Lab=28SR=29/Enginee?= =?utf8?q?r/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Mon, 2 Sep 2019 17:25:52 +0900 Subject: [PATCH] Enable Floor op for ACL neon (#7100) This commit enables to support Floor op for ACL neon. Signed-off-by: jiseob.jang --- .../neurun/backend/acl_neon/KernelGenerator.cc | 22 ++++++++++++++++++++++ runtimes/neurun/backend/acl_neon/KernelGenerator.h | 1 + runtimes/neurun/backend/acl_neon/ShapeFixer.cc | 2 ++ runtimes/neurun/backend/acl_neon/ShapeFixer.h | 1 + .../neurun/core/src/compiler/OperationValidator.cc | 12 ++++++++++++ .../neurun/core/src/compiler/OperationValidator.h | 1 + tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon | 1 - 7 files changed, 39 insertions(+), 1 deletion(-) diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc index d2cd2e5..9da0139 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.cc +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -508,6 +509,27 @@ void KernelGenerator::visit(const model::operation::ConcatNode &node) _execution_builder->append(std::move(acl_fn)); } +void KernelGenerator::visit(const model::operation::FloorNode &node) +{ + const auto ofm_index{node.getOutputs().at(0)}; + const auto ifm_index{node.getInputs().at(model::operation::FloorNode::Input::INPUT)}; + + auto ofm_alloc = _tensor_builder->at(ofm_index).get(); + auto ifm_alloc = _tensor_builder->at(ifm_index).get(); + + std::unique_ptr<::arm_compute::IFunction> fn; + + auto l = nnfw::cpp14::make_unique<::arm_compute::NEFloor>(); + + l->configure(ifm_alloc->handle(), ofm_alloc->handle()); + + fn = std::move(l); + + auto acl_fn = asAclFunction(std::move(fn)); + + _execution_builder->append(std::move(acl_fn)); +} + void KernelGenerator::visit(const model::operation::FullyConnectedNode &node) { using model::operation::FullyConnectedNode; diff --git a/runtimes/neurun/backend/acl_neon/KernelGenerator.h b/runtimes/neurun/backend/acl_neon/KernelGenerator.h index 32d32a1..984f2a6 100644 --- a/runtimes/neurun/backend/acl_neon/KernelGenerator.h +++ b/runtimes/neurun/backend/acl_neon/KernelGenerator.h @@ -43,6 +43,7 @@ public: void visit(const model::operation::MeanNode &) override; void visit(const model::operation::AvgPool2DNode &) override; void visit(const model::operation::ConcatNode &) override; + void visit(const model::operation::FloorNode &) override; void visit(const model::operation::FullyConnectedNode &) override; void visit(const model::operation::MulNode &) override; void visit(const model::operation::ReLUNode &) override; diff --git a/runtimes/neurun/backend/acl_neon/ShapeFixer.cc b/runtimes/neurun/backend/acl_neon/ShapeFixer.cc index 96a3520..90753c6 100644 --- a/runtimes/neurun/backend/acl_neon/ShapeFixer.cc +++ b/runtimes/neurun/backend/acl_neon/ShapeFixer.cc @@ -81,6 +81,8 @@ void ShapeFixer::visit(const model::operation::ConcatNode &node) void ShapeFixer::visit(const model::operation::ExpNode &) { /* DO NOTHING */} +void ShapeFixer::visit(const model::operation::FloorNode &) { /* DO NOTHING */} + void ShapeFixer::visit(const model::operation::FullyConnectedNode &node) { using model::operation::FullyConnectedNode; diff --git a/runtimes/neurun/backend/acl_neon/ShapeFixer.h b/runtimes/neurun/backend/acl_neon/ShapeFixer.h index 336179c..4cd8fc4 100644 --- a/runtimes/neurun/backend/acl_neon/ShapeFixer.h +++ b/runtimes/neurun/backend/acl_neon/ShapeFixer.h @@ -45,6 +45,7 @@ public: void visit(const model::operation::AvgPool2DNode &) override; void visit(const model::operation::ConcatNode &) override; void visit(const model::operation::ExpNode &) override; + void visit(const model::operation::FloorNode &) override; void visit(const model::operation::FullyConnectedNode &) override; void visit(const model::operation::MulNode &) override; void visit(const model::operation::ReLUNode &) override; diff --git a/runtimes/neurun/core/src/compiler/OperationValidator.cc b/runtimes/neurun/core/src/compiler/OperationValidator.cc index 2677157..0be6809 100644 --- a/runtimes/neurun/core/src/compiler/OperationValidator.cc +++ b/runtimes/neurun/core/src/compiler/OperationValidator.cc @@ -350,6 +350,18 @@ void OperationValidator::visit(const model::operation::ExpNode &node) assert(_ctx.at(output_index).typeInfo().type() == _ctx.at(input_index).typeInfo().type()); } +void OperationValidator::visit(const model::operation::FloorNode &node) +{ + const auto output_index{node.getOutputs().at(0)}; + const auto input_index{node.getInputs().at(model::operation::FloorNode::Input::INPUT)}; + + UNUSED_RELEASE(output_index); + UNUSED_RELEASE(input_index); + + assert(_ctx.at(output_index).shape() == _ctx.at(input_index).shape()); + assert(_ctx.at(output_index).typeInfo().type() == _ctx.at(input_index).typeInfo().type()); +} + void OperationValidator::visit(const model::operation::HashtableLookupNode &node) { const auto output_index{ diff --git a/runtimes/neurun/core/src/compiler/OperationValidator.h b/runtimes/neurun/core/src/compiler/OperationValidator.h index f9a96a3..76774da 100644 --- a/runtimes/neurun/core/src/compiler/OperationValidator.h +++ b/runtimes/neurun/core/src/compiler/OperationValidator.h @@ -54,6 +54,7 @@ public: void visit(const model::operation::SpaceToDepthNode &node) override; void visit(const model::operation::EmbeddingLookupNode &node) override; void visit(const model::operation::ExpNode &node) override; + void visit(const model::operation::FloorNode &node) override; void visit(const model::operation::HashtableLookupNode &node) override; void visit(const model::operation::TransposeConvNode &node) override; void visit(const model::operation::GatherNode &node) override; diff --git a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon index 143108e..86daa12 100644 --- a/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon +++ b/tests/nnapi/nnapi_gtest.skip.armv7l-linux.acl_neon @@ -9,7 +9,6 @@ GeneratedTests.dequantize GeneratedTests.embedding_lookup GeneratedTests.embedding_lookup_2d_nnfw GeneratedTests.embedding_lookup_4d_nnfw -GeneratedTests.floor_ GeneratedTests.greater_equal_ex* GeneratedTests.hashtable_lookup* GeneratedTests.l2_normalization* -- 2.7.4