It is inefficient to do selective writes with cuda, so this is not well supported, though there are masked_scatter_ and scatter_add_ ops.
But sequential operations like W += row_mask*column_mask or W = torch.where(mask, f(W), W) should be faster.