Closed
[Documentation|文档反馈]: aclnnInplaceRoundGetWorkspaceSize 错误码表缺 ACLNN_ERR_PARAM_INVALID(161002) 整类说明 #3916
liuhanwen8Add on  16 days agoClosed at  3 days ago
liuhanwen8
liuhanwen8
16 days ago Create

文档链接

  • 仓库:cann/ops-math
  • 版本:master @ 584b2ea6cbaeba684a51a74296d82d4d50ab3b0f
  • 资料:math/round/docs/aclnnRound&aclnnInplaceRound.md:284-309(## aclnnInplaceRoundGetWorkspaceSize 的「返回值」错误码表)
  • 对照:math/round/docs/aclnnRound&aclnnInplaceRound.md:142-173(## aclnnRoundGetWorkspaceSize 同名表)
锚点 维度 影响 证据等级 级别
math/round/docs/aclnnRound&aclnnInplaceRound.md:284-309 完备性/一致性 调用方按错误码表做异常分支时,无法预知 dtype/rank 违约会得到 161002,容易把它当未知错误直接抛出或吞掉 静态断言脚本 + 同族对照小节,单条可判定 P2

问题文档片段

问题描述:aclnnInplaceRoundGetWorkspaceSize 的「第一段接口完成入参校验」错误码表只列了 161001(空指针)与 561101(执行器创建失败),整类缺 ACLNN_ERR_PARAM_INVALID(161002)。而同文件 out-of-place 的 aclnnRoundGetWorkspaceSize 同名表里 161002 是存在的(rowspan=3)。Inplace 侧参数表已明确声明 selfRef 的 dtype 支持面与维度范围 0-8,违反其中任一条必然走参数校验失败路径,即 161002。

推导链:

  1. 资料 aclnnInplaceRoundGetWorkspaceSize 参数说明表(L245-252)声明:selfRef 数据类型为 BFLOAT16、FLOAT16、FLOAT32、DOUBLE、INT32、INT64,数据格式 ND,维度 0-8。这是接口自己声明的合法域。
  2. 既然声明了合法域,传入域外值(如 dtype 为 UINT8、或 rank=9)就属于「入参校验不通过」,按 ACLNN 返回码约定应返回 ACLNN_ERR_PARAM_INVALID(161002)。
  3. 同文档 ## aclnnRoundGetWorkspaceSize 的错误码表(L142-173)确实列了 161002,并用 rowspan=3 给出三条子描述:self和out的数据类型或数据格式不在支持的范围之内。/self和out的shape不一致。/self和out的dtype不一致。
  4. 但 Inplace 小节的表只有 161001 与 561101 两条,161002 整类缺失。
  5. 表头语义是「第一段接口完成入参校验,出现以下场景时报错」,即该表本身就是「校验失败时报什么」的穷举清单;少一整类会让读者认为 Inplace 在第一段接口里不产生 161002。

反向排除:

  1. 不是「Inplace 接口没有参数校验」:161001 已出现在该表中,说明校验链存在且在文档里被承认;若真的只有空指针检查,参数表就不会声明 dtype 支持面与维度 0-8。
  2. 不是「Inplace 复用 out-of-place 的错误码表、无需重复」:两个小节各自带独立的「返回值」段与独立表格(L142 与 L284),并未写「同 aclnnRoundGetWorkspaceSize」之类的指代;读者只会看自己调用的那个小节。
  3. 不是脚本解析漏读:脚本对 161002 所在行的 <td rowspan="3">161002</td> 做了标签剥离,在对照小节正确取到 161002(实测输出里 对照 aclnnRoundGetWorkspaceSize 错误码: ['161001', '161002']),说明解析逻辑能处理 rowspan,Inplace 侧确实是没写而不是没读到。
  4. 不是「161002 属于第二段接口」:两处表头均为「第一段接口完成入参校验」,同一语义域内一有一无,属不一致。

影响:调用方按文档编写错误处理分支时,会为 161001/561101 写专门分支,而对 161002 无预期。实际传入不支持的 dtype 或 rank>8 时会拿到 161002,被归入「未预期错误」直接上抛或忽略,掩盖真实的入参问题;自动化用例的错误码断言也会照文档写成不可能命中的期望值。

原文片段(Inplace 表,math/round/docs/aclnnRound&aclnnInplaceRound.md:298-307,逐字):

    <tr>
      <td>ACLNN_ERR_PARAM_NULLPTR</td>
      <td>161001</td>
      <td>传入的Tensor为空指针。</td>
    </tr>
    <tr>
      <td>ACLNN_ERR_INNER_CREATE_EXECUTOR</td>
      <td>561101</td>
      <td>内部错误,执行器创建失败。</td>
    </tr>

对照片段(out-of-place 表,math/round/docs/aclnnRound&aclnnInplaceRound.md:161-171,逐字):

    <tr>
      <td rowspan="3">ACLNN_ERR_PARAM_INVALID</td>
      <td rowspan="3">161002</td>
      <td>self和out的数据类型或数据格式不在支持的范围之内。</td>
    </tr>
    <tr>
      <td>self和out的shape不一致。</td>
    </tr>
    <tr>
      <td>self和out的dtype不一致。</td>
    </tr>

对照片段(Inplace 参数表 selfRef 行,...md:245-251,逐字):

      <td>selfRef(aclTensor*)</td>
      <td>输入/输出</td>
      <td>输入Tensor。</td>
      <td>支持空Tensor。</td>
      <td>BFLOAT16、FLOAT16、FLOAT32、DOUBLE、INT32、INT64</td>
      <td>ND</td>
      <td>0-8</td>

复现三件套:

  • 类型:静态文本断言(资料错误码表小节比对 + 同族对照小节)
  • 退出码语义:0 = 符合预期(不成立)/1 = 缺陷成立并打印 [DEFECT]/2 = 无法判定
  • 期望值:0;实测值:1

脚本全文:

#!/usr/bin/env python3
import argparse, os, re, sys

def section(text, heading):
    m = re.search(r"^##\s+%s\s*$" % re.escape(heading), text, re.M)
    if not m: return None
    rest = text[m.end():]
    m2 = re.search(r"^##\s+\S", rest, re.M)
    return rest[:m2.start()] if m2 else rest

def codes(seg):
    m = re.search(r"第一段接口完成入参校验(.*?)</table>", seg, re.S)
    if not m: return None
    out = []
    for tr in re.findall(r"<tr>(.*?)</tr>", m.group(0), re.S):
        cells = [re.sub(r"<[^>]+>", "", c).strip()
                 for c in re.findall(r"<td[^>]*>(.*?)</td>", tr, re.S)]
        if len(cells) >= 2 and re.match(r"^\d{6}$", cells[1] or ""):
            out.append(cells[1])
    return out

def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--repo", required=True)
    ap.add_argument("--file", required=True)
    ap.add_argument("--section", required=True)
    ap.add_argument("--control", default="")
    ap.add_argument("--code", required=True)
    ap.add_argument("--claim", choices=["missing", "extra"], default="missing")
    a = ap.parse_args()
    path = os.path.join(a.repo, a.file)
    if not os.path.isfile(path):
        print("[SKIP] 文件不存在: %s" % path); return 2
    text = open(path, encoding="utf-8", errors="replace").read()
    seg = section(text, a.section)
    if seg is None:
        print("[SKIP] 未找到小节 ## %s" % a.section); return 2
    rows = codes(seg)
    if not rows:
        print("[SKIP] 未能解析出错误码表(结构可能已变)"); return 2
    ctrl = []
    if a.control:
        cs = section(text, a.control)
        ctrl = codes(cs) or []
    print("文件: %s" % a.file)
    print("小节 %s 错误码: %s" % (a.section, sorted(set(rows))))
    if a.control:
        print("对照 %s 错误码: %s" % (a.control, sorted(set(ctrl))))
    hit = a.code in rows
    if a.claim == "missing":
        if hit:
            print("结论: 已包含 %s,本条不成立" % a.code); return 0
        if a.control and a.code not in ctrl:
            print("[SKIP] 对照小节也无 %s,无法判定'同族已有此处漏写'" % a.code); return 2
        print("[DEFECT] 小节缺 %s 整类说明(对照小节有 %d 条)" % (a.code, ctrl.count(a.code))); return 1
    else:
        if not hit:
            print("结论: 确实不含,本条不成立"); return 0
        print("[DEFECT] 不应含 %s 却出现" % a.code); return 1

if __name__ == "__main__":
    sys.exit(main())

实测输出:

$ python3 check_error_table.py --repo <repo> --file "math/round/docs/aclnnRound&aclnnInplaceRound.md" \
    --section aclnnInplaceRoundGetWorkspaceSize --control aclnnRoundGetWorkspaceSize \
    --code 161002 --claim missing
文件: math/round/docs/aclnnRound&aclnnInplaceRound.md
小节 aclnnInplaceRoundGetWorkspaceSize 错误码: ['161001', '561101']
对照 aclnnRoundGetWorkspaceSize 错误码: ['161001', '161002']
[DEFECT] 小节缺 161002 整类说明(对照小节有 1 条)
exit=1

存在的问题

修复建议:在 Inplace 小节的错误码表中补 161002 一行,措辞必须针对单张量 selfRef,不能照抄 out-of-place 的「self 和 out 的 shape/dtype 不一致」(Inplace 只有一个张量,结构上不存在 self/out 不一致)。建议在 561101 行之后追加:

    <tr>
      <td rowspan="2">ACLNN_ERR_PARAM_INVALID</td>
      <td rowspan="2">161002</td>
      <td>selfRef的数据类型或数据格式不在支持的范围之内。</td>
    </tr>
    <tr>
      <td>selfRef的维度大于8。</td>
    </tr>

若实现侧对 Inplace 只有一条校验(例如仅 dtype/format 而 rank 由通用链路拦截),则只补第一条,rowspan 改为 1 并去掉第二个 <tr>,以实际校验条数为准。

证据与环境:

  • 复现方式:静态断言脚本(无设备依赖,任何平台可复跑)
  • 实测返回码:1(含 [DEFECT])
  • 设备型号/CANN 版本:本条为纯文本完备性断言,未使用设备
  • 说明:本条只主张「同文档同语义的两张错误码表一有一无」,成立性由仓内文本决定;161002 具体对应几条子描述需实现侧确认,故修复建议给了「按实际校验条数补 1 或 2 条」的收敛写法。

完整文件清单:

  • math/round/docs/aclnnRound&aclnnInplaceRound.md(L284-309 错误码表,待补充)
  • 同文件 L142-173(对照表,无需修改)
likedislike
liuhanwen8liuhanwen8
16 days ago Added label: documentation
陈思
陈思Collaborators
15 days ago Comments:

您好,感谢反馈!核对 cann/ops-math@584b2ea6cbaeba684a51a74296d82d4d50ab3b0f,原地小节的错误码表确实缺少 ACLNN_ERR_PARAM_INVALID(161002),该返回码有实际校验路径支持。

aclnnInplaceRoundGetWorkspaceSize把同一个 selfRef 同时作为输入和输出调用非原地第一段,随后由 CheckParamsRound检查类型、shape 和格式。类型不在对应产品支持列表内、使用私有格式,或张量维数超过 8,均可返回 161002;八维限制位于共用形状检查,不是从参数表单独推测出来的。

可行的资料修订是在原地错误码表中增加 161002,包含“selfRef 的数据类型或数据格式不在支持范围内”和“selfRef 的维数大于 8”两项,并按两项设置合并行数。原地两端是同一张量,不需要照抄非原地的输入输出 shape 或 dtype 不一致条目;既有 161001、561101 及产品类型限制仍保留。

本项是源码与资料可直接核对的说明缺项,无需设备复现才能判断。我们会继续确认该错误码表的补齐方式。

likedislike
陈思陈思Collaborators
15 days ago Assign chensi79 as responsible person
陈思陈思Collaborators
15 days ago Added label: pending-confirmation
陈思陈思Collaborators
15 days ago Assign jiaoyiming as responsible person
陈思陈思Collaborators
15 days ago Removed responsible person chensi79
陈思陈思Collaborators
15 days ago Removed label: pending-confirmation
CANN-robotCANN-robotCollaborators
3 days ago Close issue
CANN-robotCANN-robotCollaborators
3 days ago changed custom state from 进行中 to 已完成
CANN-robotCANN-robotCollaborators
3 days ago Added label: resolved