Hi! I’m running a memory-intensive code and I want to save memory as much as possible. If I have multiple convolutional layers:
x = self.conv1(x)
x = self.conv2(x)
x = self.conv3(x)
…
the fact that I’m using the same variable name “x” doesn’t help here, because they’re all kept in PyTorch’s graph. So the block of code above is no different that this block?:
x1 = self.conv1(x)
x2 = self.conv2(x)
x3 = self.conv3(x)
…
If that’s the case, can I save memory by doing this?:
x = self.conv3(self.conv2(self.conv1(x)))
or does this occupy almost the same amount of memory?
I would appreciate your help!