Closed
[Documentation|文档反馈]: [aclnnIsPosInf] 资料 self 数据类型表与头文件/实现支持面不一致(多列 DOUBLE,漏列 6 种整型与 BOOL) #4354
liuhanwen8Add on  17 days agoClosed at  13 days ago
liuhanwen8
liuhanwen8
17 days ago Create

现象

一句话结论:aclnnIsPosInf 的资料把 self 的数据类型写成「FLOAT、FLOAT16、DOUBLE、BFLOAT16」,但头文件与实现的 910B 白名单里都没有 DOUBLE ——
按资料写 fp64 的调用在第一段就返回 161002;同时资料漏列了实现实际接受的 6 种整型/BOOL。

真机对照(Ascend 910B3 / CANN 9.2.0,同一份探针):

输入 第一段 第二段 输出 说明
self=fp64[4] 161002 未执行 — 按资料 :79 应放行
self=int32[4] 0 0 全 0(正确) 资料未列,实际可用;self=fp32[4] 同形为对照组
self=bool[4] 0 0 全 0(正确) 资料 :79 未列,实际可用

期望

引资料原文(math/is_pos_inf/docs/aclnnIsPosInf.md,章节「aclnnIsPosInfGetWorkspaceSize → 参数说明」):
「FLOAT、FLOAT16、DOUBLE、BFLOAT16」 →
因此 self 传 fp64 时应当被接受并正常计算,不应在第一段返回 161002。

同时该表应与头文件 op_api/aclnn_isposinf.h:48-49、实现 op_api/aclnn_isposinf.cpp:39-42 的
910B 白名单逐项一致;后两处都写的是 9 种(含 INT32/INT64/INT16/INT8/UINT8/BOOL,无 DOUBLE)。

环境

  • 硬件:Atlas A2(Ascend 910B3),npu-smi 26.1.1
  • CANN:9.2.0,Linux aarch64,g++ 11.4.0,torch 2.12.0+cpu / torch_npu 2.12.0
  • 仓库与提交:cann/ops-math 365f17f(master,稀疏检出 math/is_pos_inf)
  • 复现日期:2026-10-31

复现步骤

  1. 保存下方脚本为 repro.py
  2. 在 cann/ops-math 仓根执行 python3 repro.py --repo-root .
  3. 观察输出:应打印两行 [DEFECT],退出码 1

真机侧附证(可选):probe_isposinf_contract.cpp 里 self=fp64[4] 返回 161002、self=int32[4] 返回 0。

