I guess the error is raised on this line of code:
x += res

Could you print the shapes of x and res and make sure they are equal?
In the torchvision implementation an additional downsample 8 module is used to create the expected shapes, if necessary.
PS: Don’t use the .data attribute, as it might yield unwanted side effects.