Solved by albanD in post #2 
              
              
                Hi, 
If you don’t get an error when you backprop, then it is  
A quick check shows that it is: 
import torch

a = torch.rand(10, 10, requires_grad=True)
mask = torch.randn(10, 10).clamp(min=0).bool() # Generate random mask

out = torch.masked_select(a, mask)

out.sum().backward()
print(a.grad) # A T…