Thank you soulitzer for the helpful response!
So if I understood you correctly, p.data=x returns a new tensor object p.data that holds the old tensor of p and that is then modiPreformatted textfied to be x. Then Torch imbeds this new tensor back into parameter p. And this process is inefficient as it is not an in-place modification.
What would you recommend instead of p.data = x? I cannot use the add_ function as the new value can’t be trivially written as a sum of the old value and something new.
edit: The computation of x is a bit lengthy, but I guess I can use a chain of in-place operations on my parameters like p.add_().cos_().....