ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::misc::feature::IndexIterator Class Reference

Class to iterate Callable with Index of feature. More...

#include <IndexIterator.h>

Public Member Functions

 IndexIterator (const Shape &shape)
 Construct IndexIterator object with Shape of feature.
 
template<typename Callable >
IndexIteratoriter (Callable cb)
 Call a function iterated.
 

Detailed Description

Class to iterate Callable with Index of feature.

Definition at line 38 of file IndexIterator.h.

Constructor & Destructor Documentation

◆ IndexIterator()

nnfw::misc::feature::IndexIterator::IndexIterator ( const Shape shape)
inline

Construct IndexIterator object with Shape of feature.

Parameters
[in]shapeShape reference of feature

Definition at line 45 of file IndexIterator.h.

45 : _shape{shape}
46 {
47 // DO NOTHING
48 }

Member Function Documentation

◆ iter()

template<typename Callable >
IndexIterator & nnfw::misc::feature::IndexIterator::iter ( Callable  cb)
inline

Call a function iterated.

Parameters
[in]cbA callback function
Returns
Current IndexIterator object

Definition at line 56 of file IndexIterator.h.

57 {
58 for (int32_t batch = 0; batch < _shape.N; ++batch)
59 {
60 for (int32_t ch = 0; ch < _shape.C; ++ch)
61 {
62 for (int32_t row = 0; row < _shape.H; ++row)
63 {
64 for (int32_t col = 0; col < _shape.W; ++col)
65 {
66 cb(batch, ch, row, col);
67 }
68 }
69 }
70 }
71
72 return (*this);
73 }

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

Referenced by nnfw::misc::feature::operator<<().


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