Modify subset of a tensor


I have a 2d tensor W and 2 boolean masks that select the wanted rows and columns of a tensor. For example:
W[row_mask][:, column mask]
returns the tensor subset of interest. I want to modify these elements (for example, add 1 to each). However, doing something like:
W[row_mask][:, column mask] += 1
leaves the W tensor unchanged. Is there a way I can modify only a subset of a tensor, selected by rows and columns?

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.