Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update _torch_docs.py to Fix torch.bernoulli() #152104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ILCSFNO
Copy link
Contributor

@ILCSFNO ILCSFNO commented Apr 24, 2025

Fixes #152095
@malfet Wondering whether to fix signature that from:

@overload
def bernoulli(input: Tensor, p: _float, *, generator: Optional[Generator] = None) -> Tensor: 

to

@overload
def bernoulli(input: Tensor, p: _float, *, generator: Optional[Generator] = None, out: Optional[Tensor] = None) -> Tensor: 

Or just merge them two to:

@overload
def bernoulli(input: Tensor, p: _float = None, *, generator: Optional[Generator] = None, out: Optional[Tensor] = None) -> Tensor: 

which can cover the original both signatures.

Copy link

pytorch-bot bot commented Apr 24, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/152104

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 3 New Failures

As of commit 29eee38 with merge base d743a7b (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@pytorch-bot pytorch-bot bot added the release notes: python_frontend python frontend release notes category label Apr 24, 2025
Comment on lines +1411 to +1412
p (float): should be a scalar containing probabilities to be used
for drawing the binary random number.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy and changed according to:

add_docstr_all(
"bernoulli_",
r"""
bernoulli_(p=0.5, *, generator=None) -> Tensor
Fills each location of :attr:`self` with an independent sample from
:math:`\text{Bernoulli}(\texttt{p})`. :attr:`self` can have integral
``dtype``.
:attr:`p` should either be a scalar or tensor containing probabilities to be
used for drawing the binary random number.
If it is a tensor, the :math:`\text{i}^{th}` element of :attr:`self` tensor
will be set to a value sampled from
:math:`\text{Bernoulli}(\texttt{p\_tensor[i]})`. In this case `p` must have
floating point ``dtype``.
See also :meth:`~Tensor.bernoulli` and :func:`torch.bernoulli`
""",
)

@jerryzh168 jerryzh168 requested a review from malfet April 28, 2025 18:24
@jerryzh168 jerryzh168 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open source release notes: python_frontend python frontend release notes category triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

To fix inconsistency between signature and doc on torch.bernoulli()
3 participants