Browse Source

fix(mge): recover bn freeze fastpath execution

GitOrigin-RevId: 13e58c9fba
release-1.5
Megvii Engine Team 3 years ago
parent
commit
186bacfb71
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      imperative/python/megengine/module/batchnorm.py

+ 9
- 0
imperative/python/megengine/module/batchnorm.py View File

@@ -100,6 +100,15 @@ class _BatchNorm(Module):
if _bias is not None:
_bias = _bias.detach()

# fastpath excution for freeze
scale = (self.running_var + self.eps) ** (-0.5)
if _weight is not None:
scale *= _weight
bias = -self.running_mean * scale
if _bias is not None:
bias += _bias
return inp * scale + bias

if self.training and self.track_running_stats:
exponential_average_factor = self.momentum
else:


Loading…
Cancel
Save