if return_rgb:
rgb = rgb.permute((0, 3, 1, 2))
# pytorch does not support negative slicing for the moment
# may need to look at this again because it seems to be very slow
# rgb = rgb[:, :, ::-1, :]
rgb = rgb[:, :, list(reversed(range(rgb.shape[2]))), :]
after pytorch 0.4.0, we can use following native api to do reverse, which is really faster
line 311 rasterize.py
after pytorch 0.4.0, we can use following native api to do reverse, which is really faster
And, in pytorch 1.2
just using tensor.flip() refer to https://pytorch.org/docs/1.2.0/torch.html?highlight=flip#torch.flip