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

Class to represent strides where stride[N-1] >= stride[N] holds for all N < rank. More...

#include <NonIncreasingStride.h>

Public Member Functions

void init (const Shape &shape)
 Initialize the stride data using Shape.
 
uint32_t at (uint32_t axis) const
 Get an stride value for specific axis.
 
uint32_t offset (const Index &index) const
 Get the 1-D offset of specified index for n-D tensor.
 

Detailed Description

Class to represent strides where stride[N-1] >= stride[N] holds for all N < rank.

Definition at line 40 of file NonIncreasingStride.h.

Member Function Documentation

◆ at()

uint32_t nnfw::misc::tensor::NonIncreasingStride::at ( uint32_t  axis) const
inline

Get an stride value for specific axis.

Parameters
[in]axisAxis of stride
Returns
The value of stride

Definition at line 70 of file NonIncreasingStride.h.

70{ return _stride.at(axis); }

Referenced by nnfw::misc::tensor::Object< T >::Object().

◆ init()

void nnfw::misc::tensor::NonIncreasingStride::init ( const Shape shape)
inline

Initialize the stride data using Shape.

Parameters
[in]shapeto build stride info
Returns
N/A

Definition at line 48 of file NonIncreasingStride.h.

49 {
50 _stride.resize(shape.rank());
51
52 // Scalar
53 if (shape.rank() == 0)
54 return;
55
56 _stride.at(shape.rank() - 1) = 1;
57
58 for (uint32_t axis = shape.rank() - 1; axis > 0; --axis)
59 {
60 _stride.at(axis - 1) = _stride.at(axis) * shape.dim(axis);
61 }
62 }

References nnfw::misc::tensor::Shape::dim(), and nnfw::misc::tensor::Shape::rank().

Referenced by nnfw::misc::tensor::Object< T >::Object().

◆ offset()

uint32_t nnfw::misc::tensor::NonIncreasingStride::offset ( const Index index) const

Get the 1-D offset of specified index for n-D tensor.

Parameters
indexIndex object
Returns
1-D offset of index

Definition at line 28 of file NonIncreasingStride.cpp.

29{
30 const size_t rank = _stride.size();
31
32 assert(index.rank() == rank);
33
34 uint32_t offset = 0;
35
36 for (size_t axis = 0; axis < rank; ++axis)
37 {
38 offset += _stride.at(axis) * index.at(axis);
39 }
40
41 return offset;
42}
uint32_t offset(const Index &index) const
Get the 1-D offset of specified index for n-D tensor.
loco::GraphInputIndex index(const TFPlaceholder *node)
Definition TFNode.cpp:54

References offset().

Referenced by nnfw::misc::tensor::Object< T >::at(), nnfw::misc::tensor::Object< T >::Object(), and offset().


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