Closed
[Documentation|文档反馈]: aclnnInplaceFloorDivide 资料未声明「selfRef 的 shape 须等于广播结果」(按资料构造即 161002) #4130
liuhanwen8Add on 17 days agoClosed at 4 days ago
17 days ago Added label: documentation
xujiachen8
17 days ago Comments:
17 days ago Comments:
您好,感谢反馈及三个广播用例的对照!
问题分析
核对 cann/ops-math master b08e885e7fac370203a51904fd0680523b9a9205,原地接口参数表只写 selfRef 与 other 满足广播关系,错误码表也只描述“无法做 broadcast”,没有说明广播结果必须保持 selfRef 原有形状,这一资料缺项可以确认。参数与错误码
实现中的 CheckInplace 分两步检查:先确认两输入可广播,再要求广播结果的 shape 等于 selfRef。后者保证结果能够按原有张量形状写回。因此 [1,3] 与 [2,3] 虽可广播为 [2,3],仍会在第二项检查返回 ACLNN_ERR_PARAM_INVALID;反过来 selfRef 为 [2,3]、other 为 [1,3] 才满足这项原地约束。这与您在 A2 / CANN 9.2.0 提供的返回码一致。原地检查
该 shape 不匹配分支的日志标识确实使用 ACLNN_ERR_PARAM_NULLPTR,但函数实际返回的是 ACLNN_ERR_PARAM_INVALID,两者需要分别看待,不能将日志标识当作接口返回码。
处理方向
可考虑在 selfRef 使用说明及错误码表中明确补充“广播结果的 shape 必须等于 selfRef 的 shape”,并将这一分支的日志标识与实际参数错误含义对齐。已有广播检查有其原地写回约束,不宜为满足较简略的文字而允许 selfRef 自动扩形。我们会继续核对资料与诊断信息的一致性。


17 days ago Assign sun-yibo1 as responsible person
17 days ago Added label: pending-confirmation
17 days ago Removed label: pending-confirmation
16 days ago Assign chen_0715 as responsible person
16 days ago Removed responsible person sun-yibo1
16 days ago Added label: pending-confirmation
15 days ago Assign gcw_SUaZx3UQ as responsible person
15 days ago Removed responsible person chen_0715
11 days ago Associated pull request
4 days ago Close issue
4 days ago changed custom state from 进行中 to 已完成
4 days ago Added label: resolved
环境
cann/ops-mathmasterd04d2af9(git fetch后git rev-parse HEAD取得)math/floor_div/docs/aclnnFloorDivide&aclnnInplaceFloorDivide.md(共 17030 字符)现象
资料
aclnnInplaceFloorDivideGetWorkspaceSize的参数表里,selfRef的「使用说明」只写:但原地接口实际上还要求
selfRef的 shape 恰好等于 selfRef 与 other 广播之后的 shape,否则第一段返回
161002。这句话资料里没有。按资料字面构造的合法用例(
selfRef=[1,3]、other=[2,3],二者可广播)在两段式第一段就被拒。## 约束说明一节只写了「确定性计算:默认确定性实现」与「FLOAT16/BFLOAT16 精度有限」,也没有涉及原地写回的 shape 约束。
复现步骤
math/floor_div/docs/的上级);doc_assert_broadcast.py;IFD_DOC=math/floor_div/docs/aclnnFloorDivide&aclnnInplaceFloorDivide.md python3 doc_assert_broadcast.py1+[DEFECT]表示资料缺该声明)。复现脚本
import io, os, re, sys PATH = os.environ.get("IFD_DOC", "math/floor_div/docs/aclnnFloorDivide&aclnnInplaceFloorDivide.md") text = io.open(PATH, encoding="utf-8", errors="replace").read() m = re.search(r"## aclnnInplaceFloorDivideGetWorkspaceSize(.*?)(?=\n## )", text, re.S) sect = m.group(1) if m else "" flat = re.sub(r"<[^>]+>", "", sect) # 表格单元格里有 <a href=...> assert "selfRef" in flat and "broadcast" in flat, "资料措辞已变,需人工复核" assert re.search(r"shape\s*需要与\s*other\s*满足", flat), "找不到广播关系声明" pats = [r"selfRef[^。]{0,80}(等于|一致|相同)[^。]{0,40}(广播|broadcast)", r"selfRef[^。]{0,80}(广播|broadcast)[^。]{0,40}(之后|后)[^。]{0,20}(形状|shape)[^。]{0,20}(等于|一致)", r"(原地|原地写回|inplace)[^。]{0,60}(形状|shape)[^。]{0,30}(等于|一致)[^。]{0,30}(广播|broadcast)", r"(广播|broadcast)[^。]{0,30}(结果|后)[^。]{0,30}(存储|写回|容纳)[^。]{0,40}selfRef"] hit = [mm.group(0) for p in pats for mm in re.finditer(p, text, re.S)] if hit: print("[OK] 资料已声明原地约束:%s" % hit[0].replace("\n", " ")[:80]) sys.exit(0) print("[DEFECT] 资料未声明「原地接口要求 selfRef 的 shape 恰等于广播结果」," "而实现按此校验(selfRef=[1,3]/other=[2,3] 第一段返回 161002)") sys.exit(1)实测输出:
上板补充证据(C++ 两段式直调,同仓
op_api校验链):期望
在
selfRef的「使用说明」列(或## 约束说明)补一句,例如:这样调用方才能从资料判断「我能广播到更大形状吗」。
影响
[1,3]与[2,3]组合(资料允许的广播关系)传进来,第一段直接 161002,而资料没有任何一句能解释原因。
报错文案与真实原因不符,进一步增加排障成本。
建议
selfRef行补上述约束(最省事的落点);## 约束说明增一条「原地接口的 shape 约束」;CheckInplace()里该分支的OP_LOGE用的是ACLNN_ERR_PARAM_NULLPTR(math/floor_div/op_api/aclnn_floor_divide.cpp:388附近),plog 会打印「空指针」而返回码是 161002,与本条资料缺陷同源,建议一并澄清。