Unverified Commit c6c3294d authored by theonekeyg's avatar theonekeyg Committed by GitHub
Browse files

Replace 2 transpose ops with 1 permute (#2018)

parent ac4b9f87
......@@ -84,8 +84,7 @@ def to_tensor(pic):
img = img.view(pic.size[1], pic.size[0], len(pic.getbands()))
# put it from HWC to CHW format
# yikes, this transpose takes 80% of the loading time/CPU
img = img.transpose(0, 1).transpose(0, 2).contiguous()
img = img.permute((2, 0, 1)).contiguous()
if isinstance(img, torch.ByteTensor):
return img.float().div(255)
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment