DOC: add note for torch.clamp() special case min > max See #45664 (#56367)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/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: https://github.com/pytorch/pytorch/pull/56367
Reviewed By: ezyang
Differential Revision: D27960553
Pulled By: mruberry
fbshipit-source-id: 9dc6016ccacebe87c809a0dd9f557b4aea0ae6f5
diff --git a/torch/_torch_docs.py b/torch/_torch_docs.py
index 7e704d0..6fc3ef0 100644
--- a/torch/_torch_docs.py
+++ b/torch/_torch_docs.py
@@ -1901,6 +1901,10 @@
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