8000 result_type doesn't take dtypes and doesn't match numpy · Issue #51284 · pytorch/pytorch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
result_type doesn't take dtypes and doesn't match numpy #51284
Open
@rgommers

Description

@rgommers

🚀 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

  1. It's useful
  2. NumPy compatibility

Additional details

It looks like this wasn't discussed in gh-26012, the PR that implemented torch.result_type.

cc @mruberry @rgommers @heitorschueroff

Metadata

Metadata

Assignees

No one assigned

    Labels

    function requestA request for a new function or the addition of new arguments/modes to an existing function.module: numpyRelated to numpy support, and also numpy compatibility of our operatorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0