Solved by ptrblck in post #2 
              
              
                kY0 and kX0 are expanded tensors and as the error message suggest, you could need to clone them before applying inplace operations. 
Did you try to use the suggested operation? 
kx = torch.linspace(-64, 63, 128)
kY0, kX0 = torch.meshgrid(kx, kx)
kX0 = kX0.contiguous()
kX0 *= 0.001
kY0 = kY0.clone()
…