Hi,
The error happens because you’re trying to do an inplace operation on a Tensor that has overlapping memory (created by the expand).
In the first case, this does not happen because the + a actually creates a new Tensor of the size of a and so the expand_as() does nothing in this case.