Skip to content

Commit

Permalink
make the tensor continuous when pass numpy object to tensor (#2483)
Browse files Browse the repository at this point in the history
Co-authored-by: vfdev <vfdev.5@gmail.com>
  • Loading branch information
dddzg and vfdev-5 authored Sep 18, 2020
1 parent 5e4a9f6 commit 7f5b2c4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchvision/transforms/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def to_tensor(pic):
if pic.ndim == 2:
pic = pic[:, :, None]

img = torch.from_numpy(pic.transpose((2, 0, 1)))
img = torch.from_numpy(pic.transpose((2, 0, 1))).contiguous()
# backward compatibility
if isinstance(img, torch.ByteTensor):
return img.float().div(255)
Expand Down

0 comments on commit 7f5b2c4

Please sign in to comment.