I have a (3, h, w) rgb tensor and a (1, h, w) tensor. The latter tensor is sparse except for some > 0 values. I would like to set all the values in the rgb tensor to 0 except for the values whose indices correspond to (h, w) indices which contain non-zero values in the latter tensor.
I would like this to occur along the channel dimension so the result is a (3, h, w) rgb tensor where each channel becomes sparse except for the indices corresponding to the (1, h, w) tensor. How can I do this most efficiently?
Thank you.