void visit(const ::internal::tflite::op::Pad::Node &node) override;
void visit(const ::internal::tflite::op::SpaceToDepth::Node &node) override;
void visit(const ::internal::tflite::op::L2Pool2D::Implicit::Node &node) override;
+ void visit(const ::internal::tflite::op::EmbeddingLookup::Node &node) override;
private:
const ::internal::tflite::operand::Set &_ctx;
_builder.addStage(stage);
}
+void Planner::visit(const ::internal::tflite::op::EmbeddingLookup::Node &node)
+{
+ // TODO Implement EMBEDDING_LOOKUP
+ throw std::runtime_error("Not supported");
+}
+
class AllocationContext final : public IAllocationContext
{
public:
--- /dev/null
+#include "internal/op/EmbeddingLookup.h"
+#include "internal/op/NodeVisitor.h"
+
+#include <cassert>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace EmbeddingLookup
+{
+
+void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+} // namespace EmbeddingLookup
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace EmbeddingLookup
+{
+
+Param::Param(uint32_t inputCount, const uint32_t *inputs, uint32_t outputCount,
+ const uint32_t *outputs)
+{
+ assert(inputCount == 2 && outputCount == 1);
+
+ output_index = outputs[0];
+
+ // Each input should be interpreted as follows:
+ //
+ // 0 -> Lookups Index
+ // 1 -> Values Index
+ lookups_index = inputs[0];
+ values_index = inputs[1];
+}
+
+} // namespace EmbeddingLookup
+} // namespace op
+} // namespace tflite
+} // namespace internal
--- /dev/null
+#ifndef __INTERNAL_OP_EMBEDDING_LOOKUP_H__
+#define __INTERNAL_OP_EMBEDDING_LOOKUP_H__
+
+#include "internal/op/Node.h"
+
+#include <cstdint>
+
+namespace internal
+{
+namespace tflite
+{
+namespace op
+{
+namespace EmbeddingLookup
+{
+
+struct Param
+{
+ int32_t output_index;
+
+ int32_t lookups_index;
+ int32_t values_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 EmbeddingLookup
+} // namespace op
+} // namespace tflite
+} // namespace internal
+
+#endif // __INTERNAL_OP_EMBEDDING_LOOKUP_H__
#include "internal/op/Pad.h"
#include "internal/op/SpaceToDepth.h"
#include "internal/op/L2Pool2D.h"
+#include "internal/op/EmbeddingLookup.h"
namespace internal
{
virtual void visit(const Pad::Node &) = 0;
virtual void visit(const SpaceToDepth::Node &) = 0;
virtual void visit(const L2Pool2D::Implicit::Node &) = 0;
+ virtual void visit(const EmbeddingLookup::Node &) = 0;
};
} // namespace op
break;
}
+ case ANEURALNETWORKS_EMBEDDING_LOOKUP:
+ {
+ assert(inputCount == 2);
+ assert(outputCount == 1);
+
+ using internal::tflite::op::EmbeddingLookup::Param;
+ using internal::tflite::op::EmbeddingLookup::Node;
+
+ auto &operations = model->deref().operations();
+
+ operations.emplace_back<Node>(Param{inputCount, inputs, outputCount, outputs});
+
+ break;
+ }
default:
throw std::runtime_error{"Not supported operation"};
};