ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::misc::feature::Object< T > Class Template Referencefinal

Class to have information of the operand for feature. More...

#include <Object.h>

Collaboration diagram for nnfw::misc::feature::Object< T >:

Public Types

using Generator = std::function< T(const Shape &shape, const Index &index)>
 

Public Member Functions

 Object (const Shape &shape, const Generator &fn)
 Construct Object object with Shape of feature and set value used by Generator.
 
const Shapeshape (void) const
 Get Shape of feature as the reference.
 
at (uint32_t ch, uint32_t row, uint32_t col) const override
 Get the value used by three indexes.
 
- Public Member Functions inherited from nnfw::misc::feature::Reader< T >
virtual ~Reader ()=default
 Destruct Reader object using default destructor.
 
virtual T at (uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) const =0
 Get the value used by four indexes.
 

Detailed Description

template<typename T>
class nnfw::misc::feature::Object< T >

Class to have information of the operand for feature.

Definition at line 42 of file Object.h.

Member Typedef Documentation

◆ Generator

template<typename T >
using nnfw::misc::feature::Object< T >::Generator = std::function<T(const Shape &shape, const Index &index)>

Definition at line 45 of file Object.h.

Constructor & Destructor Documentation

◆ Object()

template<typename T >
nnfw::misc::feature::Object< T >::Object ( const Shape shape,
const Generator fn 
)
inline

Construct Object object with Shape of feature and set value used by Generator.

Parameters
[in]shapeReference of Shape for feature
[in]fnA function to set values of operand tensor

Definition at line 53 of file Object.h.

53 : _shape{shape}
54 {
55 _value.resize(_shape.C * _shape.H * _shape.W);
56
57 for (int32_t ch = 0; ch < _shape.C; ++ch)
58 {
59 for (int32_t row = 0; row < _shape.H; ++row)
60 {
61 for (int32_t col = 0; col < _shape.W; ++col)
62 {
63 _value.at(offsetOf(ch, row, col)) = fn(_shape, Index{ch, row, col});
64 }
65 }
66 }
67 }
const Shape & shape(void) const
Get Shape of feature as the reference.
Definition Object.h:74

References nnfw::misc::feature::Shape::C, nnfw::misc::feature::Shape::H, and nnfw::misc::feature::Shape::W.

Member Function Documentation

◆ at()

template<typename T >
T nnfw::misc::feature::Object< T >::at ( uint32_t  ch,
uint32_t  row,
uint32_t  col 
) const
inlineoverridevirtual

Get the value used by three indexes.

Parameters
[in]chThe depth index
[in]rowThe height index
[in]colThe width index
Returns
The value at the offset

Implements nnfw::misc::feature::Reader< T >.

Definition at line 84 of file Object.h.

85 {
86 return _value.at(offsetOf(ch, row, col));
87 }

◆ shape()

template<typename T >
const Shape & nnfw::misc::feature::Object< T >::shape ( void  ) const
inline

Get Shape of feature as the reference.

Returns
The reference of the width value

Definition at line 74 of file Object.h.

74{ return _shape; }

Referenced by RandomDataGenerator.RandomDataGenerator::_gen_float32(), RandomDataGenerator.RandomDataGenerator::_gen_int16(), and RandomDataGenerator.RandomDataGenerator::_gen_uint8().


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