Feature Request: support int->float type promotion for torch.reciprocal #49091
Labels
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
torch.reciprocal does not support integer inputs today:
This is because reciprocal's codomain for the integers is not the integers, and historically PyTorch did not implement integer->floating point type promotion for unary ufuncs. This has changed, however. For example, torch.sin() promotes integer inputs to float:
And this is compatible with NumPy's behavior:
PyTorch has a pattern for implementing this behavior. See for example, this PR: #48644. In addition to implementing this behavior a UnaryUfuncInfo should be added for torch.reciprocal, and other tests of it that are made redundant removed.
Note that NumPy's np.reciprocal() is bugged (numpy/numpy#10374) and does not promote integer inputs to float:
The text was updated successfully, but these errors were encountered: