Skip to content

layer_norm输入bias=None时报错 #2132

@yanboc

Description

@yanboc

Describe the bug/ 问题描述 (Mandatory / 必填)
A clear and concise description of what the bug is.

运行下述代码:

from mindnlp.core.executor import execute

execute('layer_norm_ext', input, normalized_shape, weight, bias, eps)[0]

bias==None 时会报错,但 bias 设置为全 0 向量时正常运行。见下图报错信息。

execute('layer_norm_ext', input, normalized_shape, weight, test_bias, eps)[0]
Tensor(shape=[1, 257, 768], dtype=Float32, value=
[[[-1.19714761e+00,  8.28569651e-01, -2.29455810e-02 ... -4.54779059e-01, -6.37458086e-01, -2.80537573e-03],
  [ 2.52148837e-01, -1.72901452e-01, -2.64418513e-01 ...  1.70840234e-01, -4.80072469e-01, -1.63292274e-01],
  [-1.96372688e-01, -6.39725327e-02,  2.53430277e-01 ...  5.98249674e-01, -1.59051001e-01, -4.74222451e-01],
  ...
  [ 8.79732907e-01, -6.23664975e-01, -5.21586359e-01 ...  5.86168885e-01, -5.99324346e-01,  3.84117328e-02],
  [-2.41721794e-01, -2.40101457e-01, -2.03653723e-01 ... -2.44932920e-01, -1.20150650e+00, -1.98367789e-01],
  [-1.10828352e+00,  9.96406019e-01, -2.67364141e-02 ... -3.45482022e-01,  6.46613002e-01,  8.25831108e-03]]], device=device(type=npu, index=0))
(Pdb) execute('layer_norm_ext', input, normalized_shape, weight, bias, eps)[0]
Segmentation fault (core dumped)
  • Hardware Environment(Ascend/GPU/CPU) / 硬件环境:

    • CPU: Kunpeng 920, NPU: 300I Duo
  • Software Environment / 软件环境 (Mandatory / 必填):

    • CANN==8.1.RC1
    • Python==3.11.6
    • MindSpore==2.6.0
    • Mindnlp==master
  • Excute Mode / 执行模式 (Mandatory / 必填)(PyNative/Graph):

    • pynative

To Reproduce / 重现步骤 (Mandatory / 必填)

+ 见问题描述

Expected behavior / 预期结果 (Mandatory / 必填)
A clear and concise description of what you expected to happen.

+ 见问题描述

Screenshots/ 日志 / 截图 (Mandatory / 必填)
If applicable, add screenshots to help explain your problem.

+ 见问题描述

Additional context / 备注 (Optional / 选填)
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions