Inplace matrix modification

Yes, of course, it will work. Autograd has built in checks for in-place modifications, so if it doesn’t raise an error, it will work. Otherwise .clone() might help you. One important thing is that you shouldn’t reuse the same L Variable indefinitely - its history is going to get longer and longer. You can probably reuse it for a single training sequence, but then you should do sth like repackage_hidden from the language modelling example, to allow the graph to get freed.