Conversation
💊 CI failures summary and remediationsAs of commit 422e870 (more details on the Dr. CI page):
🕵️ 2 new failures recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
|
Thinking seems good, but PRs introducing new functions typically do add the out variants and derivatives, and they should be straightforward to include. I do have a question, though: What's the difference between min_values (max_values) and amin (amax)? Should we leave min_values and max_values unchanged and deprecate them? |
|
@mruberry Yes, I missed that point. Added now. |
| argmin | ||
| amax | ||
| amin | ||
| max |
There was a problem hiding this comment.
This is a better place for max and min but would you please remove them from the "Comparison Ops," too, then? People should be using maximum and minimum, anyway, for comparisons.
| r""" | ||
| amax(input, dim, keepdim=False, *, out=None) -> Tensor | ||
|
|
||
| Returns the maximum value of each row of the :attr:`input` tensor in the given |
There was a problem hiding this comment.
Given that there are potentially multiple dimensions, it's slice, not row
| The difference between ``max``/``min`` and ``amax``/``amin`` is: | ||
| 1. ``amax``/``amin`` supports reducing on multiple dimensions, | ||
| 2. ``amax``/``amin`` does not return indices, | ||
| 3. ``amax``/``amin`` produces deterministic (sub)gradients unlike |
There was a problem hiding this comment.
max and min will produce deterministic (but different) gradients soon, so it makes sense to say that amax evenly distributes gradient between equal values, while max propagates gradient only to a single index in the source tensor.
|
Just fixed the failures in doc build and doc test. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
@zasdfgbnm Would you rebase this? |
|
@mruberry rebased |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This is to align with the naming in numpy and in #43092 Test Plan: ``` python test/test_torch.py TestTorchDeviceTypeCPU.test_aminmax_cpu_float32 python test/test_torch.py TestTorchDeviceTypeCUDA.test_aminmax_cuda_float32 ``` Reviewers: Subscribers: Tasks: Tags: [ghstack-poisoned]
Summary: This is to align with the naming in numpy and in #43092 Test Plan: ``` python test/test_torch.py TestTorchDeviceTypeCPU.test_aminmax_cpu_float32 python test/test_torch.py TestTorchDeviceTypeCUDA.test_aminmax_cuda_float32 ``` Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D23465298](https://our.internmc.facebook.com/intern/diff/D23465298) [ghstack-poisoned]
Summary: Pull Request resolved: #44001 This is to align with the naming in numpy and in #43092 Test Plan: ``` python test/test_torch.py TestTorchDeviceTypeCPU.test_aminmax_cpu_float32 python test/test_torch.py TestTorchDeviceTypeCUDA.test_aminmax_cuda_float32 ``` Imported from OSS Reviewed By: jerryzh168 Differential Revision: D23465298 fbshipit-source-id: b599035507156cefa53942db05f93242a21c8d06
|
This was reverted because it triggered a preexisting CUDA bug, relevant log snippet: |
Summary: Add a max/min operator that only return values. ## Some important decision to discuss | **Question** | **Current State** | |---------------------------------------|-------------------| | Expose torch.max_values to python? | No | | Remove max_values and only keep amax? | Yes | | Should amax support named tensors? | Not in this PR | ## Numpy compatibility Reference: https://numpy.org/doc/stable/reference/generated/numpy.amax.html | Parameter | PyTorch Behavior | |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| | `axis`: None or int or tuple of ints, optional. Axis or axes along which to operate. By default, flattened input is used. If this is a tuple of ints, the maximum is selected over multiple axes, instead of a single axis or all the axes as before. | Named `dim`, behavior same as `torch.sum` (pytorch#29137) | | `out`: ndarray, optional. Alternative output array in which to place the result. Must be of the same shape and buffer length as the expected output. | Same | | `keepdims`: bool, optional. If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array. | implemented as `keepdim` | | `initial`: scalar, optional. The minimum value of an output element. Must be present to allow computation on empty slice. | Not implemented in this PR. Better to implement for all reductions in the future. | | `where`: array_like of bool, optional. Elements to compare for the maximum. | Not implemented in this PR. Better to implement for all reductions in the future. | **Note from numpy:** > NaN values are propagated, that is if at least one item is NaN, the corresponding max value will be NaN as well. To ignore NaN values (MATLAB behavior), please use nanmax. PyTorch has the same behavior Pull Request resolved: pytorch#43092 Reviewed By: ngimel Differential Revision: D23360705 Pulled By: mruberry fbshipit-source-id: 5bdeb08a2465836764a5a6fc1a6cc370ae1ec09d
Summary: Pull Request resolved: pytorch#44001 This is to align with the naming in numpy and in pytorch#43092 Test Plan: ``` python test/test_torch.py TestTorchDeviceTypeCPU.test_aminmax_cpu_float32 python test/test_torch.py TestTorchDeviceTypeCUDA.test_aminmax_cuda_float32 ``` Imported from OSS Reviewed By: jerryzh168 Differential Revision: D23465298 fbshipit-source-id: b599035507156cefa53942db05f93242a21c8d06
Add a max/min operator that only return values.
Some important decision to discuss
Numpy compatibility
Reference: https://numpy.org/doc/stable/reference/generated/numpy.amax.html
axis: None or int or tuple of ints, optional. Axis or axes along which to operate. By default, flattened input is used. If this is a tuple of ints, the maximum is selected over multiple axes, instead of a single axis or all the axes as before.dim, behavior same astorch.sum(#29137)out: ndarray, optional. Alternative output array in which to place the result. Must be of the same shape and buffer length as the expected output.keepdims: bool, optional. If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.keepdiminitial: scalar, optional. The minimum value of an output element. Must be present to allow computation on empty slice.where: array_like of bool, optional. Elements to compare for the maximum.Note from numpy:
PyTorch has the same behavior