Closed
[Documentation|文档反馈]: aclnnSituGlu 错误码表 4 个子项与实测不符(561001 三子项实测 561002、out dtype 实测 161002) #7743
liuhanwen8Add on  23 days agoClosed at  18 days ago
liuhanwen8
liuhanwen8
23 days ago Create

现象

Document Link(文档链接):https://gitcode.com/cann/ops-nn/blob/master/activation/situ_glu/docs/aclnnSituGlu.md
(错误码表在「aclnnSituGluGetWorkspaceSize → 返回值」一节)

Issues Section(问题文档片段):错误码表 4 个子项里,3 个子项声明 561001、1 个声明 561002,
实测分别是 561002 与 161002(逐条见下)。

原文(错误码表,逐字复制节选):

      <td rowspan="2">ACLNN_ERR_INNER_INFERSHAPE_ERROR</td>
      <td rowspan="2">561001</td>
      <td>x或out的shape维度不在支持的范围之内。</td>
    </tr>
    <tr>
      <td>dim不在指定的取值范围内或x在dim对应维度上不能被2整除。</td>
    </tr>
    <tr>
      <td rowspan="2">ACLNN_ERR_INNER_TILING_ERROR</td>
      <td rowspan="2">561002</td>
      <td>out的数据类型与x不匹配。</td>

参数表 x 行「维度(shape)」原文:1-8

期望

Existing Issues(存在的问题):错误码表四个子项与实测返回码不符(Atlas A2 910B2 / CANN 9.2.0,aclnnSituGlu 两段式直调):

资料子项 资料声明 实测 复现用例
dim 越界([-rank, rank-1]) 561001 561002 x=fp32[2x32]、out=fp32[2x16]、dim=2(dim=-3 同)
x 在 dim 方向非偶数 561001 561002 x=fp32[2x3]、out=fp32[2x1]、dim=-1
x/out 的 shape 维度不在支持范围 561001 561002(0 维);9–25 维返回 0 且结果正确 同 rank、末轴 4/2
out 的数据类型与 x 不匹配 561002 161002 x=fp32[2x32]、out=fp16[2x16]

