I added two more tests:

Creating a 6x3 torch.tensor using torch.rand(6,3)
Creating a 6x3 torch.tensor directly on GPU using variables
Creating a 6x3 torch.tensor direcly on GPU using constants

It seems that

Creating a torch.rand(6,3) directly on GPU is the fastest operation
However, creating a 6x3 np.array and then transfering it to GPU is yet faster than creating a 6x3 torch.tensor directly on GPU using variables or constants. This is counter intuitive.


jetsonfloat64.png1855×1022 40.7 KB
 
desktopfloat64.png1855×1022 46.6 KB