When I try to use this function torch.Tensor.masked_scatter_ — PyTorch 2.1 documentation like so
local_add = input[0:67, 0:32, 160:192]
zeros = torch.zeros_like(input)
zeros[0:67, 0:32, 160:192] = local_add
mask = torch.zeros(67,32*10,32*10).bool()
#mask[0:67, 0:32,160:192] = True
#zeros = zeros.cuda()
mask = mask.cuda()
self.memory.memory_vb.masked_scatter_(mask,zeros)
I am getting an error :
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [67, 320, 320]], which is output 0 of MaskedScatterBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True)