资料声明「dim 越界 / 奇数切分 / shape 维度越界 → 561001,out dtype 不匹配 → 561002」,实测应为「前三者 561002、最后一者 161002」,或让实现补上 infershape 校验使 561001 真正可达。原因:aclnn 单算子直调不跑 infershape,dim 范围 / %2 / out 形状都在 tiling 里判,561001 在 A2 上不可达;out dtype 不一致在参数校验阶段即被拦成 161002。同族 aclnnSituGluGrad 有过同类单(#7156)。

环境

  • 硬件/软件:Atlas A2 910B2(npu-smi 26.1.1)、CANN 9.2.0 aarch64、g++ 11.4.0
  • 仓库与提交:cann/ops-nn c46db05f5bb5155691263ea24a5f10b10547a28a,复现日期 2026-10-30

复现步骤

  1. 保存下方「复现脚本」为 repro.cpp
  2. g++ -std=c++17 -O2 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -L$ASCEND_HOME_PATH/lib64 -lascendcl -lopapi -lnnopbase && ./repro
  3. 观察四行输出:依次为 561002 / 561002 / 561002 / 161002

实测输出:

A dim=2      x=fp32[2x32] out=fp32[2x16] dim=2  -> ret_gws=561002  (资料 561001)
B dim=-3     x=fp32[2x32] out=fp32[2x16] dim=-3 -> ret_gws=561002  (资料 561001)
C odd cut    x=fp32[2x3]  out=fp32[2x1]  dim=-1 -> ret_gws=561002  (资料 561001)
D out dtype  x=fp32[2x32] out=fp16[2x16] dim=-1 -> ret_gws=161002  (资料 561002)
E rank=9     x/out 9 维(末轴 4/2)              -> ret_gws=0 ret_exec=0,结果正确(资料 1-8 维)

复现脚本

上板探针(改 dim/out dtype 即可覆盖上表各行):

#include <cstdio>
#include <vector>
#include "acl/acl.h"
#include "aclnnop/aclnn_situ_glu.h"

static void Run(const std::vector<int64_t>& xs, int64_t dim, aclDataType odt,
                const std::vector<int64_t>& os)
{
    std::vector<float> xh(64, 1.0f), oh(64, 0.0f);
    aclTensor *x = nullptr, *o = nullptr;
    void* xd = nullptr;
    void* od = nullptr;
    size_t xn = 64 * 4, on = 64 * 4;
    aclrtMalloc(&xd, xn, ACL_MEM_MALLOC_HUGE_FIRST);
    aclrtMalloc(&od, on, ACL_MEM_MALLOC_HUGE_FIRST);
    aclrtMemcpy(xd, xn, xh.data(), xn, ACL_MEMCPY_HOST_TO_DEVICE);
    aclrtMemcpy(od, on, oh.data(), on, ACL_MEMCPY_HOST_TO_DEVICE);
    std::vector<int64_t> s1(xs.size(), 1), s2(os.size(), 1);
    for (int i = (int)xs.size() - 2; i >= 0; i--) s1[i] = xs[i + 1] * s1[i + 1];
    for (int i = (int)os.size() - 2; i >= 0; i--) s2[i] = os[i + 1] * s2[i + 1];
    x = aclCreateTensor(xs.data(), xs.size(), ACL_FLOAT, s1.data(), 0, ACL_FORMAT_ND,
                        xs.data(), xs.size(), xd);
    o = aclCreateTensor(os.data(), os.size(), odt, s2.data(), 0, ACL_FORMAT_ND,
                        os.data(), os.size(), od);
    uint64_t ws = 0;
    aclOpExecutor* ex = nullptr;
    int rg = (int)aclnnSituGluGetWorkspaceSize(x, dim, 1.0, 0.0, true, o, &ws, &ex);
    printf("ret_gws=%d\n", rg);
    aclDestroyTensor(x);
    aclDestroyTensor(o);
    aclrtFree(xd);
    aclrtFree(od);
}

int main()
{
    aclInit(nullptr);
    aclrtSetDevice(0);
    Run({2, 32}, 2, ACL_FLOAT, {2, 16});    // A 期望 561001
    Run({2, 32}, -3, ACL_FLOAT, {2, 16});   // B 期望 561001
    Run({2, 3}, -1, ACL_FLOAT, {2, 1});     // C 期望 561001
    Run({2, 32}, -1, ACL_FLOAT16, {2, 16}); // D 期望 561002
    aclFinalize();
    return 0;
}

编译:g++ -std=c++17 -O2 repro.cpp -o repro -I$ASCEND_HOME_PATH/include -L$ASCEND_HOME_PATH/lib64 -lascendcl -lopapi -lnnopbase

影响

调用方按资料写错误分支会对不上(把参数错误当内部故障排查),且 561001 整类在 A2 上不可达,判据形同空条款。

建议

以实测码订正错误码表(三个 561001 子项改 561002、out dtype 子项改 161002),或补齐 infershape 让 561001 可达;x/out 维度支持面(实测 1–25 维可用)一并与实际对齐。

likedislike
liuhanwen8liuhanwen8
23 days ago Added label: documentation
yuning_chenyuning_chenCollaborators
23 days ago Assign east_yang as responsible person
yuning_chen
yuning_chenCollaborators
23 days ago Comments:

初步分析

感谢反馈。

现象理解:aclnnSituGlu 错误码表子项与实际可触发错误不完全对齐(文档反馈)。
当前判断:初步判断,待复现确认。资料错误码覆盖可能不足或表述过宽/过窄。
涉及范围:activation/situ_glu 文档错误码表。
下一步:对照实现补齐/修订错误码表子项。

likedislike
yuning_chen
yuning_chenCollaborators
23 days ago Comments:

您好,该问题已收到,当前问题 @east_yang 正在处理中

likedislike
east_yang
east_yangCollaborators
19 days ago Comments:

/unassign @east_yang

likedislike
CANN-robotCANN-robotCollaborators
19 days ago Removed responsible person east_yang
east_yang
east_yangCollaborators
19 days ago Comments:
likedislike
CANN-robotCANN-robotCollaborators
19 days ago Assign fengying555682 as responsible person
fengying555682fengying555682Collaborators
18 days ago Assign guijianwei as responsible person
fengying555682fengying555682Collaborators
18 days ago Removed responsible person fengying555682
CANN-robotCANN-robotCollaborators
18 days ago Close issue
CANN-robotCANN-robotCollaborators
17 days ago Added label: resolved