17#ifndef __ONERT_IR_SHAPE_H__
18#define __ONERT_IR_SHAPE_H__
50 FeatureShape(int32_t depth, int32_t height, int32_t width) :
N{1},
C{depth},
H{height},
W{width}
50 FeatureShape(int32_t depth, int32_t height, int32_t width) :
N{1},
C{depth},
H{height},
W{width} {
…}
61 FeatureShape(int32_t batch, int32_t depth, int32_t height, int32_t width)
62 :
N{batch},
C{depth},
H{height},
W{width}
61 FeatureShape(int32_t batch, int32_t depth, int32_t height, int32_t width) {
…}
77 explicit Shape(
int rank) : _dimensions(rank) {}
79 Shape(std::initializer_list<int32_t> dimensions) : _dimensions(dimensions) {}
81 int rank()
const {
return _dimensions.size(); }
83 const std::vector<int32_t> &
dims()
const {
return _dimensions; }
85 int32_t
dim(
int i)
const
87 assert(
rank() != 0 || i == 0);
88 return rank() == 0 ? 1 : _dimensions.at(i);
85 int32_t
dim(
int i)
const {
…}
92 int32_t &
dim(
int i) {
return _dimensions.at(i); }
97 uint64_t num_elements()
const;
106 void prepend(int32_t d) { _dimensions.insert(_dimensions.cbegin(), d); }
112 void append(int32_t d) { _dimensions.emplace_back(d); }
118 void extendRank(
int to_rank);
128 return (std::find(_dimensions.begin(), _dimensions.end(), kUnspecifiedDim) !=
133 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.
static int32_t const kUnspecifiedDim
void append(int32_t d)
Add dimension to the end.
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.