21#ifndef __IR_BUILDER_H__
22#define __IR_BUILDER_H__
36 assert(_module !=
nullptr);
43 bool empty(
void)
const {
return _stack.empty(); }
50 assert(_stack.size() > 0);
51 return _stack.front();
62 _stack.push_front(op);
104 assert(_stack.size() > 0);
105 auto op = _stack.front();
111 template <
typename ConcreteOp>
OpBuilder &binary()
113 assert(_stack.size() >= 2);
127 std::deque<coco::Op *> _stack;
139 assert(_module !=
nullptr);
coco::Copy * copy(coco::Object *into, coco::Object *from) const
Create "Copy" instruction with given two "Object".
InstrBuilder(coco::Module *module)
coco::Eval * eval(coco::Object *out, coco::Op *op) const
Create "Eval" instruction with a given "Object" and "Op".
OpBuilder & load(coco::Object *obj)
Create "Load" op and push it onto the internal stack.
coco::Op * top(void) const
Return the operation at the top of the internal stack.
OpBuilder & mul(void)
Create "Mul" op and push it onto the internal stack.
OpBuilder & push(coco::Op *op)
Push op onto the internal stack.
coco::Op * pop(void)
Pop op from the internal stack.
OpBuilder & add(void)
Create "Add" op and push it onto the internal stack.
OpBuilder(coco::Module *module)
bool empty(void) const
Return true if the internal stack is empty.
Index-wise element transfer between two objects.
Object * from(void) const
Evaluate an Object from a given Op.
Top-level element of coco IR which represents a neural network.
virtual EntityManager * entity(void)=0
Base interface on all typed NN values.
virtual OpManager * op(void)=0
virtual InstrManager * instr(void)=0
Base interface on all supported NN operations.
std::unique_ptr< coco::Module > ModuleHandle
OpBuilder op_builder(coco::Module *m)
InstrBuilder instr_builder(coco::Module *m)