I have a mask tensor which is in shape of BxCxHxW where C represents the number of masks (C=10). I also have an input tensor that is in shape of Bx3xHxW.
I wonder if I can do the following without loop to be faster…
how I can multiply my input with the mask so that I have output of shape C*Bx3xHxW.
where output[:C,...] is the output of input[0,...] times mask[0,...], and output[C:2C] is equal to input[1,...] times mask[1,...], and so on…
In the loop form it would be like:
output = torch.zeros(B*C,3,H,W)
for b in range(B):
   for i in range(C):
      output[i + b*C] = torch.mul(input[b].unsqueeze(0), 
                                     mask[b,i].unsqueeze(0).unsqueeze(0))