Closed
[Documentation|文档反馈]: aclnnClampMaxTensor 参数表混入无名类型行(aclOpExecutor**),按表解析会多出一个出参 #3941
liuhanwen8Add on  17 days agoClosed at  15 days ago
liuhanwen8
liuhanwen8
17 days ago Create

现象

aclnnClampMaxTensor / aclnnInplaceClampMaxTensor 的资料参数表里有两行只有类型、没有参数名:

L141  <td>(aclOpExecutor**)</td><td>输出</td><td>返回op执行器,包含了算子计算流程。</td>
L300  <td>(aclOpExecutor**)</td><td>输出</td><td>返回op执行器,包含了算子计算流程。</td>

参数表其余 7 行都是「类型 + 参数名」两段式(如 self(aclTensor*)),只有这两行不是:
名字被全角括号包住,且 aclOpExecutor** 不是业务参数,而是 aclnn 两段式接口的框架出参。

期望

参数表只列业务参数(输入/输出张量与属性)。aclOpExecutor 属于框架两段式协议
(GetWorkspaceSize(..., aclOpExecutor** executor)),不应作为参数表的「输出」行。

若要保留说明,建议放在表外的一句话(如「executor 由框架持有,调用方无需构造」),
而不是塞进参数表。

影响

  1. 按表解析会多出一个「出参」:以「首列 = 类型+参数名」为规则的解析器会把这两行
    识别成第 3 个输出。本轮自动化挖掘中,采样器据此把 (aclOpExecutor**) 当成真实张量
    传进调用,构造出的参数串是
    self=fp16[3x3x3x1]|max=fp16[3x3x3x3]|out=fp16[3x3x3x3]|(aclOpExecutor**)=int32[3x3x3x3]ND,
    用例直接非法(ret=161002)—— 白白浪费 fuzz 轮次,且很容易被误读成算子缺陷。
  2. 全角括号里的名字不是合法形参名,读文档的人无法引用它。

建议

删除这两行;或在参数表外补一句说明 executor 由框架持有。同仓另有约 19 份资料
(aclnnClamp*、aclnnTril、aclnnDiagFlat、aclnnSplitTensor、aclnnPermute、
aclnnInplaceCopy、aclnnReflectionPad*、aclnnReplicationPad* 等)含同一模式,
可批量处理。按「一个接口一条 issue」的约定,本条只针对 aclnnClampMaxTensor。

环境

  • 仓:cann/ops-math @ 584b2ea6(master,2026-10-24 fetch)
  • 资料:conversion/clip_by_value_v2/docs/aclnnClampMaxTensor&aclnnInplaceClampMaxTensor.md
  • 实测日期 2026-10-25(纯文本断言,不需要 NPU)

复现步骤

  1. 把下方脚本存为 repro_clamp_executor_row.py
  2. 运行:python3 repro_clamp_executor_row.py --repo-root <ops-math clone>
  3. 期望:rc=1 且输出含 [DEFECT];修复后应 rc=0

复现脚本

import argparse, os, re, sys

DOC = "conversion/clip_by_value_v2/docs/aclnnClampMaxTensor&aclnnInplaceClampMaxTensor.md"
ROW_RE = re.compile(r"<tr[^>]*>(.*?)</tr>", re.S | re.I)
CELL_RE = re.compile(r"<t[dh][^>]*>(.*?)</t[dh]>", re.S | re.I)
TAG_RE = re.compile(r"<[^>]+>")
NAME_RE = re.compile(r"^\s*[A-Za-z_][A-Za-z0-9_]*\s*[((][^))]+[))]")   # 对照组 CTRL:合法两段式
TYPEONLY_RE = re.compile(r"^\s*[((]\s*[A-Za-z_][A-Za-z0-9_*\s]*[))]\s*$")  # 缺陷组 DEFECT:只有类型

ap = argparse.ArgumentParser()
ap.add_argument("--repo-root", default=".")
a = ap.parse_args()
path = os.path.join(a.repo_root, DOC)
if not os.path.isfile(path):
    print("[INCONCLUSIVE] 找不到资料:%s" % path)
    sys.exit(2)
text = open(path, encoding="utf-8", errors="replace").read()

bad, good = [], 0
for m in ROW_RE.finditer(text):
    cells = [TAG_RE.sub("", c).strip() for c in CELL_RE.findall(m.group(1))]
    if not cells:
        continue
    ln = text.count("\n", 0, m.start()) + 1
    if TYPEONLY_RE.match(cells[0]):
        bad.append((ln, cells[0], cells[1] if len(cells) > 1 else ""))
    elif NAME_RE.match(cells[0]):
        good += 1

print("对照(ctrl):参数表两段式行数 = %d" % good)
if bad:
    print("[DEFECT] 参数表出现「只有类型、没有参数名」的行 %d 处:" % len(bad))
    for ln, first, role in bad:
        print("  L%d  首列=%r  该行第二列=%r" % (ln, first, role))
    print("[DEFECT] 期望:参数表只列业务参数;aclOpExecutor 由框架持有,不应作为参数行出现")
    sys.exit(1)
print("[OK] 参数表无无名类型行")

实测输出:

对照(ctrl):参数表两段式行数 = 7;
[DEFECT] 参数表出现「只有类型、没有参数名」的行 2 处:L141 首列='(aclOpExecutor**)' 该行第二列='输出';L300 同上;rc=1。

likedislike
liuhanwen8liuhanwen8
17 days ago Added label: documentation
陈思
陈思Collaborators
16 days ago Comments:

您好,感谢反馈!在 cann/ops-math@584b2ea6 中,两处首列确实只剩 (aclOpExecutor**),漏写了参数名 executor,会影响依赖“名称(类型)”格式的解析。非原地参数表、原地参数表。

不过,executor 是两个 GetWorkspaceSize 原型中真实存在的输出形参,参数表列出它本身是合理的。它返回执行器句柄,随后作为第二段接口的输入,并不是额外的输出 Tensor;文档样例也是第一段传 &executor,第二段使用得到的 executor。头文件原型、调用样例。

一个直接的修正方向是将两处补为 executor(aclOpExecutor**),并说明“返回执行器句柄,供对应第二段接口使用,无需构造 Tensor”。这样可恢复参数名与原型的一致性。若将协议参数单独分组说明,也需完整保留名称、类型和传递方式;直接删除会让参数说明缺少真实形参。

您给出的采样字符串把执行器识别成了 INT32 Tensor,这与正式原型不符;其中的 161002 仍需结合实际生成的调用判断,不能仅凭表格漏名归因为算子执行缺陷。本条可先按这两处参数名及句柄说明的文档问题处理。

likedislike
陈思陈思Collaborators
16 days ago Assign chensi79 as responsible person
陈思陈思Collaborators
16 days ago Added label: pending-confirmation
陈思陈思Collaborators
16 days ago Assign sun-yibo1 as responsible person
陈思陈思Collaborators
16 days ago Removed responsible person chensi79
陈思陈思Collaborators
16 days ago Removed label: pending-confirmation
Ccai-chengchaoCollaborators
16 days ago Associated pull request
CANN-robotCANN-robotCollaborators
15 days ago Close issue
CANN-robotCANN-robotCollaborators
15 days ago Added label: resolved