How can I speed up add/sub math operation using PyTorch?

Hello,

I am trying to speed up the PSO algorithm. I have two question, want can I do to speed up the following:

  1. The creation of the particles;
  2. The movement equation.
  1. x = (xmax - xmin)*torch.rand(pop).dtype + xmin
  1. vnext = wtorch.rand(pop).dtype + c1torch.rand(pop).dtype*(b - x) + c2torch.rand(pop).dtype(bg - x)

When I use dtype = torch.cuda.FloatTensor is slower then using dtype =torch.FloatTensor.
How can I speed up the math using the GPU?