Improve doc for torch.add and add doc for torch.sub.#25114
Improve doc for torch.add and add doc for torch.sub.#25114xuhdev wants to merge 13 commits intogh/xuhdev/29/basefrom
Conversation
gchanan
left a comment
There was a problem hiding this comment.
Don't document this, it's considered deprecated, see https://github.com/pytorch/pytorch/blob/master/tools/autograd/deprecated.yaml.
@gchanan I'm a bit confused. What is the replacement? How would one now, for example, do the fma operation (as |
|
Doesn't: work? |
|
@gchanan I see what you meant now -- you meant not to document the first variant, is that correct? I've removed the first variant from the doc. |
Pull Request resolved: #25114
Pull Request resolved: #25114
Pull Request resolved: #25114
torch/_torch_docs.py
Outdated
| If :attr:`other` is of type FloatTensor or DoubleTensor, :attr:`alpha` must be | ||
| a real number, otherwise it should be an integer. | ||
| The category (floating point, integer, or Boolean) of :attr:`alpha` must match | ||
| that of the result of addition between :attr:`input` and :attr:`other`. |
There was a problem hiding this comment.
This isn't true. the following (integer alpha, float result) works for me on master:
import torch
x = torch.randn(3, 3)
y = torch.randn(3, 3)
torch.add(x, y, alpha=1)
There was a problem hiding this comment.
I would change this to say the following:
If the result of the addition between :attr:`input` and :attr:`other` is:
- floating point, :attr:`alpha` can be `float` or `int`
- integral, :attr:`alpha` must be `int`
- boolean, :attr:`alpha` can be `int` or `bool.
There was a problem hiding this comment.
Thanks, I reworded a bit and updated this PR.
zou3519
left a comment
There was a problem hiding this comment.
"the category (floating point, integer, or Boolean) of :attr:alpha must match
a real number, otherwise it should be an integer. that of the result of addition between :attr:input and :attr:other." is wrong, let's reword it.
Pull Request resolved: #25114 [ghstack-poisoned]
|
Of course, if you can cherry-pick the add and sub part of #27501 into master, I think this can be closed |
My PR on the 1.3 branch conflicts with master, so probably easier to land this one than to cherry pick that one. |
Stack from ghstack:
Pull Request resolved: #25114