Em…this is a bit odd, since I am indeed using the module, instead of calling the function directly. And yes, most of the time the solution seems to be working. I didn’t find any problems with it when I was testing the module alone either.
The abnormal memory leak happens when I used the module in a fairly large network. Maybe it has something to do with python, or even pytorch. But still, I would recommend commenting out the relevant lines since self.output doesn’t have further reference after all.
Thanks for your attention anyway!