Closed
[Bug-Report|缺陷反馈]: aclnnSituGlu 缺 rank 上限校验:rank≥26 返回 0 但输出完全未写,rank 9–25 超出资料 1–8 声明却正常执行 #7741
liuhanwen8Add on 23 days agoClosed at 18 days ago
23 days ago Added label: bug-report
23 days ago Assign east_yang as responsible person
yuning_chen
23 days ago Comments:
23 days ago Comments:
yuning_chen
23 days ago Comments:
23 days ago Comments:
您好,该问题已收到,当前问题 @east_yang 正在处理中


east_yang
19 days ago Comments:
19 days ago Comments:
/unassign @east_yang


19 days ago Removed responsible person east_yang
east_yang
19 days ago Comments:
19 days ago Comments:
/assign @guijianwei


19 days ago Assign guijianwei as responsible person
18 days ago Associated pull request
18 days ago Close issue
17 days ago Added label: resolved
现象
一句话结论:
aclnnSituGlu在x的 rank ≥ 26 时两段式接口都返回 0、workspaceSize 返回 0、输出一个字节都没写(出参保持预填金丝雀0x5A);而 rank 9–25 虽超出资料声明(1–8 维)却能算出正确结果。说明op_host侧完全没有 rank 上限校验。同一脚本、同一卡、同一进程内连续执行:
b7ccd53f725f5940b7ccd53f725f59405a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5aws=0说明 tiling 未调起(正常固定 16 MB)、kernel 未启动,但两段接口都返回ACLNN_SUCCESS。期望
资料
activation/situ_glu/docs/aclnnSituGlu.md:参数表x行「维度(shape)」写明 「1-8」;错误码表561001(ACLNN_ERR_INNER_INFERSHAPE_ERROR)写明 「x或out的shape维度不在支持的范围之内。」。因此 rank > 8 的输入应被拒并返回非 0,不应返回成功,更不应在返回成功的同时让输出保持未初始化。环境
npu-smi 26.1.1cann/ops-nnc46db05f5bb5155691263ea24a5f10b10547a28a(git fetch后 HEAD)复现步骤
repro.cppg++ -std=c++17 -O2 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -L$ASCEND_HOME_PATH/lib64 -lascendcl -lopapi -lnnopbase./reproret_gws=0 ret_exec=0且out_bytes=5a5a5a5a5a5a5a5a(出参未写);前两行为对照组main()里Run(26, stream)的参数(26–34 现象一致)复现脚本
// aclnnSituGlu rank 上限缺失复现:rank=26/28 返回成功但输出完全未写 #include <cstdio> #include <cstring> #include <vector> #include "acl/acl.h" #include "aclnnop/aclnn_situ_glu.h" static void* Dev(const std::vector<int64_t>& s, aclTensor** t, const std::vector<float>& h) { void* p = nullptr; size_t n = h.size() * sizeof(float); aclrtMalloc(&p, n ? n : 64, ACL_MEM_MALLOC_HUGE_FIRST); if (!h.empty()) aclrtMemcpy(p, n, h.data(), n, ACL_MEMCPY_HOST_TO_DEVICE); std::vector<int64_t> st(s.size(), 1); for (int i = (int)s.size() - 2; i >= 0; i--) st[i] = s[i + 1] * st[i + 1]; *t = aclCreateTensor(s.data(), s.size(), ACL_FLOAT, st.data(), 0, ACL_FORMAT_ND, s.data(), s.size(), p); return p; } static void Run(int rank, aclrtStream stream) { std::vector<int64_t> xs(rank, 1), os(rank, 1); xs[rank - 1] = 4; os[rank - 1] = 2; std::vector<float> xh = {1.0f, 2.0f, 3.0f, 4.0f}; std::vector<float> oh(2, 0.0f); aclTensor *x = nullptr, *o = nullptr; void* xd = Dev(xs, &x, xh); void* od = Dev(os, &o, oh); aclrtMemset(od, 8, 0x5A, 8); // 出参金丝雀,用于判断算子是否真的写了输出 uint64_t ws = 0; aclOpExecutor* ex = nullptr; int rg = (int)aclnnSituGluGetWorkspaceSize(x, -1, 1.0, 0.0, true, o, &ws, &ex); int re = -1; if (rg == 0) { void* wp = nullptr; if (ws > 0) aclrtMalloc(&wp, ws, ACL_MEM_MALLOC_HUGE_FIRST); re = (int)aclnnSituGlu(wp, ws, ex, stream); if (re == 0) aclrtSynchronizeStream(stream); if (wp) aclrtFree(wp); } unsigned char got[8] = {0}; aclrtMemcpy(got, 8, od, 8, ACL_MEMCPY_DEVICE_TO_HOST); printf("rank=%-2d ws=%-9llu ret_gws=%-3d ret_exec=%-3d out_bytes=", rank, (unsigned long long)ws, rg, re); for (int i = 0; i < 8; i++) printf("%02x", got[i]); printf("\n"); aclDestroyTensor(x); aclDestroyTensor(o); aclrtFree(xd); aclrtFree(od); } int main() { aclInit(nullptr); aclrtSetDevice(0); aclrtStream stream = nullptr; aclrtCreateStream(&stream); Run(8, stream); // 对照组:合法 rank Run(25, stream); // 资料未声明但可算 Run(26, stream); // 缺陷组:返回 0 但输出未写 Run(28, stream); // 缺陷组 aclrtDestroyStream(stream); aclrtResetDevice(0); aclFinalize(); return 0; }实测输出:
影响
调用方拿到
ret=0即认为算完,实际输出仍是未初始化显存(0x5A5A5A5A按 fp32 为 1.5e16),错误现场与真正原因相隔很远;workspaceSize=0是唯一旁证,但资料没说明「ws=0 代表未执行」。同一处缺失也让 rank 9–25 逃过资料 1–8 的限制并正常出数。建议
在
op_host/situ_glu_tiling.cpp::CheckAndGetXAndAttrs(或situ_glu_infershape.cpp)补 rank 上限判据,按资料取1 ≤ rank ≤ 8(若放开到gert::Shape容量至少卡 25),越界返回非 0;同时把资料错误码表 561001「shape 维度不在支持范围」与实测对码(当前不可达)。