Skip to content

Commit 3d214c1

Browse files
authored
fix layer_norm with bias=None (#2134)
1 parent 0a18317 commit 3d214c1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

mindnlp/core/nn/functional.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,10 @@ def softmax(input, dim=-1, *, dtype=None):
560560
return out
561561

562562
def layer_norm(input, normalized_shape, weight=None, bias=None, eps=1e-5):
563+
if weight is None:
564+
weight = core.ones(normalized_shape, dtype=input.dtype, device=input.device)
565+
if bias is None:
566+
bias = core.zeros(normalized_shape, dtype=input.dtype, device=input.device)
563567
return execute('layer_norm_ext', input, normalized_shape, weight, bias, eps)[0]
564568

565569

0 commit comments

Comments
 (0)