Is it possible to check if elements of a tensor are out of boundaries?
Is it possible to check if elements of a tensor are out of boundaries using torch.cuda.FloatTensor on PyTorch, GPU approach? 

Example (check limits):

for i in range(pop):
    if (x[i]&gt;xmax):
        x[i]=xmax
    elif (x[i]&lt;xmin):
        x[i]=xmin


I tried the following, but did not speed up: 

idxmax    = (x &gt; xmax) # elements that are bigger that upper limit
idxmim    = (x &lt; min)  # elements that are smaller that upper limit
x[idxmax] = xmax
x[idxmin] = xmin


If not, is it possible to do this check limits part, using only the CPU? How? 

You can get a CPU copy of tensor x, do your operations and then push the tensor to GPU memory again.

x = x.cpu()  # get the CPU copy
# do your operations
x = x.cuda() # move the object back to cuda memory

