Open
Description
🚀 Feature
The signature for torch.result_type is currently:
result_type(tensor1, tensor2)
While numpy.result_type's signature is:
result_type(*arrays_and_dtypes)
It's not uncommon to mix tensors and dtypes to ensure you find both a dtype that input tensors can upcast to, and that's a minimum dtype in the dtype hierarchy, e.g.:
result_type(tensor1, tensor2, complex64)
Here is an example from scipy.signal: https://github.com/scipy/scipy/blob/5f4c4d802e5a56708d86909af6e5685cd95e6e66/scipy/signal/_upfirdn.py#L79
torch.result_type
can be extended in a backwards compatible way to accepted a sequence of arrays and dtypes. I propose to do so.
Motivation
- It's useful
- NumPy compatibility
Additional details
It looks like this wasn't discussed in gh-26012, the PR that implemented torch.result_type
.