dpnp.tensor.can_cast¶
- dpnp.tensor.can_cast(from_, to, /, *, casting='safe') bool[source]¶
Determines if one data type can be cast to another data type according to Type Promotion Rules.
- Parameters:
from ({usm_ndarray, dtype}) -- Source data type. If from_ is an array, device-specific type promotion rules apply.
to (dtype) -- Target data type.
casting (str, optional) --
Controls what kind of data casting may occur.
"no" means data types should not be cast at all.
"safe" means only casts that preserve values are allowed.
"same_kind" means only safe casts and casts within a kind, like float64 to float32, are allowed.
"unsafe" means any data conversion can be done.
Default:
"safe".
- Returns:
out (bool) -- Gives True if cast can occur according to the casting rule.