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

2D Convolution over 3D Feature Map with 4D kernel More...

#include <Ops.h>

Collaboration diagram for coco::Conv2D:

Public Member Functions

 Conv2D ()
 
uint32_t arity (void) const final
 Return the number of arguments (# of child Ops)
 
Oparg (uint32_t n) const final
 Return N-th argument.
 
std::set< Object * > uses (void) const override
 Return a set of object(s) used during execution.
 
Conv2DasConv2D (void) override
 
const Conv2DasConv2D (void) const override
 
Instrloc (void) override
 
Oparg (void) const
 
void arg (Op *arg)
 
KernelObjectker (void) const
 
void ker (KernelObject *ker)
 
uint32_t group (void) const
 Divide an input and kernel (= convolution filter) into G independent groups.
 
void group (uint32_t g)
 
Padding2Dpad (void)
 
const Padding2Dpad (void) const
 
Stride2Dstride (void)
 
const Stride2Dstride (void) const
 
- Public Member Functions inherited from coco::Op
virtual ~Op ()
 
template<typename T >
accept (IVisitor< T > *v) const
 
template<typename T >
accept (IVisitor< T > &v) const
 
template<typename T >
accept (IVisitor< T > &&v) const
 
void accept (IMutator *m)
 
void accept (IMutator &m)
 
void accept (IMutator &&m)
 
Instrparent (void) const
 
Opup (void) const
 Return a pointer to the parent Op.
 
- Public Member Functions inherited from coco::Entity
virtual ~Entity ()=default
 
Modulemodule (void) const
 
- Public Member Functions inherited from coco::Object::Consumer
virtual ~Consumer ()=default
 
- Public Member Functions inherited from coco::Bag::Reader
virtual ~Reader ()=default
 
- Public Member Functions inherited from coco::Locatable
virtual ~Locatable ()=default
 

Detailed Description

2D Convolution over 3D Feature Map with 4D kernel

NOTE IFM and OFM are implicit. Only 4D kernel is explicit in this class TODO Decide source code layout policy and extract this class if necessary

Definition at line 73 of file Ops.h.

Constructor & Destructor Documentation

◆ Conv2D()

coco::Conv2D::Conv2D ( )
explicit

Definition at line 24 of file Conv2D.cpp.

24 : _ker{this}, _arg{this}
25{
26 // DO NOTHING
27}

Member Function Documentation

◆ arg() [1/3]

void coco::Conv2D::arg ( Op arg)
inline

Definition at line 96 of file Ops.h.

96{ _arg.child(arg); }
Op * arg(void) const
Definition Ops.h:95
Op * child(void) const
Definition Part.h:40

References arg(), and coco::Part::child().

◆ arg() [2/3]

Op * coco::Conv2D::arg ( uint32_t  n) const
finalvirtual

Return N-th argument.

Note
The behavior of arg(n) is defined only when n < artiy()

Implements coco::Op.

Referenced by enco::output_shape(), and OpPrinter::visit().

◆ arg() [3/3]

Op * coco::Conv2D::arg ( void  ) const
inline

Definition at line 95 of file Ops.h.

95{ return _arg.child(); }

References coco::Part::child().

Referenced by arg(), and uses().

◆ arity()

uint32_t coco::Conv2D::arity ( void  ) const
finalvirtual

Return the number of arguments (# of child Ops)

Implements coco::Op.

Definition at line 29 of file Conv2D.cpp.

30{
31 // Conv2D has one argument (IFM)
32 // NOTE This design is subject to change
33 return 1;
34}

◆ asConv2D() [1/2]

const Conv2D * coco::Conv2D::asConv2D ( void  ) const
inlineoverride

Definition at line 86 of file Ops.h.

86{ return this; }

◆ asConv2D() [2/2]

Conv2D * coco::Conv2D::asConv2D ( void  )
inlineoverride

Definition at line 85 of file Ops.h.

85{ return this; }

◆ group() [1/2]

void coco::Conv2D::group ( uint32_t  g)
inline

Definition at line 117 of file Ops.h.

117{ _group = g; }

◆ group() [2/2]

uint32_t coco::Conv2D::group ( void  ) const
inline

Divide an input and kernel (= convolution filter) into G independent groups.

Given an input of shape(Ic, Ih, Iw), a kernel of shape(Kn, Kc, Kh, Kw), and group G, Conv2D is identical to G independent convolutions over G inputs of shape(Ic / G, Ih, Iw) and a kernel of shape(Kn / G, Kc, Kh, Kw) followed by concatenation.

REQUIRED

  • "Ic" SHOULD BE a multiple of "G"
  • "Kc" SHOULD BE identical to "Ic /G"

NOTE Depthwise convolution is a special case of group convolution where Ic == G.

Definition at line 116 of file Ops.h.

116{ return _group; }

◆ ker() [1/2]

void coco::Conv2D::ker ( KernelObject ker)

Definition at line 62 of file Conv2D.cpp.

62{ _ker.value(ker); }
KernelObject * ker(void) const
Definition Conv2D.cpp:64
Object * value(void) const
Definition Use.h:37

References ker(), and coco::Use::value().

◆ ker() [2/2]

KernelObject * coco::Conv2D::ker ( void  ) const

Definition at line 64 of file Conv2D.cpp.

65{
66 if (auto obj = _ker.value())
67 {
68 assert(obj->asKernel() != nullptr);
69 return obj->asKernel();
70 }
71
72 return nullptr;
73}

References coco::Use::value().

Referenced by tflimport::Conv2DGraphBuilder::build(), tflimport::DepthwiseConv2DGraphBuilder::build(), ker(), enco::output_shape(), uses(), and OpPrinter::visit().

◆ loc()

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

Implements coco::Locatable.

Definition at line 89 of file Ops.h.

89{ return parent(); }
Instr * parent(void) const
Definition Op.cpp:31

References coco::Op::parent().

◆ pad() [1/2]

Padding2D * coco::Conv2D::pad ( void  )
inline

Definition at line 120 of file Ops.h.

120{ return &_pad; }

Referenced by enco::output_shape(), and OpPrinter::visit().

◆ pad() [2/2]

const Padding2D * coco::Conv2D::pad ( void  ) const
inline

Definition at line 121 of file Ops.h.

121{ return &_pad; }

◆ stride() [1/2]

Stride2D * coco::Conv2D::stride ( void  )
inline

Definition at line 124 of file Ops.h.

124{ return &_stride; }

Referenced by enco::output_shape(), and OpPrinter::visit().

◆ stride() [2/2]

const Stride2D * coco::Conv2D::stride ( void  ) const
inline

Definition at line 125 of file Ops.h.

125{ return &_stride; }

◆ uses()

std::set< Object * > coco::Conv2D::uses ( void  ) const
overridevirtual

Return a set of object(s) used during execution.

NOTE There is no 'def' method as Op is not allowed to define a new object

Implements coco::Op.

Definition at line 42 of file Conv2D.cpp.

43{
44 std::set<Object *> res;
45
46 if (ker())
47 {
48 res.insert(ker());
49 }
50
51 if (auto ifm = arg())
52 {
53 for (auto obj : ifm->uses())
54 {
55 res.insert(obj);
56 }
57 }
58
59 return res;
60}
std::set< Object * > uses(void) const override
Return a set of object(s) used during execution.
Definition Conv2D.cpp:42

References arg(), and ker().


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