#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace Implicit
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
void Node::inputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override { return {_op->param().ifm_index}; }
virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
virtual void inputs(const operand::IndexSet &indexes) override;
#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace Concat
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
operand::IndexSet Node::inputs() const
{
operand::IndexSet set;
Node(std::unique_ptr<::internal::tflite::op::Concat::Node> &&op) : _op{std::move(op)} {}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override;
virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
virtual void inputs(const operand::IndexSet &indexes) override;
#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace Implicit
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
void Node::inputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
Node(std::unique_ptr<::internal::tflite::op::Conv2D::implicit::Node> &&op) : _op{std::move(op)} {}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override
{
return {_op->param().ifm_index, _op->param().ker_index, _op->param().bias_index};
#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace FullyConnected
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
void Node::inputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
Node(std::unique_ptr<::internal::tflite::op::FullyConnected::Node> &&op) : _op{std::move(op)} {}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override
{
return {_op->param().input_index, _op->param().weight_index, _op->param().bias_index};
#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace Implicit
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
void Node::inputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override { return {_op->param().ifm_index}; }
virtual operand::IndexSet outputs() const override { return {_op->param().ofm_index}; }
virtual void inputs(const operand::IndexSet &indexes) override;
#include "NOP.h"
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace NOP
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
operand::IndexSet Node::inputs() const
{
operand::IndexSet set;
Node(std::unique_ptr<::internal::tflite::op::NOP::Node> &&op) : _op{std::move(op)} {}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override;
virtual operand::IndexSet outputs() const override;
virtual void inputs(const operand::IndexSet &indexes) override;
--- /dev/null
+#include "Node.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+// NO IMPLEMENTATION YET
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
{
class LowerInfo;
+struct NodeVisitor;
class Node
{
virtual ~Node() = default;
public:
+ virtual void accept(NodeVisitor &) const = 0;
+
+public:
virtual operand::IndexSet inputs() const = 0;
virtual operand::IndexSet outputs() const = 0;
// It's for only input/output tensors but const data.
--- /dev/null
+#ifndef __NEURUN_GRAPH_OPERATION_NODE_VISITOR_H__
+#define __NEURUN_GRAPH_OPERATION_NODE_VISITOR_H__
+
+#include "Conv2D.h"
+#include "MaxPool2D.h"
+#include "AvgPool2D.h"
+#include "Concat.h"
+#include "Reshape.h"
+#include "FullyConnected.h"
+#include "Softmax.h"
+#include "NOP.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+
+struct NodeVisitor
+{
+ virtual ~NodeVisitor() = default;
+
+ virtual void visit(const Conv2D::Implicit::Node &) = 0;
+ virtual void visit(const MaxPool2D::Implicit::Node &) = 0;
+ virtual void visit(const AvgPool2D::Implicit::Node &) = 0;
+ virtual void visit(const Concat::Node &) = 0;
+ virtual void visit(const Reshape::Node &) = 0;
+ virtual void visit(const FullyConnected::Node &) = 0;
+ virtual void visit(const Softmax::Node &) = 0;
+ virtual void visit(const NOP::Node &) = 0;
+};
+
+} // namespace operation
+} // namespace graph
+} // namespace neurun
+
+#endif // __NEURUN_GRAPH_OPERATION_NODE_VISITOR_H__
#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace Reshape
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
void Node::inputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
Node(std::unique_ptr<::internal::tflite::op::Reshape::Node> &&op) : _op{std::move(op)} {}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override
{
return {_op->param().input_index, _op->param().shape_index};
#include <cassert>
+#include "NodeVisitor.h"
+
namespace neurun
{
namespace graph
namespace Softmax
{
+void Node::accept(NodeVisitor &v) const { v.visit(*this); }
+
void Node::inputs(const operand::IndexSet &indexes)
{
assert(indexes.size() == 1);
Node(std::unique_ptr<::internal::tflite::op::Softmax::Node> &&op) : _op{std::move(op)} {}
public:
+ virtual void accept(NodeVisitor &) const override;
+
+public:
virtual operand::IndexSet inputs() const override { return {_op->param().input_index}; }
virtual operand::IndexSet outputs() const override { return {_op->param().output_index}; }
virtual void inputs(const operand::IndexSet &indexes) override;
TestNode() = default;
public:
+ virtual void accept(neurun::graph::operation::NodeVisitor &) const override {}
+
+public:
virtual neurun::graph::operand::IndexSet inputs() const { return {1, 2, 3, 4}; }
virtual neurun::graph::operand::IndexSet outputs() const { return {1, 2, 3}; }
virtual void inputs(const neurun::graph::operand::IndexSet &indexes) override {}
}
public:
+ virtual void accept(neurun::graph::operation::NodeVisitor &) const override {}
+
+public:
virtual neurun::graph::operand::IndexSet inputs() const override { return {_input}; }
virtual neurun::graph::operand::IndexSet outputs() const override { return {_output}; }
virtual void inputs(const neurun::graph::operand::IndexSet &indexes) override {}