Compute the dtype that a binary operation on the inputs would produce.
Implements NumPy-style type promotion: tensors contribute their declared dtype, while Python scalars are treated as having no dtype of their own and follow whichever tensor operand they appear with.
Parameters
Returns
DTypeThe dtype that an arithmetic operation on a and b would
produce.
Notes
The promotion algorithm groups dtypes into four kinds — bool — and uses bit-width as a tiebreaker. Concretely:
See also promote_types (operates directly on dtype objects).
Examples
>>> import lucid
>>> a = lucid.tensor([1, 2], dtype=lucid.int32)
>>> b = lucid.tensor([1., 2.], dtype=lucid.float32)
>>> lucid.result_type(a, b)
lucid.float32