class ov::Dimension

Overview

Class representing a dimension, which may be dynamic (undetermined until runtime), in a shape or shape-like object. More…

#include <dimension.hpp>

class Dimension
{
public:
    // typedefs

    typedef int64_t value_type;

    // construction

    Dimension();
    Dimension(, );
    Dimension();
    Dimension();

    // methods

    boolconst Dimension& operator == () const;
    boolconst Dimension& operator != () const;
    bool is_static() const;
    bool is_dynamic() const;
    value_type get_length() const;
    value_type get_min_length() const;
    value_type get_max_length() const;
    const Interval& get_interval() const;
    Interval& get_interval();
    boolconst Dimension& same_scheme() const;
    boolconst Dimension& compatible() const;
    boolconst Dimension& relaxes() const;
    boolconst Dimension& refines() const;
    Dimensionconst Dimension& operator + () const;
    Dimensionconst Dimension& operator - () const;
    Dimensionconst value_type operator/ () const;
    Dimension&const value_type operator/= ();
    Dimensionconst Dimension& operator\* () const;
    Dimension&const Dimension& operator += ();
    Dimension&const Dimension& operator\*= ();
    Dimensionconst Dimension& operator & () const;
    Dimension&const Dimension& operator &= ();
    std::string to_string() const;
    static boolDimension&const Dimension&const Dimension& merge(, , );
    static boolDimension&const Dimension&const Dimension& broadcast_merge(, , );
    static Dimension dynamic();
};

Detailed Documentation

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().

Construction

Dimension()

Construct a static dimension.

Parameters:

dimension

Value of the dimension.

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()

Construct a dimension from string.

Parameters:

str

String to parse to dimension.

Dimension()

Construct a dynamic dimension with range [0, …].

Methods

bool is_static() const

Check whether this dimension is static.

Returns:

true if the dimension is static, else false.

bool is_dynamic() const

Check whether this dimension is dynamic.

Returns:

false if the dimension is static, else true.

value_type get_length() const

Convert this dimension to value_type. This dimension must be static and non-negative.

Parameters:

std::invalid_argument

If this dimension is dynamic or negative.

const Interval& get_interval() const

Return the interval of valid lengths.

boolconst Dimension& same_scheme() 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 and dim are both dynamic, or if they are both static and equal; otherwise, false.

boolconst Dimension& compatible() 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 with d, else false.

boolconst Dimension& relaxes() const

Check whether this dimension is a relaxation of the argument.

A dimension d1 relaxes (or is a relaxation of) d2 if d1 and d2 are static and equal, or d1 is dynamic.

d1.relaxes(d2) is equivalent to d2.refines(d1).

Parameters:

d

The dimension to compare this dimension with.

Returns:

true if this dimension relaxes d, else false.

boolconst Dimension& refines() const

Check whether this dimension is a refinement of the argument.

A dimension d2 refines (or is a refinement of) d1 if d1 and d2 are static and equal, or d2 is dynamic.

d1.refines(d2) is equivalent to d2.relaxes(d1).

Parameters:

d

The dimension to compare this dimension with.

Returns:

true if this dimension relaxes d, else false.

Dimensionconst Dimension& operator + () const

Addition operator for Dimension.

Parameters:

dim

Right operand for addition.

Returns:

Smallest interval dimension enclosing inputs

Dimensionconst Dimension& operator - () const

Subtraction operator for Dimension.

Parameters:

dim

Right operand for subtraction.

Returns:

Smallest interval dimension enclosing inputs

Dimensionconst value_type operator/ () const

Division operator for Dimension divided by a value_type parameter.

Parameters:

divisor

Right operand for division.

Returns:

Smallest interval dimension enclosing inputs

Dimension&const value_type operator/= ()

Divided-into operator for Dimension.

Parameters:

divisor

Right operand for multiplication.

Returns:

A reference to \*this, after updating \*this to the value \*this \* dim.

Dimensionconst Dimension& operator\* () const

Multiplication operator for Dimension.

Parameters:

dim

Right operand for multiplicaiton.

Returns:

Smallest interval containing all “produces” which are 0 if either of this or dim has length 0, else unbounded if either is unbounded, else product of lengths.

Dimension&const Dimension& operator += ()

Add-into operator for Dimension.

Parameters:

dim

Right operand for addition.

Returns:

A reference to \*this, after updating \*this to the value \*this + dim.

Dimension&const Dimension& operator\*= ()

Multiply-into operator for Dimension.

Parameters:

dim

Right operand for multiplication.

Returns:

A reference to \*this, after updating \*this to the value \*this \* dim.

Dimensionconst Dimension& operator & () const

Intersection of dimensions.

Dimension&const Dimension& operator &= ()

Intersection of dimensions.

std::string to_string() const

String representation of Dimension.

static boolDimension&const Dimension&const Dimension& merge(, , )

Try to merge two Dimension objects together.

  • If d1 is dynamic, writes d2 to dst and returns true.

  • If d2 is dynamic, writes d1 to dst and returns true.

  • If d1 and d2 are static and equal, writes d1 to dst and returns true.

  • If d1 and d2 are both static and unequal, leaves dst unchanged and returns false.

Parameters:

dst

Reference to write the merged Dimension into.

d1

First dimension to merge.

d2

Second dimension to merge.

Returns:

true if merging succeeds, else false.

static boolDimension&const Dimension&const Dimension& broadcast_merge(, , )

Try to merge two Dimension objects together with implicit broadcasting of unit-sized dimension to non unit-sized dimension.

static Dimension dynamic()

Create a dynamic dimension.

Returns:

A dynamic dimension.