Skip to content

Commit 837c682

Browse files
committed
For ConvNeXt, use timm internal LayerNorm for fast_norm in non conv_mlp mode
1 parent cac0a45 commit 837c682

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

timm/models/convnext.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
2121
from .helpers import named_apply, build_model_with_cfg, checkpoint_seq
22-
from .layers import trunc_normal_, SelectAdaptivePool2d, DropPath, ConvMlp, Mlp, LayerNorm2d,\
22+
from .layers import trunc_normal_, SelectAdaptivePool2d, DropPath, ConvMlp, Mlp, LayerNorm2d, LayerNorm, \
2323
create_conv2d, get_act_layer, make_divisible, to_ntuple
2424
from .registry import register_model
2525

@@ -161,7 +161,7 @@ def __init__(
161161
out_chs = out_chs or in_chs
162162
act_layer = get_act_layer(act_layer)
163163
if not norm_layer:
164-
norm_layer = partial(LayerNorm2d, eps=1e-6) if conv_mlp else partial(nn.LayerNorm, eps=1e-6)
164+
norm_layer = LayerNorm2d if conv_mlp else LayerNorm
165165
mlp_layer = ConvMlp if conv_mlp else Mlp
166166
self.use_conv_mlp = conv_mlp
167167

@@ -291,8 +291,8 @@ def __init__(
291291
assert output_stride in (8, 16, 32)
292292
kernel_sizes = to_ntuple(4)(kernel_sizes)
293293
if norm_layer is None:
294-
norm_layer = partial(LayerNorm2d, eps=1e-6)
295-
norm_layer_cl = norm_layer if conv_mlp else partial(nn.LayerNorm, eps=1e-6)
294+
norm_layer = LayerNorm2d
295+
norm_layer_cl = norm_layer if conv_mlp else LayerNorm
296296
else:
297297
assert conv_mlp,\
298298
'If a norm_layer is specified, conv MLP must be used so all norm expect rank-4, channels-first input'

0 commit comments

Comments
 (0)