已合并
add_example测试输入多样化 #2004
Sun创建于 3月31日
add_example测试输入多样化 #2004
已合并
Sun创建于 3月31日
Sun
Sun成员
3月31日

描述

修改add_example的输入数据,使用指定种子的随机数,增加多样化。
指定add_example输出长度,防止被大量日志淹没。
配套修改文档中展示add_example的结果的内容。

关联的Issue

https://gitcode.com/cann/ops-math/issues/1133
https://gitcode.com/cann/ops-math/issues/1094

测试

样例运行正常,不同机器上随机数结果一致

文档更新

docs/QUICKSTART.md
docs/zh/debug/cann_sim.md
docs/zh/invocation/op_invocation.md

类型标签

  • Bug修复
  • 新特性
  • 性能优化
  • 文档更新
  • 其他,请描述:
likedislike
Pull Request已成功合入, 合并人@CANN-robot
(感谢 Sun 的贡献)
SunSun成员
3月31日 创建了 pull request,commit 6c05e05f
SunSun成员
3月31日 关联了issue:[Documentation|文档反馈]: 快速入门的AddExample算子打印了两千多行一样的输出是否正常
CANN-robotCANN-robot成员
3月31日 添加了label:stat/needs-squash
CANN-robot
CANN-robot成员
3月31日 评论:

Thanks for your pull-request.
The full list of commands accepted by me can be found at here
You can get sig-info at here


PR Approval Progress

Congratulations! All modules have met the lgtm and approve requirements.

Module Approval Details

module lgtm status approve status
repo-cann/ops-math zl_hw, songkai111 (2/2) songkai111 (1/1)

💡 Tip:

  • Committer can comment /approve or /lgtm
  • Commenting /approve implies both code review (lgtm) and intent to merge (approve)

CLA Signature Pass

LuckySun, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
CANN-robotCANN-robot成员
3月31日 将zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,songkai111,llimwang,gubaocheng设为评审人
CANN-robotCANN-robot成员
3月31日 添加了label:cann-cla/yes
CANN-robotCANN-robot成员
3月31日 将zhou-qilong,wangrui_,rxtfeng,loov1,zhangzijie,songkai111,llimwang,gubaocheng设为审查人
CANN-robot
CANN-robot成员
3月31日 评论:

🔵 source code change are detected, tasks labels is removed in this pull request!

likedislike
CANN-robot
CANN-robot成员
3月31日 评论:

问题/功能描述

本次PR主要解决了CANN算子库中加法算子(AddExample)的文档和示例代码存在的演示效果不佳问题。具体包括:1)相关Markdown文档中的示例输出过于简单(如“1+1=2”),无法有效展示算子的实际计算效果;2)示例程序的输入数据单一、输出打印不清晰,导致演示效果和可读性较差。通过优化,旨在使文档和代码示例更贴近真实测试场景,便于用户理解和验证。

修改方案描述

修改方案分为两部分:1)统一更新了快速入门、算子调用和仿真工具等多个Markdown文档,将其中AddExample算子的单调示例输出替换为包含标题行和10组不同数值(含正负数)的详细输出。2)优化了加法算子示例程序的代码,改进了输入数据生成方式(如使用递增数列和可控随机数)并优化了结果打印逻辑(如增加提示、限制打印数量)。所有修改均不涉及核心算法、安全配置或构建逻辑,仅用于提升文档和示例的清晰度与实用性。

likedislike
SunSun成员
3月31日 修改了pull request 的描述
SunSun成员
3月31日 修改了pull request 的描述
Sun
Sun成员
3月31日 评论:

compile

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-running
CANN-robot
CANN-robot成员
3月31日 评论:

