22#ifndef __NNFW_MISC_TENSOR_INDEX_H__
23#define __NNFW_MISC_TENSOR_INDEX_H__
29#include <initializer_list>
55 Index(std::initializer_list<int32_t> offsets) : _offsets{offsets}
67 uint32_t
rank(
void)
const {
return static_cast<uint32_t
>(_offsets.size()); }
75 int32_t
at(uint32_t n)
const {
return _offsets.at(n); }
82 int32_t &
at(uint32_t n) {
return _offsets.at(n); }
85 std::vector<int32_t> _offsets;
94inline static Index copy_reverse(
const Index &origin)
96 uint32_t rank = origin.
rank();
98 for (uint32_t i = 0; i < rank; i++)
99 target.at(i) = origin.at(rank - 1 - i);
Struct to represent index of each dimension of a tensor.
uint32_t rank(void) const
Get the rank.
Index(uint32_t rank)
Construct a new Index object.
int32_t at(uint32_t n) const
Get the index n'th dimension.
Index(std::initializer_list< int32_t > offsets)
Construct a new Index object.
int32_t & at(uint32_t n)
Get the reference of the index n'th dimension.