Skip to content

Commit

Permalink
DOC: add note for torch.clamp() special case min > max See #45664 (#5…
Browse files Browse the repository at this point in the history
…6367)

Summary:
Fixes #45664

This PR adds a note to the documentation for `torch.clamp()` to alert users to a special case: If `min` is greater than `max`, all values are set to the `max` value.

Also, an example was added after the first code example. And this one is referenced in the note.

Pull Request resolved: #56367

Reviewed By: ezyang

Differential Revision: D27960553

Pulled By: mruberry

fbshipit-source-id: 9dc6016ccacebe87c809a0dd9f557b4aea0ae6f5
  • Loading branch information
xamm authored and facebook-github-bot committed Apr 25, 2021
1 parent 45692fb commit 6e5ce56
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch/_torch_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1901,6 +1901,10 @@ def merge_dicts(*dicts):
y_i = \min(\max(x_i, \text{min\_value}), \text{max\_value})
""" + r"""
.. note::
If :attr:`min` is greater than :attr:`max` :func:`torch.clamp(..., min, max) <torch.clamp>`
sets all elements in :attr:`input` to the value of :attr:`max`.
Args:
{input}
min (Number): lower-bound of the range to be clamped to
Expand Down

0 comments on commit 6e5ce56

Please sign in to comment.