Are these forward functions equivalent?

def forward(self, x):
    if self.dowsample:
        identity = self.downsample(x)
    else:
        identity = x
    if need_downsampling == True:
        self.downsample = do the downsampling stuff
    else:
        self.downsample = lambda x : x

def forward(self, x):
    identity = self.downsample(x)

Is one of the above more computation or memory efficient than the other?

Hi,

Yes they are.
Note that in both case, you can change self.downsample in between forwards if needed.

Thanks for your reply!