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 isFalse.
- Return type:
Union[Dtype,NativeDtype]- Returns:
ret – Data type of the array.
Examples
With
ivy.Arrayinputs:>>> x1 = ivy.array([1.0, 2.0, 3.5, 4.5, 5, 6]) >>> y = ivy.dtype(x1) >>> print(y) float32
With
ivy.NativeArrayinputs:>>> x1 = ivy.native_array([1, 0, 1, -1, 0]) >>> y = ivy.dtype(x1) >>> print(y) int32
With
ivy.Containerinputs:>>> 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.