Skip to content
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

torch.Tensor.add, add_, etc. documentation doesn't match api. #33187

Closed
cpuhrsch opened this issue Feb 11, 2020 · 1 comment
Closed

torch.Tensor.add, add_, etc. documentation doesn't match api. #33187

cpuhrsch opened this issue Feb 11, 2020 · 1 comment
Labels
module: docs Related to our documentation, both in docs/ and docblocks

Comments

@cpuhrsch
Copy link
Contributor

πŸ“š Documentation

For example torch.add says

add(value) β†’ Tensor
    add(other, *, value=1) -> Tensor

    See torch.add()

But indeed the value flag doesn't exist.

>>> import torch
>>> a = torch.randn(1, 3)
>>> b = torch.randn(1, 3)
>>> a
tensor([[-0.5835, -0.1405, -1.8119]])
>>> b
tensor([[ 0.8623, -1.3727,  1.5434]])
>>> a.add(b)
tensor([[ 0.2789, -1.5132, -0.2685]])
>>> a.add(b, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: add() takes 1 positional argument but 2 were given
>>> a.add(b, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: add() takes 1 positional argument but 2 were given
>>> a.add(b, valu=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: add() got an unexpected keyword argument 'valu'
>>> a.add(b, value=2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: add() got an unexpected keyword argument 'value'
>>> a.add(b, 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: add() takes 1 positional argument but 2 were given

Instead one has to use alpha as a flag.

>>> import torch
>>> a = torch.randn(1, 3)
>>> b = torch.randn(1, 3)
>>> a.add(a, alpha=3.0)
tensor([[ 3.3190, -0.4248, -3.6609]])

There are many other instances of this in the documentation.

@cpuhrsch cpuhrsch added the module: docs Related to our documentation, both in docs/ and docblocks label Feb 11, 2020
@gchanan
Copy link
Contributor

gchanan commented Feb 11, 2020

Closing in favor of #19200.

@gchanan gchanan closed this as completed Feb 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: docs Related to our documentation, both in docs/ and docblocks
Projects
None yet
Development

No branches or pull requests

2 participants