Closed
[Documentation|文档反馈]: aclnnInplaceRoundDecimals 头文件 selfRef 注释漏 BFLOAT16(同文件 L82 写了,资料与白名单均支持) #4142
liuhanwen8Add on 14 days agoClosed at 3 days ago
14 days ago Added label: documentation
xujiachen8
13 days ago Comments:
13 days ago Comments:
您好,感谢反馈!核对当前 master(b08e885e7fac),同一头文件中 aclnnRoundDecimals 的输入注释已列 BFLOAT16,而 aclnnInplaceRoundDecimals 的 selfRef 注释仍遗漏该类型;原地接口资料也已将 BFLOAT16 列入参数表。
实现的 A2 支持列表包含 BF16,两个接口共用 CheckDtypeValid 和 ExecRoundDecimalsGetWorkspaceSize,原地入口仅把输入张量同时作为输出。因此本条可以明确为头文件注释漏项,与 #4121 的负 decimals 数值行为是不同问题。
一个可行调整是在 selfRef 注释中补齐 BFLOAT16,并与已有平台类型限制保持一致,避免把某一平台的支持无条件扩展到所有产品。我们会持续跟踪这一文档缺项。


13 days ago Assign jiaoyiming as responsible person
13 days ago Added label: pending-confirmation
13 days ago Removed label: pending-confirmation
3 days ago Close issue
3 days ago changed custom state from 进行中 to 已完成
3 days ago Added label: resolved
现象
结论:
math/round/op_api/aclnn_round.h里一对同源接口的 dtype 注释不一致——aclnnInplaceRoundDecimals的selfRef注释(L121)漏了BFLOAT16,而同文件aclnnRoundDecimals的self注释(L82)写了;资料参数表与源码白名单都支持 BFLOAT16。aclnnRoundDecimals.selfaclnn_round.h:82aclnnInplaceRoundDecimals.selfRefaclnn_round.h:121selfRef参数表(Inplace 段)aclnnRoundDecimals&aclnnInplaceRoundDecimals.md:274ASCEND910B_DTYPE_DTYPE_SUPPORT_LISTaclnn_round.cpp:33DT_BF16实测(A2 910B2 / CANN 9.2.0,独立 C++ 直调):bf16 输入 bits
3F00/3F80/C000/BF80(0.5, 1.0, -2.0, -1.0)→ 输出0000/3F80/C000/BF80(0, 1, -2, -1),两段接口均返回 0。同族 issue 差异:#4129 是
aclnnAffineGrid、#4118 是aclnnInplaceCosh的资料支持表;本条是aclnnInplaceRoundDecimals的头文件selfRef注释与同文件aclnnRoundDecimals注释不一致,接口与载体均不同。同接口的实现缺陷另见 #4121。期望
aclnnInplaceRoundDecimalsGetWorkspaceSize的selfRef注释应与同文件aclnnRoundDecimals的self注释、以及资料参数表 L274 一致,列出BFLOAT16。两个接口共用同一个CheckDtypeValid与同一条ExecRoundDecimalsGetWorkspaceSize路径,dtype 白名单为同一份。环境
cann/ops-mathmaster21848df4复现步骤
cann/ops-math(master)。assert_bf16.py。python3 assert_bf16.py --repo-root .。[CHECK]与末尾[DEFECT]:退出码 1 即注释不一致成立。aclnn_round.h:121补成与 L82 一致后重跑,退出码 0、输出[OK]。复现脚本
#!/usr/bin/env python3 """断言 aclnnInplaceRoundDecimals 头文件 selfRef 的 dtype 注释漏了 BFLOAT16。""" import argparse import os import sys def rd(p): return open(p, encoding="utf-8").read().splitlines() def dtype_after(lines, anchor): for i, l in enumerate(lines): if anchor in l: for j in range(i, min(i + 8, len(lines))): if "数据类型支持" in lines[j]: return j + 1, lines[j] return None, "" ap = argparse.ArgumentParser() ap.add_argument("--repo-root", default=".") root = ap.parse_args().repo_root H = os.path.join(root, "math/round/op_api/aclnn_round.h") C = os.path.join(root, "math/round/op_api/aclnn_round.cpp") M = os.path.join(root, "math/round/docs/aclnnRoundDecimals&aclnnInplaceRoundDecimals.md") for p in (H, C, M): if not os.path.exists(p): print("[SKIP] 缺文件 %s" % p) sys.exit(0) hl, cl, ml = rd(H), rd(C), rd(M) on, ot = dtype_after(hl, "const aclTensor* self;") if on is None: on, ot = dtype_after(hl, "@param [in] self") inn, it = dtype_after(hl, "@param [in] selfRef") h = next((i for i, l in enumerate(ml) if l.startswith("## aclnnInplaceRoundDecimalsGetWorkspaceSize")), 0) mdn = next((i + 1 for i in range(h, min(h + 120, len(ml))) if "FLOAT、BFLOAT16、FLOAT16、DOUBLE、INT32、INT64" in ml[i]), None) wln = next((i + 1 for i, l in enumerate(cl) if "ASCEND910B_DTYPE_DTYPE_SUPPORT_LIST" in l), None) wlok = wln is not None and "DT_BF16" in "\n".join(cl[wln - 1:wln + 6]) shared = any("CheckDtypeValid" in l for l in cl) print("[CHECK] 头文件 aclnnRoundDecimals.self L%s %s" % (on, ot.strip())) print("[CHECK] 头文件 aclnnInplaceRoundDecimals.selfRef L%s %s" % (inn, it.strip())) print("[CHECK] 资料参数表 L%s 含 BFLOAT16:%s" % (mdn, mdn is not None)) print("[CHECK] 源码白名单 L%s 含 DT_BF16:%s" % (wln, wlok)) print("[CHECK] 两接口共用 CheckDtypeValid:%s" % shared) if "BFLOAT16" in ot and "BFLOAT16" not in it and mdn and wlok and shared: print("\n[DEFECT] L%s 写 BFLOAT16、L%s 漏写;资料 L%s 与白名单 L%s 均支持,两接口共用同一 CheckDtypeValid。" % (on, inn, mdn, wln)) sys.exit(1) print("\n[OK] 无注释不一致(若已补全,本条不成立)") sys.exit(0)实测输出:
影响
按头文件注释判断能力的调用方(含 IDE 补全与头文件检索)会认为该接口不支持 bf16,从而主动规避或改用 fp32,丢掉 bf16 的带宽与精度收益。
建议
把
math/round/op_api/aclnn_round.h:121的selfRefdtype 列表补成与 L82 一致的FLOAT,BFLOAT16,FLOAT16,DOUBLE,INT32,INT64。