17#ifndef __ONERT_IR_SHAPE_H__
18#define __ONERT_IR_SHAPE_H__
52 FeatureShape(int32_t depth, int32_t height, int32_t width) :
N{1},
C{depth},
H{height},
W{width}
63 FeatureShape(int32_t batch, int32_t depth, int32_t height, int32_t width)
64 :
N{batch},
C{depth},
H{height},
W{width}
78 explicit Shape(
int rank) : _dimensions(rank) {}
80 Shape(std::initializer_list<int32_t> dimensions) : _dimensions(dimensions) {}
82 int rank()
const {
return _dimensions.size(); }
84 const std::vector<int32_t> &
dims()
const {
return _dimensions; }
86 int32_t
dim(
int i)
const
88 assert(
rank() != 0 || i == 0);
89 return rank() == 0 ? 1 : _dimensions.at(i);
93 int32_t &
dim(
int i) {
return _dimensions.at(i); }
98 uint64_t num_elements()
const;
107 void prepend(int32_t d) { _dimensions.insert(_dimensions.cbegin(), d); }
113 void append(int32_t d) { _dimensions.emplace_back(d); }
119 void extendRank(
int to_rank);
129 return (std::find(_dimensions.begin(), _dimensions.end(), kUnspecifiedDim) !=
134 std::vector<int32_t> _dimensions;
bool operator==(const Shape &lhs, const Shape &rhs)
bool operator!=(const Shape &lhs, const Shape &rhs)
bool rankMaybeUnspecified(const ir::Shape &shape)
Find out if tha rank in this shape is "maybe" unspecified. Note that when rank == 0,...
Shape convertShape(const Shape &shape, const PermuteType &type)
Converts shape when its rank is 4.
Structure to have values of dimensions for feature.
FeatureShape()=default
Construct FeatureShape object using default constrcutor.
FeatureShape(int32_t depth, int32_t height, int32_t width)
Construct FeatureShape object with three values of dimensions.
FeatureShape(int32_t batch, int32_t depth, int32_t height, int32_t width)
Construct FeatureShape object with four values of dimensions.
Shape(std::initializer_list< int32_t > dimensions)
void prepend(int32_t d)
Add dimension to the beginning.
void append(int32_t d)
Add dimension to the end.
static int32_t const kUnspecifiedDim
const std::vector< int32_t > & dims() const
static int32_t const kMaxRank
bool hasUnspecifiedDims() const
Find out if any dimension is unspecified. If the rank is not specified, it returns false.