已关闭
[Bug-Report|缺陷反馈]: aclnnNonzero.md、aclnnNonzeroV2.md示例代码需修改 #5924
renshuojian创建于  21 天前关闭于  20 天前
renshuojian
renshuojian
21 天前 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

  1. aclnnNonzero.md:示例代码存在不可达代码。main 函数在『return 0;』之后才编写『7. 释放device资源』块(aclrtFree/aclrtDestroyStream/aclrtResetDevice/aclFinalize),该块永远无法执行,device 资源与运行时不会按示例意图释放。
  2. aclnnNonzeroV2.md:示例代码中输出张量形状与数据大小设置错误。输入全为非零元素(N=8),输出shape应为{2, 8},size应为16,当前代码设置为{2, 7}和14。

Environment Information / 环境信息 (Mandatory / 必填)

950

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

跑示例代码

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  1. 将『return 0;』移到『7. 释放device资源』块之后,确保 aclrtFree(selfDeviceAddr)/aclrtFree(outDeviceAddr)/aclrtDestroyStream/aclrtResetDevice/aclFinalize 在返回前执行。
  2. std::vector<int64_t> outShape = {2, 8};
    void* selfDeviceAddr = nullptr;
    void* outDeviceAddr = nullptr;
    aclTensor* self = nullptr;
    aclTensor* out = nullptr;
    std::vector selfHostData = {0, 1, 2, 3, 4, 5, 6, 7};
    std::vector<int64_t> outHostData(16, 0);

见示例代码。

Special notes for this issue/备注 (Optional / 选填)

likedislike
renshuojian
renshuojian
21 天前 评论:

/assign

likedislike
CANN-robotCANN-robot成员
21 天前 将 rsj007 设为负责人
CANN-robotCANN-robot成员
20 天前 关闭了 issue
CANN-robotCANN-robot成员
20 天前 添加了label:resolved