This depends on whether the thing you modify inplace is needed for the gradient (of the function that returned it - as here - or when you used it as input before modifying it). You have linear last which needs its output to do backward while resnet has batch norm last.
Best regards
Thomas