Shape#

A Shape is used in expressing the shape of a certain entity in Legate. The reason Legate introduces this indirection to the shape metadata is that stores in Legate can have unknown shapes at creation time; the shape of an unbound store is determined only when the producer task finishes. The shape object can help the runtime query the store’s metadata or construct another store isomorphic to the store without getting blocked.

Shape objects should behave just like an array of integers, but operations that introspect the values implicitly block on completion of the producer task.

Shape.__init__([extents, ispace])

Constructs a new shape object

Properties#

Shape.extents

Returns the extents of the shape in a tuple

Shape.fixed

Indicates whether the shape's extents are already computed

Shape.ndim

Dimension of the shape.

Shape.volume()

Returns the shape's volume

Shape.sum()

Returns a sum of the extents

Shape.strides()

Computes strides of the shape.

Manipulation Methods#

Shape.drop(dim)

Removes a dimension from the shape

Shape.update(dim, new_value)

Replaces the extent of a dimension with a new extent

Shape.replace(dim, new_values)

Replaces a dimension with multiple dimensions

Shape.insert(dim, new_value)

Inserts a new dimension

Shape.map(mapping)

Applies a mapping to each extent in the shape

Arithmetic and comparison#

Shape.__eq__(other)

Checks whether the shape is identical to a given shape

Shape.__le__(other)

Returns the result of element-wise <=.

Shape.__lt__(other)

Returns the result of element-wise <.

Shape.__ge__(other)

Returns the result of element-wise <=.

Shape.__gt__(other)

Returns the result of element-wise <=.

Shape.__add__(other)

Returns an element-wise addition of the shapes

Shape.__sub__(other)

Returns an element-wise subtraction between the shapes

Shape.__mul__(other)

Returns an element-wise multiplication of the shapes

Shape.__mod__(other)

Returns the result of element-wise modulo operation

Shape.__floordiv__(other)

Returns the result of element-wise integer division