复现脚本

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""aclnnIsPosInf 资料 dtype 表与头文件/实现支持面不一致(条目 2.2-07)。"""
import os
import re
import sys

DOC = "math/is_pos_inf/docs/aclnnIsPosInf.md"
HDR = "math/is_pos_inf/op_api/aclnn_isposinf.h"
IMPL = "math/is_pos_inf/op_api/aclnn_isposinf.cpp"
INTS = ("INT32", "INT64", "INT16", "INT8", "UINT8", "BOOL")


def main():
    root = sys.argv[sys.argv.index("--repo-root") + 1] if "--repo-root" in sys.argv else "."
    txt = {}
    for name in (DOC, HDR, IMPL):
        path = os.path.join(root, name)
        if not os.path.isfile(path):
            print("[SKIP] 缺文件:%s" % name)
            return 2
        txt[name] = open(path, encoding="utf-8", errors="replace").read()

    m = re.search(r"<td>(FLOAT[^<]*)</td>", txt[DOC])
    doc_dt = (m.group(1) if m else "").strip()
    hdr = re.search(r"@param \[in\] self:(.*?)(?:\n \*\s*@|\*/)", txt[HDR], re.S).group(1)
    impl = re.search(r"ASCEND910B_DTYPE_SUPPORT_LIST\s*=\s*\{(.*?)\};", txt[IMPL], re.S).group(1)

    print("资料       dtype = %s" % doc_dt)
    print("头文件     DOUBLE=%s  整型/BOOL=%d 种" % ("DOUBLE" in hdr, sum(n in hdr for n in INTS)))
    print("实现白名单 DOUBLE=%s  整型/BOOL=%d 种"
          % ("DT_DOUBLE" in impl, sum("DT_" + n in impl for n in INTS)))

    bad = 0
    if "DOUBLE" in doc_dt and "DOUBLE" not in hdr and "DT_DOUBLE" not in impl:
        print("[DEFECT] 资料列了 DOUBLE,头文件与实现的 910B 白名单都没有 → "
              "按资料写 fp64 的调用在第一段即被 161002 拒绝")
        bad += 1
    if all(n in hdr for n in INTS) and all("DT_" + n in impl for n in INTS) \
            and not any(n in doc_dt for n in INTS):
        print("[DEFECT] 头文件与实现都接受 %s,资料只列 %d 种浮点 → 漏列 6 种实际支持的 dtype"
              % ("/".join(INTS), len(doc_dt.split("、"))))
        bad += 1
    if not bad:
        print("[OK] 资料 dtype 表与头文件/实现一致")
        return 0
    return 1


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

实测输出(退出码 1):

资料       dtype = FLOAT、FLOAT16、DOUBLE、BFLOAT16
头文件     DOUBLE=False  整型/BOOL=6 种
实现白名单 DOUBLE=False  整型/BOOL=6 种
[DEFECT] 资料列了 DOUBLE,头文件与实现的 910B 白名单都没有 → 按资料写 fp64 的调用在第一段即被 161002 拒绝
[DEFECT] 头文件与实现都接受 INT32/INT64/INT16/INT8/UINT8/BOOL,资料只列 4 种浮点 → 漏列 6 种实际支持的 dtype

原文片段(math/is_pos_inf/docs/aclnnIsPosInf.md:79,逐字复制):

      <td>FLOAT、FLOAT16、DOUBLE、BFLOAT16</td>

影响

  • 按资料写 fp64 的调用在 910B3 上直接失败(161002),无 workaround:CheckDtypeValid 是第一段第一道校验,先于任何 cast。
  • 反向同样有害:资料没写 INT32/INT64/INT16/INT8/UINT8/BOOL,用户不会想到这些类型可用,能力被埋没。
  • 安装包侧一致:.../kernel/ascend910b/ops_legacy/is_pos_inf/ 下只有 float16/float32/bfloat16 三个 kernel json,无 double。

建议

优先改资料 math/is_pos_inf/docs/aclnnIsPosInf.md:79:删掉 DOUBLE,补上 INT32、INT64、INT16、INT8、UINT8、BOOL,与头文件 op_api/aclnn_isposinf.h:48-49 对齐。
若产品确实要支持 DOUBLE,则需在 op_api/aclnn_isposinf.cpp:39-42 与 op_host/is_pos_inf_def.cpp 同步补 DT_DOUBLE 及对应 kernel 二进制 —— 仓内三处只有资料一份写 DOUBLE,按少数服从多数应先改资料。

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

您好,感谢反馈!

按您注明的 ops-math 提交 365f17f0302ed5da125337d712924984e34ed892 核查,self 类型表确有错列和漏列。A2 的实际白名单为 FLOAT、FLOAT16、BFLOAT16、INT32、INT64、INT16、INT8、UINT8、BOOL,不含 DOUBLE,且与接口头文件一致。DOUBLE 会在第一阶段的 dtype 检查中被拒绝并返回 161002,与您报告的结果相符。

整型和 BOOL 的支持也有明确实现:第一阶段对这些有界类型生成全 false 结果,随后拷贝到输出;因此它们无需单独的 IsPosInf 整型计算 kernel。输出仍要求 BOOL,shape 与 self 一致。

可行的修订方向是删除文档中的 DOUBLE,补齐上述五种整型和 BOOL,并保留产品差异:310P 对应的 Atlas 推理系列分支不支持 BFLOAT16。这样可以准确描述现有 API 支持范围;新增 DOUBLE 能力需要另行评估实现支持。我们会继续跟踪类型表与接口定义的对齐。

likedislike
陈思陈思Collaborators
17 days ago Assign chen_0715 as responsible person
陈思陈思Collaborators
17 days ago Added label: pending-confirmation
陈思陈思Collaborators
15 days ago Removed label: pending-confirmation
CchenyifengCollaborators
14 days ago Assign m0_55003149 as responsible person
CchenyifengCollaborators
14 days ago Removed responsible person chen_0715
CANN-robotCANN-robotCollaborators
13 days ago Close issue
CANN-robotCANN-robotCollaborators
13 days ago Added label: resolved