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

Base class for NN model arguments (Input/Output) More...

#include <Arg.h>

Public Member Functions

 Arg (const nncc::core::ADT::tensor::Shape &shape)
 
virtual ~Arg ()=default
 
const nncc::core::ADT::tensor::Shapeshape (void) const
 
const std::string & name (void) const
 
void name (const std::string &s)
 
Bagbag (void) const
 
void bag (Bag *)
 
ElemIDat (const nncc::core::ADT::tensor::Index &)
 
const ElemIDat (const nncc::core::ADT::tensor::Index &) const
 
void reorder (const nncc::core::ADT::tensor::Layout &l)
 
template<typename LayoutImpl >
void reorder (void)
 

Protected Member Functions

virtual void onTake (Bag *)
 
virtual void onRelease (Bag *)
 

Detailed Description

Base class for NN model arguments (Input/Output)

Definition at line 36 of file Arg.h.

Constructor & Destructor Documentation

◆ Arg()

coco::Arg::Arg ( const nncc::core::ADT::tensor::Shape shape)
explicit

Definition at line 34 of file Arg.cpp.

34 : _shape{shape}, _bag{nullptr}
35{
37}
const nncc::core::ADT::tensor::Shape & shape(void) const
Definition Arg.h:45
uint64_t num_elements(const Shape &)
Definition Shape.cpp:51

References nncc::core::ADT::tensor::num_elements(), and shape().

◆ ~Arg()

virtual coco::Arg::~Arg ( )
virtualdefault

Member Function Documentation

◆ at() [1/2]

ElemID & coco::Arg::at ( const nncc::core::ADT::tensor::Index index)

Definition at line 56 of file Arg.cpp.

57{
58 return _map.at(l.offset(_shape, index));
59}

Referenced by reorder().

◆ at() [2/2]

const ElemID & coco::Arg::at ( const nncc::core::ADT::tensor::Index index) const

Definition at line 61 of file Arg.cpp.

62{
63 return _map.at(l.offset(_shape, index));
64}

◆ bag() [1/2]

void coco::Arg::bag ( Bag bag)

Definition at line 39 of file Arg.cpp.

40{
41 if (_bag != nullptr)
42 {
43 onRelease(_bag);
44 _bag = nullptr;
45 }
46
47 assert(_bag == nullptr);
48
49 if (bag != nullptr)
50 {
51 _bag = bag;
52 onTake(_bag);
53 }
54}
virtual void onRelease(Bag *)
Definition Arg.h:53
Bag * bag(void) const
Definition Arg.h:56
virtual void onTake(Bag *)
Definition Arg.h:52

References bag(), onRelease(), and onTake().

◆ bag() [2/2]

Bag * coco::Arg::bag ( void  ) const
inline

Definition at line 56 of file Arg.h.

56{ return _bag; }

Referenced by bag().

◆ name() [1/2]

void coco::Arg::name ( const std::string &  s)
inline

Definition at line 49 of file Arg.h.

49{ _name = s; }

◆ name() [2/2]

const std::string & coco::Arg::name ( void  ) const
inline

Definition at line 48 of file Arg.h.

48{ return _name; }

◆ onRelease()

virtual void coco::Arg::onRelease ( Bag )
inlineprotectedvirtual

Definition at line 53 of file Arg.h.

53{ return; }

Referenced by bag().

◆ onTake()

virtual void coco::Arg::onTake ( Bag )
inlineprotectedvirtual

Definition at line 52 of file Arg.h.

52{ return; }

Referenced by bag().

◆ reorder() [1/2]

void coco::Arg::reorder ( const nncc::core::ADT::tensor::Layout l)

Definition at line 66 of file Arg.cpp.

67{
69
70 for (IndexEnumerator e{shape()}; e.valid(); e.advance())
71 {
72 const auto offset = static_cast<uint32_t>(l.offset(shape(), e.current()));
73
74 at(e.current()) = coco::ElemID{offset};
75 }
76}
ElemID & at(const nncc::core::ADT::tensor::Index &)
Definition Arg.cpp:56
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540

References at(), offset(), and shape().

◆ reorder() [2/2]

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

Definition at line 65 of file Arg.h.

65{ reorder(LayoutImpl{}); }
void reorder(void)
Definition Arg.h:65

References reorder().

Referenced by reorder().

◆ shape()


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