ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::misc::tensor::Index Struct Reference

Struct to represent index of each dimension of a tensor. More...

#include <Index.h>

Public Member Functions

 Index (uint32_t rank)
 Construct a new Index object.
 
 Index (std::initializer_list< int32_t > offsets)
 Construct a new Index object.
 
uint32_t rank (void) const
 Get the rank.
 
int32_t at (uint32_t n) const
 Get the index n'th dimension.
 
int32_t & at (uint32_t n)
 Get the reference of the index n'th dimension.
 

Detailed Description

Struct to represent index of each dimension of a tensor.

Definition at line 41 of file Index.h.

Constructor & Destructor Documentation

◆ Index() [1/2]

nnfw::misc::tensor::Index::Index ( uint32_t  rank)
inline

Construct a new Index object.

Parameters
[in]rankRank of a tensor

Definition at line 48 of file Index.h.

48{ _offsets.resize(rank); }
uint32_t rank(void) const
Get the rank.
Definition Index.h:67

References rank().

◆ Index() [2/2]

nnfw::misc::tensor::Index::Index ( std::initializer_list< int32_t >  offsets)
inline

Construct a new Index object.

Parameters
[in]offsetsRank of a tensor of std::initializer_list<int32_t> type

Definition at line 55 of file Index.h.

55 : _offsets{offsets}
56 {
57 // DO NOTHING
58 }

Member Function Documentation

◆ at() [1/2]

int32_t & nnfw::misc::tensor::Index::at ( uint32_t  n)
inline

Get the reference of the index n'th dimension.

Parameters
[in]nDimension
Returns
reference of index of n'th dimension

Definition at line 82 of file Index.h.

82{ return _offsets.at(n); }

◆ at() [2/2]

int32_t nnfw::misc::tensor::Index::at ( uint32_t  n) const
inline

Get the index n'th dimension.

Parameters
[in]nDimension
Returns
index of n'th dimension

Definition at line 75 of file Index.h.

75{ return _offsets.at(n); }

Referenced by nnfw::misc::tensor::IndexEnumerator::advance(), and nnfw::misc::tensor::IndexEnumerator::IndexEnumerator().

◆ rank()

uint32_t nnfw::misc::tensor::Index::rank ( void  ) const
inline

Get the rank.

Returns
Rank that this Index object can handle
Note
We can use static_cast
because size of _offsets is decieded by constructor's uintt_32 type argument

Definition at line 67 of file Index.h.

67{ return static_cast<uint32_t>(_offsets.size()); }

Referenced by Index().


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