I was running some data ffmpeg to torch (thru pipes) and noticed that I was doing something very naive. So I profiled, with single process, conversion between npuint to float32
The difference in CPU can be almost one order of magnitude. GPU tightens everything.
If anyone is interested.

  
      gist.github.com
  
  
    https://gist.github.com/xvdp/149e8c7f532ffb58f29344e5d2a1bee0 36
npuint8_torchfloat32.py
""" I was writing a dataloader from a video stream. I ran some numbers.
# in a nutshell. 
-> np.transpose() or torch.permute() is faster as uint8, no difference between torch and numpy
-> np.uint8/number results in np.float64, never do it, if anything cast as np.float32
-> convert to pytorch before converting uint8 to float32
-> contiguous() is is faster in torch than numpy
-> contiguous() is faster for torch.float32 than for torch.uint8
-> convert to CUDA in the numpy to pytorch conversion, if you can.

When loading a dataset a quite typical operation is to load the data - which may come thru numpy -
This file has been truncated. show original