closest_valid_dtype#
- ivy.closest_valid_dtype(type, /)[source]#
Determine the closest valid datatype to the datatype passed as input.
- Parameters:
type (
Optional
[Union
[Dtype
,str
]]) – The data type for which to check the closest valid type for.- Return type:
Union
[Dtype
,str
]- Returns:
ret – The closest valid data type as a native ivy.Dtype
Examples
With
ivy.Dtype
input:>>> xType = ivy.float16 >>> yType = ivy.closest_valid_dtype(xType) >>> print(yType) float16
With
ivy.NativeDtype
inputs:>>> xType = ivy.native_uint16 >>> yType = ivy.closest_valid_dtype(xType) >>> print(yType) uint16
With
str
input:>>> xType = 'int32' >>> yType = ivy.closest_valid_dtype(xType) >>> print(yType) int32