This commit introduces RNN operation into purACL.
Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
void visit(const ::internal::tflite::op::Tanh::Node &node) override;
void visit(const ::internal::tflite::op::Logistic::Node &node) override;
void visit(const ::internal::tflite::op::Mean::Node &node) override;
+ void visit(const ::internal::tflite::op::RNN::Node &node) override;
private:
const ::internal::tflite::operand::Set &_ctx;
_builder.addStage(stage);
}
+void Planner::visit(const ::internal::tflite::op::RNN::Node &node)
+{
+ // TODO Implement RNN op
+}
+
class AllocationContext final : public IAllocationContext
{
public:
#include "internal/op/Squeeze.h"
#include "internal/op/Logistic.h"
#include "internal/op/Mean.h"
+#include "internal/op/Rnn.h"
namespace internal
{
virtual void visit(const Squeeze::Node &) = 0;
virtual void visit(const Logistic::Node &) = 0;
virtual void visit(const Mean::Node &) = 0;
+ virtual void visit(const RNN::Node &) = 0;
};
} // namespace op
--- /dev/null
+#include "internal/op/Rnn.h"
+#include "internal/op/NodeVisitor.h"
+
+#include <cassert>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace RNN
+{
+
+void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+} // namespace RNN
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace RNN
+{
+
+Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
+ const uint32_t *outputs)
+{
+ assert(inputCount == 6 && outputCount == 2);
+
+ output_index = outputs[0];
+ hidden_state_out_index = inputs[4];
+
+ input_index = inputs[0];
+ weights_index = inputs[1];
+ recurrent_weights_index = inputs[2];
+ bias_index = inputs[3];
+ hidden_state_in_index = inputs[4];
+ fused_activation_index = inputs[5];
+}
+
+} // namespace RNN
+} // namespace op
+} // namespace tflite
+} // namespace internal
--- /dev/null
+#ifndef __INTERNAL_OP_RNN_H__
+#define __INTERNAL_OP_RNN_H__
+
+#include "internal/op/Node.h"
+
+#include <cstdint>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace RNN
+{
+
+struct Param
+{
+ int32_t output_index;
+ int32_t hidden_state_out_index;
+
+ int32_t input_index;
+ int32_t weights_index;
+ int32_t recurrent_weights_index;
+ int32_t bias_index;
+ int32_t hidden_state_in_index;
+ int32_t fused_activation_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 RNN
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+#endif // __INTERNAL_OP_RNN_H__
break;
}
+ case ANEURALNETWORKS_RNN:
+ {
+ using internal::tflite::op::RNN::Param;
+ using internal::tflite::op::RNN::Node;
+
+ auto &operations = model->deref().operations();
+
+ operations.emplace_back<Node>(Param{inputCount, inputs, outputCount, outputs});
+
+ break;
+ }
default:
throw std::runtime_error{"Not supported operation"};
};