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
) – Whether or not to return the dtype in string format. Default isFalse
. (default: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.
- Return type:
Dtype
- Container.dtype(self, *, as_native=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
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 }
- Return type:
Container