#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 68 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 79 of file Shape.h.
79: _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 112 of file Shape.h.
112{ _dimensions.emplace_back(d); }
◆ asFeature()
Definition at line 27 of file Shape.cc.
28{
30
31
32
33
34
35
36 const auto batch =
dim(0);
37 const auto depth =
dim(3);
38 const auto height =
dim(1);
39 const auto width =
dim(2);
40
41 return {batch, depth, height, width};
42}
◆ dim() [1/2]
int32_t & onert::ir::Shape::dim |
( |
int |
i | ) |
|
|
inline |
Definition at line 92 of file Shape.h.
92{ return _dimensions.at(i); }
◆ dim() [2/2]
int32_t onert::ir::Shape::dim |
( |
int |
i | ) |
const |
|
inline |
Definition at line 85 of file Shape.h.
86 {
87 assert(
rank() != 0 || i == 0);
88 return rank() == 0 ? 1 : _dimensions.at(i);
89 }
References rank().
◆ dims()
const std::vector< int32_t > & onert::ir::Shape::dims |
( |
| ) |
const |
|
inline |
Definition at line 83 of file Shape.h.
83{ 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 45 of file Shape.cc.
46{
47 assert(to_rank -
rank() >= 0);
48 _dimensions.insert(_dimensions.cbegin(), to_rank -
rank(), 1);
49}
◆ 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 51 of file Shape.cc.
52{
53
54 if (std::any_of(_dimensions.begin(), _dimensions.end(),
55 [](const int32_t &v) { return v == kUnspecifiedDim; }))
56 throw std::runtime_error("num_elements() cannot calculate when any dimension is unspecified");
57
58 return std::accumulate(_dimensions.cbegin(), _dimensions.cend(), UINT64_C(1),
59 std::multiplies<uint64_t>());
60}
◆ 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 106 of file Shape.h.
106{ _dimensions.insert(_dimensions.cbegin(), d); }
◆ rank()
int onert::ir::Shape::rank |
( |
| ) |
const |
|
inline |
Definition at line 81 of file Shape.h.
81{ return _dimensions.size(); }
Referenced by dim().
◆ kMaxRank
int32_t const onert::ir::Shape::kMaxRank = 6 |
|
inlinestatic |
◆ kUnspecifiedDim
int32_t const onert::ir::Shape::kUnspecifiedDim = -1 |
|
inlinestatic |
The documentation for this struct was generated from the following files: