ONE - On-device Neural Engine
Loading...
Searching...
No Matches
coco::Instr Class Reference

Base interface on explicit computation steps in coco IR. More...

#include <Instr.h>

Collaboration diagram for coco::Instr:

Data Structures

struct  IVisitor
 Instr visitor interface. More...
 
struct  Visitor
 

Public Member Functions

 Instr ()=default
 
 Instr (const Instr &)=delete
 
 Instr (Instr &&)=delete
 
virtual ~Instr ()
 
template<typename T >
accept (IVisitor< T > *v) const
 
template<typename T >
accept (IVisitor< T > &v) const
 
template<typename T >
accept (IVisitor< T > &&v) const
 
const InstrIndexindex (void) const
 
- Public Member Functions inherited from coco::DLinkedList< Child, Parent >::Node
 Node ()
 
virtual ~Node ()
 
Parent * parent (void) const
 
Child * prev (void) const
 
Child * next (void) const
 
void insertBefore (Node *next)
 
void insertAfter (Node *prev)
 
void detach (void)
 
- Public Member Functions inherited from coco::Entity
virtual ~Entity ()=default
 
Modulemodule (void) const
 

Friends

void DLinkedList (Block *, Instr *)
 
void DLinkedList (Block *, Instr *)
 

Detailed Description

Base interface on explicit computation steps in coco IR.

NOTE Input/output is explicit in Instr, but implicit in Op NOTE Instr is may (not always) be a combination of multiple NN operations

One may find a set of supported instructions from "Instrs.h"

‍How to add a new base instruction in coco IR <<

To introduce a new instruction (whose name is INS),

  1. Append "INSTR(INS)" to "Instr.lst"
  2. Declare class INS which inherits Instr class in "Instrs.h" NOTE This class SHOULD be default constructible

Definition at line 56 of file Instr.h.

Constructor & Destructor Documentation

◆ Instr() [1/3]

coco::Instr::Instr ( )
default

◆ Instr() [2/3]

coco::Instr::Instr ( const Instr )
delete

◆ Instr() [3/3]

coco::Instr::Instr ( Instr &&  )
delete

◆ ~Instr()

virtual coco::Instr::~Instr ( )
inlinevirtual

Definition at line 70 of file Instr.h.

71 {
72 if (parent())
73 {
74 // NOTE It is safe to invoke detach here (although "Instr" is not a final class)
75 // as "leaving" hook accesses only the internal of "Instr" class
76 detach();
77 }
78 }
Parent * parent(void) const

References coco::DLinkedList< Child, Parent >::Node::detach(), and coco::DLinkedList< Child, Parent >::Node::parent().

Member Function Documentation

◆ accept() [1/3]

template<typename T >
T coco::Instr::accept ( IVisitor< T > &&  v) const
inline

Definition at line 127 of file Instr.h.

127{ return accept(&v); }
T accept(IVisitor< T > *v) const
Definition Instr.h:114

References accept().

Referenced by accept().

◆ accept() [2/3]

template<typename T >
T coco::Instr::accept ( IVisitor< T > &  v) const
inline

Definition at line 126 of file Instr.h.

126{ return accept(&v); }

References accept().

Referenced by accept().

◆ accept() [3/3]

template<typename T >
T coco::Instr::accept ( IVisitor< T > *  v) const
inline

Definition at line 114 of file Instr.h.

115 {
116#define INSTR(Name) \
117 if (auto ins = as##Name()) \
118 { \
119 return v->visit(ins); \
120 }
121#include "coco/IR/Instr.lst"
122#undef INSTR
123 throw std::runtime_error{"unreachable"};
124 }

Referenced by dump().

◆ index()

const InstrIndex & coco::Instr::index ( void  ) const
inline

Definition at line 130 of file Instr.h.

130{ return _index; }

Referenced by coco::DLinkedList< Child, Parent >::joined(), and coco::DLinkedList< Child, Parent >::leaving().

Friends And Related Symbol Documentation

◆ DLinkedList [1/2]

void DLinkedList ( Block ,
Instr  
)
friend

◆ DLinkedList [2/2]

void DLinkedList ( Block ,
Instr  
)
friend

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