Skip to content

Commit

Permalink
Merge pull request Lyken17#189 from JaredFern/master
Browse files Browse the repository at this point in the history
Check for elementwise_affine used by LayerNorm
  • Loading branch information
Lyken17 committed Sep 7, 2022
2 parents 54e60ed + 9e106f3 commit 43c064a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion thop/vision/basic_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def count_normalization(m: nn.modules.batchnorm._BatchNorm, x, y):
x = x[0]
# bn is by default fused in inference
flops = calculate_norm(x.numel())
if m.affine:
if (getattr(m, 'affine', False) or getattr(m, 'elementwise_affine', False)):
flops *= 2
m.total_ops += flops

Expand Down

0 comments on commit 43c064a

Please sign in to comment.