ONE - On-device Neural Engine
Loading...
Searching...
No Matches
coco::Copy Class Referencefinal

Index-wise element transfer between two objects. More...

#include <Instrs.h>

Collaboration diagram for coco::Copy:

Public Member Functions

 Copy ()
 
CopyasCopy (void) override
 
const CopyasCopy (void) const override
 
Instrloc (void) override
 
Objectfrom (void) const
 
void from (Object *o)
 
Objectinto (void) const
 
void into (Object *o)
 
- Public Member Functions inherited from coco::Instr
 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
 
- Public Member Functions inherited from coco::Object::Producer
virtual ~Producer ()=default
 
- Public Member Functions inherited from coco::Bag::Updater
virtual ~Updater ()=default
 
- Public Member Functions inherited from coco::Locatable
virtual ~Locatable ()=default
 
- Public Member Functions inherited from coco::Object::Consumer
virtual ~Consumer ()=default
 
- Public Member Functions inherited from coco::Bag::Reader
virtual ~Reader ()=default
 

Detailed Description

Index-wise element transfer between two objects.

Given two objects "src" and "dst" of the same kind/shape, "copy(src, dst)" denotes index-wise element transfer.

For example, the following pseudo-code describes "copy(src, dat)" when both src and dst are a feature map of the shape B x C x H x W:

for each valid index b, ch, row, col: load the "src->at(b, ch, row, col)"-th element from bag(src) store it as the "dst->at(b, ch, row, col)"-th element of bag(dst)

In principle, "copy" is unnecessary as it is always possible to rewrite "copy" as a "shuffle" below. However, "shuffle"-based optimization is too heavy as it requires much of iterations.

Definition at line 84 of file Instrs.h.

Constructor & Destructor Documentation

◆ Copy()

coco::Copy::Copy ( )
inline

Definition at line 87 of file Instrs.h.

87 : _from{this}, _into{this}
88 {
89 // DO NOTHING
90 }

Member Function Documentation

◆ asCopy() [1/2]

const Copy * coco::Copy::asCopy ( void  ) const
inlineoverride

Definition at line 94 of file Instrs.h.

94{ return this; }

◆ asCopy() [2/2]

Copy * coco::Copy::asCopy ( void  )
inlineoverride

Definition at line 93 of file Instrs.h.

93{ return this; }

◆ from() [1/2]

void coco::Copy::from ( Object o)
inline

Definition at line 101 of file Instrs.h.

101{ _from.value(o); }
Object * value(void) const
Definition Use.h:37

References coco::Use::value().

◆ from() [2/2]

Object * coco::Copy::from ( void  ) const
inline

Definition at line 100 of file Instrs.h.

100{ return _from.value(); }

References coco::Use::value().

Referenced by InstrBuilder::copy(), and InstrPrinter::visit().

◆ into() [1/2]

void coco::Copy::into ( Object o)
inline

Definition at line 105 of file Instrs.h.

105{ _into.value(o); }
Object * value(void) const
Definition Def.h:37

References coco::Def::value().

◆ into() [2/2]

Object * coco::Copy::into ( void  ) const
inline

Definition at line 104 of file Instrs.h.

104{ return _into.value(); }

References coco::Def::value().

Referenced by InstrPrinter::visit().

◆ loc()

Instr * coco::Copy::loc ( void  )
inlineoverridevirtual

Implements coco::Locatable.

Definition at line 97 of file Instrs.h.

97{ return this; }

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