Skip to content

Docs should mention that integral tensor types don't accept float scalars in methods #845

@ming-c

Description

@ming-c

Hi,
When I did something like this:

----------------code-----------------
temp = torch.add(sub_x_tensor, -1.1)

(type of 'sub_x_tensor' : torch.cuda.LongTensor)

And an error happened:
-------------screen's print---------------
TypeError: torch.add received an invalid combination of arguments - got (torch.cuda.LongTensor, float), but expected one of:

  • (torch.cuda.LongTensor source, int value)
    didn't match because some of the arguments have invalid types: (torch.cuda.LongTensor, float)
  • (torch.cuda.LongTensor mat1, torch.cuda.sparse.LongTensor mat2)
    didn't match because some of the arguments have invalid types: (torch.cuda.LongTensor, float)
  • (torch.cuda.LongTensor source, torch.cuda.LongTensor other)
    didn't match because some of the arguments have invalid types: (torch.cuda.LongTensor, float)
  • (torch.cuda.LongTensor mat1, int value, torch.cuda.sparse.LongTensor mat2)
  • (torch.cuda.LongTensor source, int value, torch.cuda.LongTensor other)

But after I checked the doc of torch.add() from http://pytorch.org/docs/torch.html#pointwise-ops, it shows that the added value can be 'float'

torch.add(input, value, out=None)

Parameters:
input (Tensor) – the input Tensor
value (float) – the number to be added to each element of input
out (Tensor, optional) – The result Tensor

I don't know what's wrong here, could someone kindly help me with this?
pytorch version:
torch==0.1.8.post1
torchvision==0.1.7

Ubuntu 14.04
python2.7

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions