From 9c90fe72362085f235aac75484d3f98a9de158be Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=82=A8=EA=B6=81=EC=84=9D/=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: Thu, 5 Jul 2018 12:17:39 +0900 Subject: [PATCH] Definitions for supporting Tanh in pureacl runtime (#1846) Define namespace, node, param for Tanh Signed-off-by: seok --- runtimes/pure_arm_compute/src/compilation.cc | 8 ++++ .../pure_arm_compute/src/internal/op/NodeVisitor.h | 2 + runtimes/pure_arm_compute/src/internal/op/Tanh.cc | 47 +++++++++++++++++++ runtimes/pure_arm_compute/src/internal/op/Tanh.h | 53 ++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 runtimes/pure_arm_compute/src/internal/op/Tanh.cc create mode 100644 runtimes/pure_arm_compute/src/internal/op/Tanh.h diff --git a/runtimes/pure_arm_compute/src/compilation.cc b/runtimes/pure_arm_compute/src/compilation.cc index 2775595..8c0689b 100644 --- a/runtimes/pure_arm_compute/src/compilation.cc +++ b/runtimes/pure_arm_compute/src/compilation.cc @@ -344,6 +344,7 @@ public: void visit(const ::internal::tflite::op::ReLU::Node &node) override; void visit(const ::internal::tflite::op::ReLU1::Node &node) override; void visit(const ::internal::tflite::op::ReLU6::Node &node) override; + void visit(const ::internal::tflite::op::Tanh::Node &node) override; private: const ::internal::tflite::operand::Set &_ctx; @@ -2101,6 +2102,13 @@ void Planner::visit(const ::internal::tflite::op::ReLU6::Node &node) _builder.addStage(stage); } +void Planner::visit(const ::internal::tflite::op::Tanh::Node &node) +{ + VERBOSE(Tanh) << "Configure Tanh operation" << std::endl; + + throw std::runtime_error{"Not supported operation"}; +} + class AllocationContext final : public IAllocationContext { public: diff --git a/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h b/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h index c99e592..68cf28d 100644 --- a/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h +++ b/runtimes/pure_arm_compute/src/internal/op/NodeVisitor.h @@ -23,6 +23,7 @@ #include "internal/op/ReLU.h" #include "internal/op/ReLU1.h" #include "internal/op/ReLU6.h" +#include "internal/op/Tanh.h" namespace internal { @@ -57,6 +58,7 @@ struct NodeVisitor virtual void visit(const ReLU::Node &) = 0; virtual void visit(const ReLU1::Node &) = 0; virtual void visit(const ReLU6::Node &) = 0; + virtual void visit(const Tanh::Node &) = 0; }; } // namespace op diff --git a/runtimes/pure_arm_compute/src/internal/op/Tanh.cc b/runtimes/pure_arm_compute/src/internal/op/Tanh.cc new file mode 100644 index 0000000..43874ce --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Tanh.cc @@ -0,0 +1,47 @@ +#include "internal/op/Tanh.h" +#include "internal/op/NodeVisitor.h" + +#include + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Tanh +{ + +void Node::accept(NodeVisitor &&v) const { v.visit(*this); } + +} // namespace Tanh +} // namespace op +} // namespace tflite +} // namespace internal + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Tanh +{ + +Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, + const uint32_t *outputs) +{ + assert(inputCount == 1 && outputCount == 1); + + ofm_index = outputs[0]; + + // Each input should be interpreted as follows: + // + // 0 -> Input Tensor Index + ifm_index = inputs[0]; +} + +} // namespace Tanh +} // namespace op +} // namespace tflite +} // namespace internal diff --git a/runtimes/pure_arm_compute/src/internal/op/Tanh.h b/runtimes/pure_arm_compute/src/internal/op/Tanh.h new file mode 100644 index 0000000..0342201 --- /dev/null +++ b/runtimes/pure_arm_compute/src/internal/op/Tanh.h @@ -0,0 +1,53 @@ +#ifndef __INTERNAL_OP_TANH_H__ +#define __INTERNAL_OP_TANH_H__ + +#include "internal/op/Node.h" + +#include + +namespace internal +{ +namespace tflite +{ +namespace op +{ +namespace Tanh +{ + +struct Param +{ + int32_t ofm_index; + + int32_t ifm_index; + + Param() = default; + Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount, const uint32_t *outputs); +}; + +class Node final : public op::Node +{ +public: + Node(const Param ¶m) : _param(param) + { + // DO NOTHING + } + +public: + virtual ~Node() = default; + +public: + const Param ¶m(void) const { return _param; } + +public: + void accept(NodeVisitor &&) const override; + +private: + const Param _param; +}; + +} // namespace Tanh +} // namespace op +} // namespace tflite +} // namespace internal + +#endif // __INTERNAL_OP_TANH_H__ -- 2.7.4