Hello @ptrblck !
strange, but your approach with view’s is very slow.
It is faster than loop approach when I use timeit, but inference pipeline got slower in 10 times (with for loop is about 50 FPS, with views about 5 FPS)
EDIT 1:
Just added torch.cuda.synchronize()

for loop: 0.5 ms
view approach: 150 ms

I don’t understand what happens, view shouldn’t change tensor itself (from continuous to non continuous)
Do you have any thoughts?
Additional info:
I use CUDA tensor with shape [B, 3, 1024, 1024]
torch version: 1.2.0
cuda version: 10.0.130
GPU: NVIDIA QUADRO GV100
OS: linux