Closed
[Documentation|文档反馈]: aclnnFlip 文档与头文件 dtype 表漏 UINT16/UINT32/UINT64(REGBASE 白名单含且设备实测全对) #8934
liuhanwen8Add on 4 days agoClosed at 4 days ago
4 days ago Added label: bug-report
4 days ago Associated pull request
yuning_chen
4 days ago Comments:
4 days ago Comments:
问题成立,文档与头文件/实现不一致。建议以实际行为为准收敛资料(dtype 表、约束、错误码三处),中英文同一 PR 一起改,并顺手核对同族算子是否有同类漂移。
本条:aclnnFlip 文档与头文件 dtype 表漏 UINT16/UINT32/UINT64。注意:责任田表里没有 Flip 行,我先回复不指派,等确认归属后再落人。


4 days ago Assign yue-ma as responsible person
yuning_chen
4 days ago Comments:
4 days ago Comments:
您好,问题已收到,当前 @yue-ma 正在处理中。


4 days ago Assign xingtaowu as responsible person
4 days ago Removed responsible person yue-ma
4 days ago Deleted associated pull request: docs: add missing UINT16/UINT32/UINT64 to aclnnFlip dtype tables
4 days ago Deleted associated pull request: docs: add missing UINT16/UINT32/UINT64 to aclnnFlip dtype tables
4 days ago changed custom state from 待办的 to 已解决
4 days ago Close issue
4 days ago Added label: resolved
现象
aclnnFlip(算子ReverseV2)的资料docs/aclnnFlip.md:87把self数据类型列为 12 种,不含UINT16/UINT32/UINT64(公开头文件aclnn_flip.h同样未列,grep -c UINT16= 0);而同仓实现侧op_api/aclnn_flip.cpp:41-46的REGBASE_DTYPE_SUPPORT_LIST(Ascend 950 系列实走,见:53的IsRegbase分支)含这三种,设备实测也能正确翻转。docs/aclnnFlip.md:87op_api/aclnn_flip.cpp:41-46期望
资料
:87的列表应补入UINT16、UINT32、UINT64,与aclnn_flip.cpp:41-46白名单及实测一致。该表全产品共用(无按产品分段),故对 950 成立。根因
REGBASE_DTYPE_SUPPORT_LIST引入三种无符号整型时(与DT_INT8/UINT8/INT16同批),只更新了op_api白名单与 OpDef,未同步资料参数表。此类「int 有列、对应 uint 未列」的成对遗漏在index/下另有同类(gather_v2的UINT16)。环境
25.7.rc1;日期 2026-11-17cann/ops-nn955fa5c92246c4851530034c798e7694412bca8f(git ls-remote与 fetch 后本地HEAD一致);该提交下aclnnFlip.md=f7be4510、aclnn_flip.cpp=f511ae7c(与前基线7a2786b4相同,未变动)grep -c UINT16对docs/aclnnFlip.md与op_api/aclnn_flip.h均为 0复现步骤
repro.cpp,按文件首注释编译(需 CANN 9.3.0 及以上),然后./repro—— 6 种 dtype 逐个跑两段式接口(self=[16]、dims={0}),判断「两段返回 / 哨兵残留 / 是否逐元素等于翻转 golden」;观察int16/int32/int64(资料已列)与uint16/uint32/uint64(资料未列)全部0/0且翻转全对。复现脚本
// repro.cpp — aclnnFlip dtype 契约实测 // build: g++ -O2 -std=c++17 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -I$ASCEND_HOME_PATH/include/aclnn -I$ASCEND_HOME_PATH/include/aclnnop -L$ASCEND_HOME_PATH/lib64 -lopapi_cv -lopapi -lnnopbase -lascendcl // 【缺陷组】uint16/32/64:资料 :87 未列,REGBASE 白名单含且实测翻转全对;【对照组】int16/32/64(资料已列)应全对 #include <cstdio> #include <cstring> #include <vector> #include "acl/acl.h" #include "aclnn/acl_meta.h" #include "aclnn_flip.h" struct D { const char* n; aclDataType a; int b; bool doc; }; struct R { int r1, r2, sent; bool exact; }; // 跑一次 flip(dim=0) 的结果 static R run(aclrtStream st, aclDataType dt, int b, int N) { int64_t sh[1] = {N}, dv[1] = {0}; size_t sz = (size_t)N * b; void *sD = nullptr, *oD = nullptr; aclrtMalloc(&sD, sz, ACL_MEM_MALLOC_HUGE_FIRST); aclrtMalloc(&oD, sz, ACL_MEM_MALLOC_HUGE_FIRST); std::vector<unsigned char> hs(sz), ho(sz, 0xAB); // out 预填哨兵 for (int k = 0; k < N; ++k) { long long v = k + 1; memcpy(hs.data() + (size_t)k * b, &v, b < 8 ? b : 8); } aclrtMemcpy(sD, sz, hs.data(), sz, ACL_MEMCPY_HOST_TO_DEVICE); aclrtMemcpy(oD, sz, ho.data(), sz, ACL_MEMCPY_HOST_TO_DEVICE); aclTensor *tx = aclCreateTensor(sh, 1, dt, nullptr, 0, ACL_FORMAT_ND, sh, 1, sD), *to = aclCreateTensor(sh, 1, dt, nullptr, 0, ACL_FORMAT_ND, sh, 1, oD); aclIntArray* dims = aclCreateIntArray(dv, 1); R r; r.r1 = r.r2 = -1; r.sent = -1; r.exact = false; uint64_t w = 0; aclOpExecutor* e = nullptr; r.r1 = (int)aclnnFlipGetWorkspaceSize(tx, dims, to, &w, &e); if (r.r1 == 0) { void* p = nullptr; if (w) aclrtMalloc(&p, w, ACL_MEM_MALLOC_HUGE_FIRST); r.r2 = (int)aclnnFlip(p, w, e, st); if (r.r2 == 0) { aclrtSynchronizeStream(st); std::vector<unsigned char> g(sz, 0); aclrtMemcpy(g.data(), sz, oD, sz, ACL_MEMCPY_DEVICE_TO_HOST); r.sent = 0; for (size_t i = 0; i < sz; ++i) if (g[i] == 0xAB) r.sent++; r.exact = (r.sent == 0); for (int k = 0; k < N && r.exact; ++k) if (memcmp(&g[(size_t)k*b], &hs[(size_t)(N-1-k)*b], b)) r.exact = false; } if (p) aclrtFree(p); } aclDestroyTensor(tx); aclDestroyTensor(to); aclDestroyIntArray(dims); aclrtFree(sD); aclrtFree(oD); return r; } int main() { setvbuf(stdout, nullptr, _IONBF, 0); aclInit(nullptr); aclrtSetDevice(0); aclrtStream st = nullptr; aclrtCreateStream(&st); const int N = 16; D DS[] = {{"int16", ACL_INT16, 2, true}, {"uint16", ACL_UINT16, 2, false}, {"int32", ACL_INT32, 4, true}, {"uint32", ACL_UINT32, 4, false}, {"int64", ACL_INT64, 8, true}, {"uint64", ACL_UINT64, 8, false}}; printf("%-8s %-5s %-12s %-8s %s\n", "dtype", "资料", "两段返回", "未写", "判定"); int listedOK = 0, listedN = 0, unOK = 0, unN = 0; for (auto& d : DS) { R r = run(st, d.a, d.b, N); bool pass = (r.r1 == 0 && r.r2 == 0 && r.sent == 0 && r.exact); char rb[24]; snprintf(rb, sizeof(rb), "%d/%d", r.r1, r.r2); printf("%-8s %-5s %-12s %-8d %s\n", d.n, d.doc ? "有" : "无", rb, r.sent, r.r1 != 0 ? "REJ" : (r.sent > 0 ? "*** 未写 ***" : (r.exact ? "OK(翻转全对)" : "值错"))); if (d.doc) { listedN++; listedOK += pass; } else { unN++; unOK += pass; } } printf("\n资料已列 %d/%d 通过;资料未列 %d/%d 通过\n", listedOK, listedN, unOK, unN); if (listedOK == listedN && unOK > 0) printf(">>> DOC-GAP: 资料未列的 %d 种 uint 实测通过且翻转正确(同宽 int 兄弟对照)\n" " 靶点: docs/aclnnFlip.md:87 只 12 种;aclnn_flip.cpp:41-46 REGBASE 含 3 种 uint\n", unOK); aclrtDestroyStream(st); aclrtResetDevice(0); aclFinalize(); return 0; }实测输出:
[SELFPROOF positive]资料已列的int16/int32/int64同宽对照两段0/0、残留 0、翻转逐元素正确,证明夹具与 golden(out[k]=self[N-1-k])无误。[SELFPROOF oracle]期望值来源:资料aclnnFlip.md:87dtype 列与aclnn_flip.cpp:41-46白名单原文(grep -c UINT16对资料/头文件均为 0),非自拟。[SELFPROOF canary]out 预填0xAB,六种 dtype 的 16 元素残留均为 0;uint 与 int 同宽同值域结果一致,双排除偶合。[SELFPROOF dtype]enum_source=header (acl_base_rt.h):ACL_INT16=6(:180)、ACL_UINT16=7(:181)、ACL_UINT32=8(:182)、ACL_INT32=3(:178)、ACL_INT64=9、ACL_UINT64=10。影响
使用者按资料选型时会误判
aclnnFlip不支持三种 uint:上层框架(PTA 等)若以文档为准做 dtype 能力探测,会把无符号整型输入判为不支持而提前插入 cast 降级或拒绝,损失三条已可用通路。严重性为文档级(对外契约窄于实现,不会拿到错误结果)。建议
docs/aclnnFlip.md:87的 self 数据类型列补入UINT16、UINT32、UINT64(紧随对应INT16/INT32/INT64之后,与本仓aclnn_take.h:36风格一致);out行写「与 self 一致」,无需改动。FLOAT64而其余仓多用DOUBLE,建议对齐aclnn_flip.cpp的DT_DOUBLE(纯文档用词,无行为影响)。#7145(同接口COMPLEX128被白名单放行但 OpDef 未注册、静默全 0)方向相反、对象不同:本条是白名单已含 uint 且实测可用、仅文档缺失,两者互不覆盖。