The line output = model(input) overwrites output in so far as it reassigns the name output to point to new data, in this case the return value of model(input). If some other code has kept a reference to the old data then python keeps the old data around. In this case the next line loss += criterion(output, target) uses the value of output to calculate the loss, and PyTorch updates the computation graph that it will use to calculate the gradients.


This sort of code shouldn’t make things slower at all given that output is just a name that points to a location of data stored in memory.


The size of the Variable is of no significance.