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

Generic Kernel Layout. More...

#include <KernelLayouts.h>

Collaboration diagram for coco::KernelLayouts::Generic:

Public Member Functions

const KernelLayout::IDid (void) const override
 Return the identifier of each layout.
 
const nncc::core::ADT::kernel::Shapeshape (void) const override
 
ElemIDat (uint32_t n, uint32_t ch, uint32_t row, uint32_t col)
 
ElemID at (uint32_t n, uint32_t ch, uint32_t row, uint32_t col) const override
 
void reorder (const nncc::core::ADT::kernel::Layout &l)
 
template<typename LayoutImpl >
void reorder (void)
 
- Public Member Functions inherited from coco::KernelLayout
virtual ~KernelLayout ()=default
 

Static Public Member Functions

static const KernelLayout::IDuid (void)
 
static std::unique_ptr< Genericcreate (const nncc::core::ADT::kernel::Shape &shape)
 

Detailed Description

Generic Kernel Layout.

Definition at line 87 of file KernelLayouts.h.

Member Function Documentation

◆ at() [1/2]

ElemID & coco::KernelLayouts::Generic::at ( uint32_t  n,
uint32_t  ch,
uint32_t  row,
uint32_t  col 
)

Definition at line 122 of file KernelLayouts.cpp.

123{
124 return _content.at(l.offset(_shape, n, ch, row, col));
125}

Referenced by reorder().

◆ at() [2/2]

ElemID coco::KernelLayouts::Generic::at ( uint32_t  n,
uint32_t  ch,
uint32_t  row,
uint32_t  col 
) const
overridevirtual

Implements coco::KernelLayout.

Definition at line 127 of file KernelLayouts.cpp.

128{
129 return _content.at(l.offset(_shape, n, ch, row, col));
130}

◆ create()

std::unique_ptr< Generic > coco::KernelLayouts::Generic::create ( const nncc::core::ADT::kernel::Shape shape)
static

Definition at line 149 of file KernelLayouts.cpp.

150{
151 return std::unique_ptr<Generic>{new Generic{shape}};
152}
const nncc::core::ADT::kernel::Shape & shape(void) const override

References shape().

Referenced by coco::KernelObject::KernelObject().

◆ id()

const KernelLayout::ID * coco::KernelLayouts::Generic::id ( void  ) const
inlineoverridevirtual

Return the identifier of each layout.

REQUIRED

Given l1 and l2 of KernelLayout * type, typeid(*l1) == typeif(*l2) SHOULD hold if l1->id() == l2->id() holds.

Implements coco::KernelLayout.

Definition at line 94 of file KernelLayouts.h.

94{ return uid(); }
static const KernelLayout::ID * uid(void)

References uid().

Referenced by uid().

◆ reorder() [1/2]

void coco::KernelLayouts::Generic::reorder ( const nncc::core::ADT::kernel::Layout l)

Definition at line 132 of file KernelLayouts.cpp.

133{
134 for (uint32_t n = 0; n < shape().count(); ++n)
135 {
136 for (uint32_t ch = 0; ch < shape().depth(); ++ch)
137 {
138 for (uint32_t row = 0; row < shape().height(); ++row)
139 {
140 for (uint32_t col = 0; col < shape().width(); ++col)
141 {
142 at(n, ch, row, col) = ElemID{l.offset(shape(), n, ch, row, col)};
143 }
144 }
145 }
146 }
147}
ElemID & at(uint32_t n, uint32_t ch, uint32_t row, uint32_t col)
uint32_t width(void) const
Definition Shape.h:47
uint32_t height(void) const
Definition Shape.h:46
uint32_t count(void) const
Definition Shape.h:44
uint32_t depth(void) const
Definition Shape.h:45

References at(), nncc::core::ADT::kernel::Shape::count(), nncc::core::ADT::kernel::Shape::depth(), nncc::core::ADT::kernel::Shape::height(), shape(), and nncc::core::ADT::kernel::Shape::width().

◆ reorder() [2/2]

template<typename LayoutImpl >
void coco::KernelLayouts::Generic::reorder ( void  )
inline

Definition at line 102 of file KernelLayouts.h.

102{ reorder(LayoutImpl{}); }

References reorder().

Referenced by reorder().

◆ shape()

const nncc::core::ADT::kernel::Shape & coco::KernelLayouts::Generic::shape ( void  ) const
inlineoverridevirtual

◆ uid()

const KernelLayout::ID * coco::KernelLayouts::Generic::uid ( void  )
static

Definition at line 113 of file KernelLayouts.cpp.

114{
115 struct LayoutID final : public KernelLayout::ID
116 {
117 };
118 static LayoutID id;
119 return &id;
120}
const KernelLayout::ID * id(void) const override
Return the identifier of each layout.

References id().

Referenced by id().


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