throw "Unsupported";
}
+Stage StageGenerator::generate(const graph::operation::Add::Node &)
+{
+ VERBOSE(Add) << "generate CPU Add" << std::endl;
+
+ throw std::runtime_error("NYI");
+}
+
} // namespace acl_cl
} // namespace backend
} // namespace neurun
virtual Stage generate(const graph::operation::Softmax::Node &node) override;
virtual Stage generate(const graph::operation::NOP::Node &node) override;
virtual Stage generate(const graph::operation::Permute::Node &node) override;
+ virtual Stage generate(const graph::operation::Add::Node &node) override;
private:
const neurun::graph::operand::Set &_ctx;
};
}
+Stage StageGenerator::generate(const graph::operation::Add::Node &)
+{
+ VERBOSE(Add) << "generate CPU Add" << std::endl;
+
+ throw std::runtime_error("NYI");
+}
+
} // namespace neurun
} // namespace backend
} // namespace cpu
virtual Stage generate(const graph::operation::Softmax::Node &node) override;
virtual Stage generate(const graph::operation::NOP::Node &node) override;
virtual Stage generate(const graph::operation::Permute::Node &node) override;
+ virtual Stage generate(const graph::operation::Add::Node &node) override;
private:
const neurun::graph::operand::Set &_ctx;
#include "graph/operation/Softmax.h"
#include "graph/operation/NOP.h"
#include "graph/operation/Permute.h"
+#include "graph/operation/Add.h"
struct IExecutionBuilder
{
virtual Stage generate(const graph::operation::Softmax::Node &node) = 0;
virtual Stage generate(const graph::operation::NOP::Node &node) = 0;
virtual Stage generate(const graph::operation::Permute::Node &node) = 0;
+ virtual Stage generate(const graph::operation::Add::Node &node) = 0;
};
} // namespace backend
_builder.addStage(stage_gen->generate(node));
}
+void Planner::visit(const graph::operation::Add::Node &node)
+{
+ VERBOSE(Add) << "Configure Add operation" << std::endl;
+
+ // backend
+ auto backend = node.lower_info()->backend();
+
+ // Generate Stage
+ auto stage_gen = backend->stage_gen();
+ _builder.addStage(stage_gen->generate(node));
+}
+
} // namespace codegen
} // namespace neurun
virtual void visit(const graph::operation::Softmax::Node &) override;
virtual void visit(const graph::operation::NOP::Node &) override;
virtual void visit(const graph::operation::Permute::Node &) override;
+ virtual void visit(const graph::operation::Add::Node &) override;
private:
const neurun::graph::operand::Set &_ctx;
VERBOSE(LIR) << " - Output : OFM(" << node.getOutputs().at(0).value() << ")" << std::endl;
}
+void Dumper::visit(const Add::Node &node)
+{
+ VERBOSE(LIR) << "* Add" << std::endl;
+ VERBOSE(LIR) << " - Inputs : Input(" << node.getInputs().at(0).value() << ", "
+ << node.getInputs().at(1).value() << ")" << std::endl;
+ VERBOSE(LIR) << " - Output : Output(" << node.getOutputs().at(0).value() << ")" << std::endl;
+}
+
} // namespace dumper
} // namespace graph
} // namespace neurun
void visit(const graph::operation::Softmax::Node &node) override;
void visit(const graph::operation::NOP::Node &node) override;
void visit(const graph::operation::Permute::Node &node) override;
+ void visit(const graph::operation::Add::Node &node) override;
};
} // namespace dumper
--- /dev/null
+#include "Add.h"
+
+#include <cassert>
+
+#include "NodeVisitor.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+namespace Add
+{
+
+void Node::accept(NodeVisitor &&v) const { v.visit(*this); }
+
+Node::Node(const graph::operation::Node::InitParam &init_param)
+ : operation::Node{OperandConstraint::createEQ(2u)}
+{
+ assert(init_param.input_count == 2);
+ assert(init_param.output_count == 1);
+
+ // Each input should be interpreted as follows:
+ //
+ // 0 -> Lefthand side operand
+ // 1 -> Righthand side operand
+
+ setInputs({init_param.inputs[0], init_param.inputs[1]});
+ setOutputs({init_param.outputs[0]});
+}
+
+} // namespace Add
+} // namespace operation
+} // namespace graph
+} // namespace neurun
--- /dev/null
+#ifndef __NEURUN_GRAPH_OPERATION_ADD_H__
+#define __NEURUN_GRAPH_OPERATION_ADD_H__
+
+#include "graph/operation/Node.h"
+
+namespace neurun
+{
+namespace graph
+{
+namespace operation
+{
+namespace Add
+{
+
+enum Input
+{
+ LHS = 0,
+ RHS
+};
+
+struct Param
+{
+ operand::Index activation_index;
+};
+
+class Node : public graph::operation::Node
+{
+public:
+ Node(const graph::operation::Node::InitParam &init_param);
+
+public:
+ virtual void accept(NodeVisitor &&) const override;
+ virtual std::string getName() const override { return "Add"; }
+};
+
+} // namespace Add
+} // namespace operation
+} // namespace graph
+} // namespace neurun
+
+#endif // __NEURUN_GRAPH_OPERATION_ADD_H__
#include "Softmax.h"
#include "NOP.h"
#include "Permute.h"
+#include "Add.h"
namespace neurun
{
virtual void visit(const Softmax::Node &) = 0;
virtual void visit(const NOP::Node &) = 0;
virtual void visit(const Permute::Node &) = 0;
+ virtual void visit(const Add::Node &) = 0;
};
} // namespace operation