ONE - On-device Neural Engine
Loading...
Searching...
No Matches
OpBuilder Class Reference

#include <IRBuilder.h>

Public Member Functions

 OpBuilder (coco::Module *module)
 
bool empty (void) const
 Return true if the internal stack is empty.
 
coco::Optop (void) const
 Return the operation at the top of the internal stack.
 
OpBuilderpush (coco::Op *op)
 Push op onto the internal stack.
 
OpBuilderload (coco::Object *obj)
 Create "Load" op and push it onto the internal stack.
 
OpBuilderadd (void)
 Create "Add" op and push it onto the internal stack.
 
OpBuildersub (void)
 Create "Sub" op and push it onto the internal stack.
 
OpBuildermul (void)
 Create "Mul" op and push it onto the internal stack.
 
OpBuilderdiv (void)
 Create "Div" op and push it onto the internal stack.
 
coco::Oppop (void)
 Pop op from the internal stack.
 
 OpBuilder (coco::Module *module)
 
bool empty (void) const
 Return true if the internal stack is empty.
 
coco::Optop (void) const
 Return the operation at the top of the internal stack.
 
OpBuilderpush (coco::Op *op)
 Push op onto the internal stack.
 
OpBuilderload (coco::Object *obj)
 Create "Load" op and push it onto the internal stack.
 
OpBuilderadd (void)
 Create "Add" op and push it onto the internal stack.
 
OpBuildermul (void)
 Create "Mul" op and push it onto the internal stack.
 
coco::Oppop (void)
 Pop op from the internal stack.
 

Detailed Description

coco IR builders

Definition at line 28 of file IRBuilder.h.

Constructor & Destructor Documentation

◆ OpBuilder() [1/2]

OpBuilder::OpBuilder ( coco::Module module)
inline

Definition at line 31 of file IRBuilder.h.

31 : _module{module}
32 {
33 // module SHOULD BE valid
34 assert(_module != nullptr);
35 }

◆ OpBuilder() [2/2]

OpBuilder::OpBuilder ( coco::Module module)
inline

Definition at line 33 of file IRBuilder.h.

33 : _module{module}
34 {
35 // module SHOULD BE valid
36 assert(_module != nullptr);
37 }

Member Function Documentation

◆ add() [1/2]

OpBuilder & OpBuilder::add ( void  )
inline

Create "Add" op and push it onto the internal stack.

BEFORE| Left; Right; Stack AFTER | Add(Left, Right); Stack

Definition at line 84 of file IRBuilder.h.

84{ return binary<coco::Add>(); }

Referenced by caffeimport::BatchNormBuilder::build(), caffeimport::ConvolutionBuilder::build(), caffeimport::EltwiseBuilder::build(), caffeimport::ScaleBuilder::build(), tflimport::Conv2DGraphBuilder::build(), and tflimport::DepthwiseConv2DGraphBuilder::build().

◆ add() [2/2]

OpBuilder & OpBuilder::add ( void  )
inline

Create "Add" op and push it onto the internal stack.

BEFORE| Left; Right; Stack AFTER | Add(Left, Right); Stack

Definition at line 86 of file IRBuilder.h.

86{ return binary<coco::Add>(); }

◆ div()

OpBuilder & OpBuilder::div ( void  )
inline

Create "Div" op and push it onto the internal stack.

BEFORE| Left; Right; Stack AFTER | Div(Left, Right); Stack

Definition at line 108 of file IRBuilder.h.

108{ return binary<coco::Div>(); }

Referenced by caffeimport::BatchNormBuilder::build().

◆ empty() [1/2]

bool OpBuilder::empty ( void  ) const
inline

Return true if the internal stack is empty.

Definition at line 41 of file IRBuilder.h.

41{ return _stack.empty(); }

◆ empty() [2/2]

bool OpBuilder::empty ( void  ) const
inline

Return true if the internal stack is empty.

Definition at line 43 of file IRBuilder.h.

43{ return _stack.empty(); }

◆ load() [1/2]

◆ load() [2/2]

OpBuilder & OpBuilder::load ( coco::Object obj)
inline

Create "Load" op and push it onto the internal stack.

BEFORE| Stack AFTER | Load(obj); Stack

Definition at line 72 of file IRBuilder.h.

73 {
74 auto op = _module->entity()->op()->create<coco::Load>();
75 op->object(obj);
76 push(op);
77 return (*this);
78 }

References coco::OpManager::create(), coco::Module::entity(), coco::Load::object(), coco::EntityManager::op(), and push().

◆ mul() [1/2]

OpBuilder & OpBuilder::mul ( void  )
inline

Create "Mul" op and push it onto the internal stack.

BEFORE| Left; Right; Stack AFTER | Mul(Left, Right); Stack

Definition at line 100 of file IRBuilder.h.

100{ return binary<coco::Mul>(); }

Referenced by caffeimport::BatchNormBuilder::build(), caffeimport::EltwiseBuilder::build(), and caffeimport::ScaleBuilder::build().

◆ mul() [2/2]

OpBuilder & OpBuilder::mul ( void  )
inline

Create "Mul" op and push it onto the internal stack.

BEFORE| Left; Right; Stack AFTER | Mul(Left, Right); Stack

Definition at line 94 of file IRBuilder.h.

94{ return binary<coco::Mul>(); }

◆ pop() [1/2]

◆ pop() [2/2]

coco::Op * OpBuilder::pop ( void  )
inline

Pop op from the internal stack.

BEFORE| Op; Stack AFTER | Stack

Definition at line 102 of file IRBuilder.h.

103 {
104 assert(_stack.size() > 0);
105 auto op = _stack.front();
106 _stack.pop_front();
107 return op;
108 }

◆ push() [1/2]

OpBuilder & OpBuilder::push ( coco::Op op)
inline

Push op onto the internal stack.

BEFORE| Stack AFTER | Op; Stack

Definition at line 58 of file IRBuilder.h.

59 {
60 _stack.push_front(op);
61 return (*this);
62 }

Referenced by caffeimport::EltwiseBuilder::build(), and load().

◆ push() [2/2]

OpBuilder & OpBuilder::push ( coco::Op op)
inline

Push op onto the internal stack.

BEFORE| Stack AFTER | Op; Stack

Definition at line 60 of file IRBuilder.h.

61 {
62 _stack.push_front(op);
63 return (*this);
64 }

◆ sub()

OpBuilder & OpBuilder::sub ( void  )
inline

Create "Sub" op and push it onto the internal stack.

BEFORE| Left; Right; Stack AFTER | Sub(Left, Right); Stack

Definition at line 92 of file IRBuilder.h.

92{ return binary<coco::Sub>(); }

Referenced by caffeimport::BatchNormBuilder::build().

◆ top() [1/2]

coco::Op * OpBuilder::top ( void  ) const
inline

Return the operation at the top of the internal stack.

Definition at line 46 of file IRBuilder.h.

47 {
48 assert(_stack.size() > 0);
49 return _stack.front();
50 }

◆ top() [2/2]

coco::Op * OpBuilder::top ( void  ) const
inline

Return the operation at the top of the internal stack.

Definition at line 48 of file IRBuilder.h.

49 {
50 assert(_stack.size() > 0);
51 return _stack.front();
52 }

The documentation for this class was generated from the following files: