dtype#

ivy.dtype(x, *, as_native=False)[source]#

Get the data type for input array x.

Parameters:
  • x (Union[Array, NativeArray]) – Tensor for which to get the data type.

  • as_native (bool, default: False) – Whether or not to return the dtype in string format. Default is False.

Return type:

Union[Dtype, NativeDtype]

Returns:

ret – Data type of the array.

Examples

With ivy.Array inputs:

>>> x1 = ivy.array([1.0, 2.0, 3.5, 4.5, 5, 6])
>>> y = ivy.dtype(x1)
>>> print(y)
float32

With ivy.NativeArray inputs:

>>> x1 = ivy.native_array([1, 0, 1, -1, 0])
>>> y = ivy.dtype(x1)
>>> print(y)
int32

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.native_array([1.0, 2.0, -1.0, 4.0, 1.0]),
...                   b=ivy.native_array([1, 0, 0, 0, 1]))
>>> y = ivy.dtype(x.a)
>>> print(y)
float32
Array.dtype()#

Data type of the array elements.

Container.dtype(self, *, as_native=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

Examples

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([2, 3, 4]))
>>> y = x.dtype()
>>> print(y)
{
    a: int32,
    b: int32
}