Class ov::Dimension¶
-
class Dimension¶
Class representing a dimension, which may be dynamic (undetermined until runtime), in a shape or shape-like object.
Static dimensions may be implicitly converted from value_type. A dynamic dimension is constructed with Dimension() or Dimension::dynamic().
Public Functions
-
Dimension(value_type dimension)¶
Construct a static dimension.
- Parameters
dimension – Value of the dimension.
-
Dimension(value_type min_dimension, value_type max_dimension)¶
Construct a dynamic dimension with bounded range.
- Parameters
min_dimension – The lower inclusive limit for the dimension
max_dimension – The upper inclusive limit for the dimension
-
Dimension(const std::string &str)¶
Construct a dimension from string.
- Parameters
str – String to parse to dimension.
-
Dimension() = default¶
Construct a dynamic dimension with range [0, …].
-
inline bool is_static() const¶
Check whether this dimension is static.
- Returns
true
if the dimension is static, elsefalse
.
-
inline bool is_dynamic() const¶
Check whether this dimension is dynamic.
- Returns
false
if the dimension is static, elsetrue
.
-
value_type get_length() const¶
Convert this dimension to
value_type
. This dimension must be static and non-negative.- Throws
std::invalid_argument – If this dimension is dynamic or negative.
-
bool same_scheme(const Dimension &dim) const¶
Check whether this dimension represents the same scheme as the argument (both dynamic, or equal).
- Parameters
dim – The other dimension to compare this dimension to.
- Returns
true
if this dimension anddim
are both dynamic, or if they are both static and equal; otherwise,false
.
-
bool compatible(const Dimension &d) const¶
Check whether this dimension is capable of being merged with the argument dimension.
Two dimensions are considered compatible if it is possible to merge them. (See Dimension::merge.)
- Parameters
d – The dimension to compare this dimension with.
- Returns
true
if this dimension is compatible withd
, elsefalse
.
-
bool relaxes(const Dimension &d) const¶
Check whether this dimension is a relaxation of the argument.
A dimension
d1
relaxes (or is a relaxation of)d2
ifd1
andd2
are static and equal, ord1
is dynamic.d1.relaxes(d2)
is equivalent tod2.refines(d1)
.- Parameters
d – The dimension to compare this dimension with.
- Returns
true
if this dimension relaxesd
, elsefalse
.
-
bool refines(const Dimension &d) const¶
Check whether this dimension is a refinement of the argument.
A dimension
d2
refines (or is a refinement of)d1
ifd1
andd2
are static and equal, ord2
is dynamic.d1.refines(d2)
is equivalent tod2.relaxes(d1)
.- Parameters
d – The dimension to compare this dimension with.
- Returns
true
if this dimension relaxesd
, elsefalse
.
-
Dimension operator+(const Dimension &dim) const¶
Addition operator for Dimension.
- Parameters
dim – Right operand for addition.
- Returns
Smallest interval dimension enclosing inputs
-
Dimension operator-(const Dimension &dim) const¶
Subtraction operator for Dimension.
- Parameters
dim – Right operand for subtraction.
- Returns
Smallest interval dimension enclosing inputs
-
Dimension operator/(const value_type divisor) const¶
Division operator for Dimension divided by a value_type parameter.
- Parameters
divisor – Right operand for division.
- Returns
Smallest interval dimension enclosing inputs
-
inline Dimension &operator/=(const value_type divisor)¶
Divided-into operator for Dimension.
- Parameters
divisor – Right operand for multiplication.
- Returns
A reference to
*this
, after updating*this
to the value*this * dim
.
-
Dimension operator*(const Dimension &dim) const¶
Multiplication operator for Dimension.
- Parameters
dim – Right operand for multiplicaiton.
- Returns
Smallest interval containing all “produces” which are 0 if either of
this
ordim
has length0
, else unbounded if either is unbounded, else product of lengths.
-
inline Dimension &operator+=(const Dimension &dim)¶
Add-into operator for Dimension.
- Parameters
dim – Right operand for addition.
- Returns
A reference to
*this
, after updating*this
to the value*this + dim
.
Public Static Functions
-
static bool merge(Dimension &dst, const Dimension &d1, const Dimension &d2)¶
Try to merge two Dimension objects together.
If
d1
is dynamic, writesd2
todst
and returnstrue
.If
d2
is dynamic, writesd1
todst
and returnstrue
.If
d1
andd2
are static and equal, writesd1
todst
and returnstrue
.If
d1
andd2
are both static and unequal, leavesdst
unchanged and returnsfalse
.
- Parameters
dst – [out] Reference to write the merged Dimension into.
d1 – First dimension to merge.
d2 – Second dimension to merge.
- Returns
true
if merging succeeds, elsefalse
.
-
Dimension(value_type dimension)¶