Closed
[Documentation|文档反馈]: aclnnInplaceCosh 的 A2 面 dtype 支持表漏列 BFLOAT16/COMPLEX64/COMPLEX128(910B 实测三种均可用) #4118
liuhanwen8Add on 13 days agoClosed at 7 days ago
xujiachen8
13 days ago Comments:
13 days ago Comments:
您好,感谢支持面及边界测试的反馈!本轮核对 master b08e885e7fac370203a51904fd0680523b9a9205 时,原地参数表已包含 COMPLEX64/COMPLEX128,BFLOAT16 的补充说明也已同时列出 Ascend 950、A3、A2;selfRef 使用说明已经写明支持空 Tensor。因而主贴所引的“A3 专属”和“未声明空 Tensor”,在该源码版本已不再成立,可对照这一版本确认资料更新。
实现中原地接口使用输出白名单,再复用非原地流程;空 Tensor 在参数检查后提前返回,不执行数值计算。不过,后端不能统一写成“bf16/complex 都走 AICPU”:当前 A2 的 BF16 在 AICORE 名单中,复数才走 AICPU。此前样例放行也不应替代全部产品的正式支持验证。
关于溢出为 Inf 而非饱和截断的补充,可以按目标产品、计算类型和输出转换补充数值边界说明;您给出的单点不足以确定通用阈值。本轮没有独立上板复测,尚未验证各安装版本与当前源码的对应关系,也未关闭此 Issue。


13 days ago Assign yangjinwen as responsible person
13 days ago Added label: pending-confirmation
13 days ago Removed label: pending-confirmation
13 days ago Assign focusforce as responsible person
13 days ago Removed responsible person yangjinwen
7 days ago Associated pull request
focusforce
7 days ago Comments:
7 days ago Comments:
b08e885e7fac370203a51904fd0680523b9a9205 修复了绝大部分,https://gitcode.com/cann/ops-math/pull/7044 完善了建议部分


7 days ago Close issue
7 days ago Added label: resolved
问题描述
math/cosh/docs/aclnnCosh&aclnnInplaceCosh.md的aclnnInplaceCoshGetWorkspaceSize参数表(第 255-261 行)把
selfRef的数据类型写作 FLOAT、FLOAT16、DOUBLE,第 286-288 行另用分组段声明「Atlas A3 系列产品:selfRef 数据类型额外支持 COMPLEX64、COMPLEX128、BFLOAT16」。
在 Atlas A2(910B) 上实测,这三种 dtype 第一段与第二段接口都返回 0,且结果正确
(bf16 得 0x3fc6 = 1.546875,与 cosh(1.0)=1.5430806 在 bf16 1 ulp 内;complex64/128 输出
(1.354181, 0.563421) 与公式 cosh(1)cos(0.5)=1.354181、sinh(1)sin(0.5)=0.563421 逐位一致)。也就是说资料对 A2 的支持面低报,
用户按资料会误判 A2 不可用。
实现侧不是"漏放行":
op_api/aclnn_cosh.cpp:61-66的CheckInplaceDtypeValid走GetDtypeSupportListV2(DTYPE_OUT_LIST, ...),而DTYPE_OUT_LIST明确包含 BF16/COMPLEX64/COMPLEX128;cosh.cpp的AICORE_910B_DTYPE_SUPPORT_LIST也含 BF16。同一探针里 int32 反例返回 161002,证明白名单仍然生效。因此这是资料声明面问题(documentation),不是实现缺陷。
复现脚本
#include <cstdio> #include <cstring> #include <vector> #include "acl/acl.h" #include "aclnnop/aclnn_cosh.h" static int One(aclDataType dt, const char* name) { size_t es = (dt == ACL_COMPLEX64) ? 8 : (dt == ACL_COMPLEX128) ? 16 : 2; void* dev = nullptr; aclrtMalloc(&dev, es, ACL_MEM_MALLOC_HUGE_FIRST); std::vector<uint8_t> h(es, 0); if (dt == ACL_BF16) { uint16_t v = 0x3F80; memcpy(h.data(), &v, 2); } /* 1.0 */ else if (dt == ACL_COMPLEX64) { float v[2] = {1.f, 0.5f}; memcpy(h.data(), v, 8); } else { double v[2] = {1.0, 0.5}; memcpy(h.data(), v, 16); } aclrtMemcpy(dev, es, h.data(), es, ACL_MEMCPY_HOST_TO_DEVICE); int64_t sh[1] = {1}, st[1] = {1}; aclTensor* t = aclCreateTensor(sh, 1, dt, st, 0, ACL_FORMAT_ND, sh, 1, dev); uint64_t ws = 0; aclOpExecutor* ex = nullptr; aclnnStatus r1 = aclnnInplaceCoshGetWorkspaceSize(t, &ws, &ex); aclnnStatus r2 = 12345; if (r1 == 0) { void* m = nullptr; if (ws) aclrtMalloc(&m, ws, ACL_MEM_MALLOC_HUGE_FIRST); r2 = aclnnInplaceCosh(m, ws, ex, nullptr); aclrtSynchronizeStream(nullptr); std::vector<uint8_t> b(es, 0); aclrtMemcpy(b.data(), es, dev, es, ACL_MEMCPY_DEVICE_TO_HOST); if (dt == ACL_BF16) { uint16_t v; memcpy(&v, b.data(), 2); printf("[%s] ret1=0 ret2=0 out_bf16=0x%04x\n", name, v); } else if (dt == ACL_COMPLEX64) { float v[2]; memcpy(v, b.data(), 8); printf("[%s] ret1=0 ret2=0 out=(%.6f,%.6f)\n", name, v[0], v[1]); } else { double v[2]; memcpy(v, b.data(), 16); printf("[%s] ret1=0 ret2=0 out=(%.12f,%.12f)\n", name, v[0], v[1]); } if (m) aclrtFree(m); } else { printf("[%s] ret1=%d\n", name, (int)r1); } aclDestroyTensor(t); aclrtFree(dev); return 0; } int main() { aclInit(nullptr); aclrtSetDevice(0); aclrtStream s; aclrtCreateStream(&s); One(ACL_BF16, "bf16"); One(ACL_COMPLEX64, "complex64"); One(ACL_COMPLEX128, "complex128"); One(ACL_INT32, "int32(阴性对照,资料未列且实现拒绝)"); aclrtDestroyStream(s); aclrtResetDevice(0); aclFinalize(); return 0; }编译与运行(Linux + CANN 9.2.0,Atlas A2):
实测输出
期望行为
主表(第 255-261 行)应把 BFLOAT16、COMPLEX64、COMPLEX128 列进 A2 面的数据类型,或明确写
「A2 亦支持」;建议同时在「约束说明」补一句 A2 上 bf16/complex 走 AICPU 实现,便于性能预期管理。
同接口另两条建议(可并在本单一起修)
ret1=ret2=0且输出缓冲不被写。cosh(x)超过本 dtype 上界时输出 inf(实测 fp16 x=11.78125 → 65376 有限、bf16 x=89.5 → inf、fp32 x=89.45 → inf),不是 clip 到 dtype 最大值。
环境
aclnnInplaceCoshGetWorkspaceSize/aclnnInplaceCosh