This commit supports Cast operation for pureACL.
- support adding Cast operation via API related to model.
- The plan of Cast operation is not yet implemented.
Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
void visit(const ::internal::tflite::op::Softmax::Node &node) override;
void visit(const ::internal::tflite::op::StridedSlice::Node &node) override;
void visit(const ::internal::tflite::op::ReduceMax::Node &node) override;
+ void visit(const ::internal::tflite::op::Cast::Node &node) override;
void visit(const ::internal::tflite::op::TopKV2::Node &node) override;
void visit(const ::internal::tflite::op::Gather::Node &node) override;
throw std::runtime_error{"ReduceMax: Not supported operation"};
}
+void Planner::visit(const ::internal::tflite::op::Cast::Node &node)
+{
+ // TODO Implement the plan of Cast
+}
+
void Planner::visit(const ::internal::tflite::op::TopKV2::Node &node)
{
const ::internal::tflite::operand::Index outputValues_index{node.param().outputValues_index};
--- /dev/null
+#include "internal/op/Cast.h"
+#include "internal/op/NodeVisitor.h"
+
+#include <cassert>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace Cast
+{
+
+void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+} // namespace Cast
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace Cast
+{
+
+Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
+ const uint32_t *outputs)
+{
+ assert(inputCount == 1 && outputCount == 1);
+
+ output_index = outputs[0];
+
+ // Each input should be interpreted as follows:
+ // 0 -> input Tensor Index
+ input_index = inputs[0];
+}
+
+} // namespace Cast
+} // namespace op
+} // namespace tflite
+} // namespace internal
--- /dev/null
+#ifndef __INTERNAL_OP_CAST_H__
+#define __INTERNAL_OP_CAST_H__
+
+#include "internal/op/Node.h"
+
+#include <cstdint>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace Cast
+{
+
+struct Param
+{
+ int32_t output_index;
+
+ int32_t input_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 Cast
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+#endif // __INTERNAL_OP_Cast_H__
#include "internal/op/FullyConnected.h"
#include "internal/op/Softmax.h"
#include "internal/op/ReduceMax.h"
+#include "internal/op/Cast.h"
#include "internal/op/TopKV2.h"
#include "internal/op/Gather.h"
virtual void visit(const FullyConnected::Node &) = 0;
virtual void visit(const Softmax::Node &) = 0;
virtual void visit(const ReduceMax::Node &) = 0;
+ virtual void visit(const Cast::Node &) = 0;
virtual void visit(const TopKV2::Node &) = 0;
virtual void visit(const Gather::Node &) = 0;
};
{
switch (type)
{
+ case ANEURALNETWORKS_CAST_EX:
+ {
+ using internal::tflite::op::Cast::Param;
+ using internal::tflite::op::Cast::Node;
+
+ // Add 'operations'
+ auto &operations = model->deref().operations();
+
+ operations.emplace_back<Node>(Param{inputCount, inputs, outputCount, outputs});
+
+ break;
+ }
case ANEURALNETWORKS_TENSORFLOW_MAX_EX:
{
using internal::tflite::op::ReduceMax::Param;