Skip to content

Broken ByteTensor indexing of Variables (still works for Tensors) #3914

@fritzo

Description

@fritzo

In PyTorch master 0.4 709fcfd, variables cannot be indexed.

import torch
from torch.autograd import Variable
print(torch.__version__)
# 0.4.0a0+709fcfd

x = Variable(torch.Tensor([0]))
x.data[x.data == 1]
# [torch.DoubleTensor with no dimension]
x[x == 1]
# *** RuntimeError: dimension out of range (expected to be in range of [-1, 0], but got 1)

This used to work in PyTorch 0.2 f964105:

import torch
from torch.autograd import Variable
print(torch.__version__)
# 0.2.0+f964105

x = Variable(torch.Tensor([0]))
x.data[x.data == 1]
# [torch.FloatTensor with no dimension]
x[x == 1]
# Variable containing:[torch.FloatTensor with no dimension]

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