Skip to content

Incorrect error message for advanced indexing cuda tensor #5559

@tejaskhot

Description

@tejaskhot
import torch
from torch.autograd import Variable
print(torch.__version__)

x = Variable(torch.rand(2,3,4).cuda())
y = torch.arange(0,3).type(torch.cuda.LongTensor)
z = torch.arange(0,3).type(torch.LongTensor)

print(x[:,y]) # works
print(x[:,z]) # does not work

In the latest pytorch versions 0.4.0a0+f8439c2 and 0.4.0a0+66547ca the error message for last line is:

RuntimeError: Expected object of type Variable[torch.LongTensor] but found type Variable[torch.cuda.LongTensor] for argument #1 'other'

which is exactly the opposite of what's supposed to work. Also, it is showing the wrong type for z in the message there.
This was not a problem in pytorch version 0.2.0_3 where the error message is:

TypeError: indexing a tensor with an object of type torch.LongTensor. The only supported types are integers, slices, numpy scalars and torch.cuda.LongTensor or torch.cuda.ByteTensor as the only argument.

Metadata

Metadata

Assignees

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