shape#

ivy.shape(x, /, *, as_array=False)[source]#

Return the shape of the array x.

Parameters:
  • x (Union[Array, NativeArray]) – Input array to infer the shape of.

  • as_array (bool, default: False) – Whether to return the shape as an array. Default is False.

Return type:

Union[Shape, NativeShape]

Returns:

ret – Shape of the array x.

Examples

>>> x = ivy.array([[-1, 0, 1], [1, 0, -1]])
>>> y = ivy.shape(x)
>>> z = ivy.shape(x, as_array = True)
>>> print(y)
(2, 3)
>>> print(z)
ivy.array([2, 3])
Array.shape()#

Array dimensions.