ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert::ir::Coordinates Class Referencefinal

Class to represent position(offset) of tensor.
Assume that the front is higher dimensional. i.g. N: 0, C: 1, H: 2, W: 3 for NCHW layout. More...

#include <Coordinates.h>

Public Member Functions

 Coordinates ()=default
 Construct a new Coordinates object with zero dimension.
 
 Coordinates (std::initializer_list< int32_t > init)
 Construct a new Coordinates object.
 
 Coordinates (std::initializer_list< uint32_t > init)
 Construct a new Coordinates object.
 
 Coordinates (int rank)
 Construct a new Coordinates object with rank.
 
void set (size_t dimension, int32_t coordinate)
 Set the coordinate of one of the coordinates.
 
size_t size () const
 Return size of coordinates.
 
int32_t operator[] (size_t dimension) const
 
std::vector< int32_t >::const_iterator begin () const
 begin() of const_iterator for this class
 
std::vector< int32_t >::const_iterator end () const
 end() of const_iterator for this class
 

Static Public Attributes

static constexpr size_t num_max_dimensions = 4
 

Detailed Description

Class to represent position(offset) of tensor.
Assume that the front is higher dimensional. i.g. N: 0, C: 1, H: 2, W: 3 for NCHW layout.

Definition at line 36 of file Coordinates.h.

Constructor & Destructor Documentation

◆ Coordinates() [1/4]

onert::ir::Coordinates::Coordinates ( )
default

Construct a new Coordinates object with zero dimension.

Returns
N/A

◆ Coordinates() [2/4]

onert::ir::Coordinates::Coordinates ( std::initializer_list< int32_t >  init)
inline

Construct a new Coordinates object.

Parameters
[in]initThe initialzer_list with coordinates
Returns

Definition at line 52 of file Coordinates.h.

52 : _coordinates{init}
53 {
54 assert(init.size() <= num_max_dimensions);
55 }
static constexpr size_t num_max_dimensions
Definition Coordinates.h:39

References num_max_dimensions.

◆ Coordinates() [3/4]

onert::ir::Coordinates::Coordinates ( std::initializer_list< uint32_t >  init)
inline

Construct a new Coordinates object.

Parameters
[in]initThe initialzer_list with coordinates
Returns

Definition at line 61 of file Coordinates.h.

61 : _coordinates{init.begin(), init.end()}
62 {
63 assert(init.size() <= num_max_dimensions);
64 }

References num_max_dimensions.

◆ Coordinates() [4/4]

onert::ir::Coordinates::Coordinates ( int  rank)
inlineexplicit

Construct a new Coordinates object with rank.

Parameters
[in]rankThe rank of coordinates
Returns

Definition at line 70 of file Coordinates.h.

70: _coordinates(rank, 0) {}

Member Function Documentation

◆ begin()

std::vector< int32_t >::const_iterator onert::ir::Coordinates::begin ( ) const
inline

begin() of const_iterator for this class

Returns
The first iterator of the coordinates

Definition at line 110 of file Coordinates.h.

110{ return _coordinates.begin(); }

◆ end()

std::vector< int32_t >::const_iterator onert::ir::Coordinates::end ( ) const
inline

end() of const_iterator for this class

Returns
The last iterator of the coordinates

Definition at line 116 of file Coordinates.h.

116{ return _coordinates.end(); }

◆ operator[]()

int32_t onert::ir::Coordinates::operator[] ( size_t  dimension) const
inline

Definition at line 98 of file Coordinates.h.

99 {
100 assert(dimension < _coordinates.size());
101 return _coordinates[dimension];
102 }

◆ set()

void onert::ir::Coordinates::set ( size_t  dimension,
int32_t  coordinate 
)
inline

Set the coordinate of one of the coordinates.

Parameters
[in]dimensionDimension for which the coordinate is set.
[in]CoordinateCoordinate to be set for the dimension.

Definition at line 79 of file Coordinates.h.

80 {
81 assert(dimension < num_max_dimensions);
82 if (dimension >= _coordinates.size())
83 {
84 _coordinates.resize(dimension + 1, 0);
85 }
86 _coordinates[dimension] = coordinate;
87 }

References num_max_dimensions.

Referenced by onert::ir::convertCoordinates(), ShapeLoop(), and onert::backend::acl_common::AclSubTensorAnalyzer::visit().

◆ size()

size_t onert::ir::Coordinates::size ( ) const
inline

Return size of coordinates.

Returns
size of coordinates

Definition at line 95 of file Coordinates.h.

95{ return _coordinates.size(); }

Referenced by onert::backend::acl_common::asTensorCoordinate().

Field Documentation

◆ num_max_dimensions

constexpr size_t onert::ir::Coordinates::num_max_dimensions = 4
staticconstexpr

Definition at line 39 of file Coordinates.h.

Referenced by Coordinates(), Coordinates(), and set().


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