mlx.core.can_cast

Contents

mlx.core.can_cast#

can_cast(from_: array | Dtype, to: Dtype) bool#

Determine if one data type can be cast to another according to type promotion rules.

from_ can be cast to to if promoting the two together gives back to.

Parameters:
  • from (array or Dtype) – The source array or dtype.

  • to (Dtype) – The destination dtype.

Returns:

Whether the cast can be performed.

Return type:

bool