#include <Shape.h>
|
| Shape ()=default |
|
| Shape (int rank) |
|
| Shape (std::initializer_list< int32_t > dimensions) |
|
int | rank () const |
|
const std::vector< int32_t > & | dims () const |
|
int32_t | dim (int i) const |
|
int32_t & | dim (int i) |
|
uint64_t | num_elements () const |
| Returns number of elements when rank or dim is specified.
|
|
FeatureShape | asFeature () const |
|
void | prepend (int32_t d) |
| Add dimension to the beginning.
|
|
void | append (int32_t d) |
| Add dimension to the end.
|
|
void | extendRank (int to_rank) |
| Extend rank of Shape object for operand with param.
|
|
bool | hasUnspecifiedDims () const |
| Find out if any dimension is unspecified. If the rank is not specified, it returns false.
|
|
Definition at line 70 of file Shape.h.
◆ Shape() [1/3]
onert::ir::Shape::Shape |
( |
| ) |
|
|
default |
◆ Shape() [2/3]
onert::ir::Shape::Shape |
( |
int |
rank | ) |
|
|
inlineexplicit |
◆ Shape() [3/3]
onert::ir::Shape::Shape |
( |
std::initializer_list< int32_t > |
dimensions | ) |
|
|
inline |
Definition at line 80 of file Shape.h.
80: _dimensions(dimensions) {}
◆ append()
void onert::ir::Shape::append |
( |
int32_t |
d | ) |
|
|
inline |
Add dimension to the end.
- Parameters
-
[in] | d | dimension to add to the end |
Definition at line 113 of file Shape.h.
113{ _dimensions.emplace_back(d); }
◆ asFeature()
Definition at line 34 of file Shape.cc.
35{
37
38
39
40
41
42
43 const auto batch =
dim(0);
44 const auto depth =
dim(3);
45 const auto height =
dim(1);
46 const auto width =
dim(2);
47
48 return {batch, depth, height, width};
49}
◆ dim() [1/2]
int32_t & onert::ir::Shape::dim |
( |
int |
i | ) |
|
|
inline |
Definition at line 93 of file Shape.h.
93{ return _dimensions.at(i); }
◆ dim() [2/2]
int32_t onert::ir::Shape::dim |
( |
int |
i | ) |
const |
|
inline |
Definition at line 86 of file Shape.h.
87 {
88 assert(
rank() != 0 || i == 0);
89 return rank() == 0 ? 1 : _dimensions.at(i);
90 }
References rank().
◆ dims()
const std::vector< int32_t > & onert::ir::Shape::dims |
( |
| ) |
const |
|
inline |
Definition at line 84 of file Shape.h.
84{ return _dimensions; }
◆ extendRank()
void Shape::extendRank |
( |
int |
to_rank | ) |
|
Extend rank of Shape object for operand with param.
- Parameters
-
[in] | to_rank | The rank value to be extended to |
Definition at line 52 of file Shape.cc.
53{
54 assert(to_rank -
rank() >= 0);
55 _dimensions.insert(_dimensions.cbegin(), to_rank -
rank(), 1);
56}
◆ hasUnspecifiedDims()
bool onert::ir::Shape::hasUnspecifiedDims |
( |
| ) |
const |
|
inline |
◆ num_elements()
uint64_t Shape::num_elements |
( |
| ) |
const |
Returns number of elements when rank or dim is specified.
Definition at line 58 of file Shape.cc.
59{
60
61 if (std::any_of(_dimensions.begin(), _dimensions.end(),
62 [](const int32_t &v) { return v == kUnspecifiedDim; }))
63 throw std::runtime_error("num_elements() cannot calculate when any dimension is unspecified");
64
65 return std::accumulate(_dimensions.cbegin(), _dimensions.cend(), UINT64_C(1),
66 std::multiplies<uint64_t>());
67}
◆ prepend()
void onert::ir::Shape::prepend |
( |
int32_t |
d | ) |
|
|
inline |
Add dimension to the beginning.
- Parameters
-
[in] | d | dimension to add to the beginning |
Definition at line 107 of file Shape.h.
107{ _dimensions.insert(_dimensions.cbegin(), d); }
◆ rank()
int onert::ir::Shape::rank |
( |
| ) |
const |
|
inline |
Definition at line 82 of file Shape.h.
82{ return _dimensions.size(); }
Referenced by dim().
◆ kMaxRank
int32_t const Shape::kMaxRank = 6 |
|
static |
◆ kUnspecifiedDim
int32_t const Shape::kUnspecifiedDim = -1 |
|
static |
The documentation for this struct was generated from the following files: