I want to quantize the values of avtivations and weights of each layer into 4bit or 8bit. So i used a method to generate the values after quantization to replace the old full precision values. The values are indeed modified because this is what i want.
However, there is always
“RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation”
I know there is some internal mechainism to track the correctness for computing of gradient. I already tried "with torch.no_grad(): " and lowered the version of pytorch to 0.2 but such tracking still exist. Can i ask how to disable such feature and change the values in gradient computing freely?
And this example is similiar to what i have tried with torch.no_grad() method, the execution of program still warn “RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation”
Thanks for your reply, I used data = new_data when i got the runtime error. I have not tried data[:] = new_data yet. Can i ask why add [:] will make a difference?
Sorry for reply late. I have tried using [:]
I tried out[0][0][0][0][:] where out is a 4 dimension array. all index set to 0 just as an example here.
But i got error
out[0][0][0][0][:] = 1
IndexError: dimension specified as 0 but tensor has no dimensions
So i tried to modify the whole tensor with out[:] = torch.rand(out.size())
I found it is still
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: