ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mir::Index Class Reference

#include <Index.h>

Public Member Functions

 Index ()=default
 
 Index (std::initializer_list< int32_t > &&l) noexcept
 
 Index (size_t rank)
 
int32_t rank () const
 
Indexresize (int32_t size)
 resize index to given dimension number
 
Indexfill (int32_t index)
 fill all axis with index
 
int32_t & at (int32_t axis)
 return position on given axis
 
int32_t at (int32_t axis) const
 return position on given axis
 

Detailed Description

Definition at line 31 of file Index.h.

Constructor & Destructor Documentation

◆ Index() [1/3]

mir::Index::Index ( )
default

◆ Index() [2/3]

mir::Index::Index ( std::initializer_list< int32_t > &&  l)
inlinenoexcept

Definition at line 36 of file Index.h.

36 : _indices(std::move(l))
37 {
38 // DO NOTHING
39 }

◆ Index() [3/3]

mir::Index::Index ( size_t  rank)
inlineexplicit

Definition at line 41 of file Index.h.

41: _indices(rank) {}
int32_t rank() const
Definition Index.h:43

Member Function Documentation

◆ at() [1/2]

◆ at() [2/2]

int32_t mir::Index::at ( int32_t  axis) const
inline

return position on given axis

Parameters
axisindex of axis to get index on. If axis is negative returns axis from the last
Returns

Definition at line 71 of file Index.h.

71{ return _indices[wrap_index(axis, _indices.size())]; }

References adt::small_vector< T, Capacity >::size(), and mir::wrap_index().

◆ fill()

Index & mir::Index::fill ( int32_t  index)

fill all axis with index

Returns
*this

Definition at line 30 of file Index.cpp.

31{
32 std::fill(std::begin(_indices), std::end(_indices), index);
33 return (*this);
34}

◆ rank()

int32_t mir::Index::rank ( ) const
inline

Definition at line 43 of file Index.h.

43{ return static_cast<int32_t>(_indices.size()); }

References adt::small_vector< T, Capacity >::size().

Referenced by mir::ShapeRange::contains(), mir::TensorVariant::getOffset(), mir::ShapeIter::operator!=(), mir::operator<<(), and mir_interpreter::shift().

◆ resize()

Index & mir::Index::resize ( int32_t  size)

resize index to given dimension number

Parameters
sizenew number of dimensions
Returns
*this
Warning
if new size is greater than old, new dimensions are undefined

Definition at line 24 of file Index.cpp.

25{
26 _indices.resize(size);
27 return *this;
28}
void resize(size_t new_size) noexcept
resize to given new size
Definition SmallVector.h:78
int32_t size[5]
Definition Slice.cpp:35

References adt::small_vector< T, Capacity >::resize(), and size.

Referenced by mir_interpreter::DepthwiseConv2DImpl< T >::run(), mir_interpreter::TransposeImpl< T >::run(), mir_interpreter::PadImpl< T >::run(), and mir_interpreter::MIRInterpreter::visit().


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