流水线任务触发成功
任务链接 [169847be7c8947f89666c42f80c1abcd][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>>
harmony-infer ✅ SUCCESS
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_X86_monitor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
ATK_Test_A2 ✅ SUCCESS

[2026-03-31 15:24:37]    CI执行结束

likedislike
SunSun成员
3月31日 修改了pull request 的描述
SunSun成员
3月31日 修改了pull request 的描述
CANN-robotCANN-robot成员
3月31日 添加了label:api-check-pass
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-passed
songkai111成员
3月31日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:approved
SunSun成员
3月31日 修改了pull request 的描述
zl_hw成员3月31日进行代码检视2
examples/add_example/examples/test_aclnn_add_example.cpp
已过期
@@ -10,9 +10,14 @@
1010 
1111#include <iostream>
1212#include <vector>
13+#include <numeric>
14+#include <random>
15+#include <algorithm>
1316#include "acl/acl.h"
1417#include "aclnn_add_example.h"
1518 
19+constexpr uint32_t PRINT_LENGTH = 10;
20+ 
1621#define CHECK_RET(cond, return_expr) \
1722 do { \
1823 if (!(cond)) { \
@@ -43,7 +48,8 @@ void PrintOutResult(std::vector<int64_t>& shape, void** deviceAddr,
4348 resultData.data(), resultData.size() * sizeof(resultData[0]), *deviceAddr, size * sizeof(resultData[0]),
4449 ACL_MEMCPY_DEVICE_TO_HOST);
4550 CHECK_RET(ret == ACL_SUCCESS, LOG_PRINT("copy result from device to host failed. ERROR: %d\n", ret); return);
46- for (int64_t i = 0; i < size; i++) {
zl_hw3月31日评论:

调测日志规范打印

likedislike
System
系统消息系统
3月31日 评论:
likedislike
zl_hw成员
3月31日 评论:

/lgtm

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:lgtm
CANN-robot
CANN-robot成员
3月31日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: songkai111.
Reviewers who wrote a comment of /lgtm are: songkai111, zl_hw.

likedislike
CANN-robot
CANN-robot成员
3月31日 评论:

The MR can not be merged, because of CodeReview discussion not resolved

If you want to solve this problem, you can click here to do it in the FAQs.

likedislike
SunSun成员
3月31日 update merge request[project id: 7649531, iid: 2004, commit_id: 633d81eda115b387b8f7aab88fdd0f0f1cf6ef12] virtual merging success
SunSun成员
3月31日 强制推送  2 个提交:0ba10da4-add_example测试输入多样化,98308386-文档中add_example的运行结果展示修改
SunSun成员
3月31日 update merge request[project id: 7649531, iid: 2004, commit_id: b6c7e89a81a99118dc3b4ccbb799c2d556b144e5] virtual merging success
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-passed
CANN-robot
CANN-robot成员
3月31日 评论:

The following labels are not ready.

lgtm: The label was added before the last update of the PR. Please re-add it after the latest update.

approved: The label was added before the last update of the PR. Please re-add it after the latest update.

ci-pipeline-passed: The label was added before the last update of the PR. Please re-add it after the latest update.

likedislike
CANN-robot
CANN-robot成员
3月31日 评论:

Notification

This pull request source branch has changed, so removes the following label(s): ci-pipeline-passed.

likedislike
CANN-robotCANN-robot成员
3月31日 删除了label:lgtmapproved
CANN-robot
CANN-robot成员
3月31日 评论:

🔵 source code change are detected, tasks labels is removed in this pull request!

likedislike
CANN-robot
CANN-robot成员
3月31日 评论:

Notice

New code changes of the pull request are detected and remove these labels lgtm, approved. 😳

likedislike
Sun
Sun成员
3月31日 评论:

compile

likedislike
SunSun成员
3月31日 解决了最后一个问题
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 删除了label:api-check-pass
CANN-robot
CANN-robot成员
3月31日 评论:

流水线任务触发成功
任务链接 [f41db17507884585aa237dec1d972b1a][流水线指导]

任务名称状态日志下载链接
codecheck ✅ SUCCESS >>>>>
SCA ✅ SUCCESS >>>>>
anti_virus ✅ SUCCESS >>>>>
Check_Pr ✅ SUCCESS >>>>>
Compile_Ascend_X86 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_mobile_station ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_experimental ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_single ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_X86_A5 ✅ SUCCESS >>>>> >>>>>
Compile_Ascend_ARM_A5 ✅ SUCCESS >>>>> >>>>>
pre_comment ✅ SUCCESS >>>>>
Compile_Ascend_X86_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_mobile_station_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_X86_A5_ubuntu24 ✅ SUCCESS >>>>>
harmony-infer ✅ SUCCESS
Compile_Ascend_ARM_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_experimental_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_single_ubuntu24 ✅ SUCCESS >>>>>
Compile_Ascend_ARM_A5_ubuntu24 ✅ SUCCESS >>>>>
Compile_X86_monitor ✅ SUCCESS >>>>> >>>>>
Compile_ARM_monitor ✅ SUCCESS >>>>> >>>>>
StaticCheck_codespell_check ✅ SUCCESS
StaticCheck_link_validity_check ✅ SUCCESS
StaticCheck_resource_existence_check ✅ SUCCESS
StaticCheck_tag_closed_check ✅ SUCCESS
StaticCheck_markdownlint ✅ SUCCESS
cocheck_codestyle ✅ SUCCESS
UT_Test ✅ SUCCESS
UT_Test_experimental ✅ SUCCESS
UT_Test_kernel ✅ SUCCESS
Smoke_A900_npupool ✅ SUCCESS >>>>>
API_Check ✅ SUCCESS >>>>>
ATK_Test_A2 ✅ SUCCESS

[2026-03-31 19:30:12]    CI执行结束

likedislike
CANN-robotCANN-robot成员
3月31日 添加了label:api-check-pass
CANN-robotCANN-robot成员
3月31日 删除了label:ci-pipeline-running
CANN-robotCANN-robot成员
3月31日 添加了label:ci-pipeline-passed
zl_hw成员
4月1日 评论:

/lgtm

likedislike
songkai111成员
4月1日 评论:

/lgtm
/approve

likedislike
CANN-robotCANN-robot成员
4月1日 添加了label:lgtmapproved
CANN-robot
CANN-robot成员
4月1日 评论:

Review Guide

This pull-request passes review.
Committers who wrote a comment of /approve are: songkai111.
Reviewers who wrote a comment of /lgtm are: zl_hw, songkai111.

likedislike
CANN-robotCANN-robot成员
4月1日 关闭了关联的issue
CANN-robotCANN-robot成员
4月1日 合入了pull request