The rule of thumb is that inplace works unless it does not. 
So the two things that usually break are

you move a leaf tensor into the graph (if you remove the cloning in above example - and cloning helps),
when a isn’t a leaf and whatever computed a wants to have a to compute the backward (cloning helps here, too).

So the conventional wisdom is to not use inplace ops, but looking deeper, it can usually be made to work. I always joke to write a non-deep-learning PyTorch book with @ptrblck where we would have a section on inplace ops.
Best regard
Thomas