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): ...@@ -84,8 +84,7 @@ def to_tensor(pic):
img = img.view(pic.size[1], pic.size[0], len(pic.getbands())) img = img.view(pic.size[1], pic.size[0], len(pic.getbands()))
# put it from HWC to CHW format # put it from HWC to CHW format
# yikes, this transpose takes 80% of the loading time/CPU img = img.permute((2, 0, 1)).contiguous()
img = img.transpose(0, 1).transpose(0, 2).contiguous()
if isinstance(img, torch.ByteTensor): if isinstance(img, torch.ByteTensor):
return img.float().div(255) return img.float().div(255)
else: 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