Closed
[Bug-Report|缺陷反馈]:bind_params处理首参数名称为"self"的算子时会将self参数剔除 #418
WuJNAdd on  21 days agoClosed at  17 days ago
WuJN
21 days ago Create

Describe the current behavior / 问题描述 (Mandatory / 必填)

算子首参数命名为self,golden调用形式如下:
image.png
预期self参数由*args或**kw接收,实际args为空(if name in name_to_value条件不满足没法append)
image.png
kw不包含"self",下面的逻辑过滤掉了
image.png
导致golden执行报错

Environment / 环境信息 (Mandatory / 必填)

950

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

python3 -m ttk aclnn -i /home/CI/run_csv/aclnnMultilabelMarginLoss/aclnnMultilabelMarginLoss_AttributeError.csv --plugin /home/CI/golden/aclnnMultilabelMarginLoss/ --dl=1 --device-whitelist=0 --xpu-perf -t aclnnMultilabelMarginLoss_L0_002

0c4a211e10e04d4ea8073f1a1fa9853f.zip

Describe the expected behavior / 预期结果 (Mandatory / 必填)

NA

FAIL | {'torch': {'status': 'FAIL', 'api': 'custom', 'error': 'Server returned 500: {"error": "AttributeError: 'NoneType' object has no attribute 'to'", "missing": null}'}}

Special notes for this issue/备注 (Optional / 选填)

likedislike
RuiWang_Collaborators
18 days ago Comments:

感谢反馈。已在当前 master(HEAD 127cec9)定位到与截图一致的根因,确认存在。

根因:

  • 按名绑定实现 bind_params(ttk/core_modules/common/xpu.py:297-366)与 golden 类形态调用的 _bind_by_name(ttk/core_modules/common/invoke.py:167-225):
    • 仅未绑定函数会跳过 self 形参(xpu.py:327-328 / invoke.py:189-190);绑定方法(类形式插件 __call__)的签名本身已无 self 形参,池中 self 名输入在签名循环里无从消费;
    • leftover 分发处显式排除 self(xpu.py:358、invoke.py:217):self 名输入既不进 **kwargs(防实例位冲突,合理),也进不了 *args(与 docstring「use *args to receive it positionally」矛盾),被整体丢弃。
  • 后果:aclnnMultilabelMarginLoss 这类首参名为 self 的算子,golden 经类形式插件绑定时收不到该输入,链路报 500 AttributeError: 'NoneType' object has no attribute 'to'。

修复方向:self 名输入按普通输入对待,经 *args 按参数序/param_order 位置送达,仅在与实例位冲突(绑定方法、未绑定 __init__ 的 **kwargs)时绕行;普通函数签名中的 self 形参仍按真实参数名绑定。当前 master 尚无该修复(git log 未见相关提交)。
环境说明:本机无 NPU 实机,无法重跑 issue 中 NPU 命令,以上为代码级核对结论。

likedislike
CANN-robotCANN-robotCollaborators
17 days ago Close issue
CANN-robotCANN-robotCollaborators
17 days ago Added label: resolved
RRuiWang_Collaborators
16 days ago Assign FishPotatoChen as responsible person