will loop decrease the utilization of the GPU?
In PyTorch, I have a loop in my DeepLearning Pipeline's forward part to normalize the intermediate result.
Will it run on CPU and decrease the utilization of the GPU?
some snippet as follow:
def forward(self):
    ...
    for b in range(batch_size):
        self.points[b] = self.unit_cube(self.points[b])
    ....


In Pytorch, whether an operation is done on the GPU or CPU is decided by where the data is. One of the main selling points of Pytorch is that you don't (usually) have to care where the data is; the interface is the same.
If the tensor data is on the GPU, then the operation is done on the GPU. If it's on the CPU, then the operation is done on the CPU. How you choose to organise those operations (ifs, for loops, etc) have no impact on it.
&gt;&gt;&gt; import torch
&gt;&gt;&gt; a = torch.randn(3,4,5)
&gt;&gt;&gt; b = a.cuda()
&gt;&gt;&gt; a.device
device(type='cpu')
&gt;&gt;&gt; b.device
device(type='cuda', index=0)
&gt;&gt;&gt; c = b
&gt;&gt;&gt; for x in range(10):
...   c = c * 2
... 
&gt;&gt;&gt; c.device
device(type='cuda', index=0)

In the above example, I used a for loop to double b 10 times, storing the result in c. This was all done on the GPU, and I equally could have done this on a, making it happen on the CPU.
