Pull Request已成功合入, 合并人@CANN-robot
(感谢 不喜欢雨天ༀ 的贡献)变更摘要
本 PR 为 examples/add_example/tests/ut/op_kernel/test_add_example.cpp 中的 add_example_test::test_case_0 补齐输入构造与输出校验,修复 #27(该用例零断言且输入未初始化的问题)。改动在 ICPU_RUN_KF 前将输入 x、y 填入已知值(x[i]=i、y[i]=2i),运行后逐元素校验 z[i] == x[i] + y[i](float32 加法位精确,期望值 3i 可精确表示),并顺带将魔数 32 * 4 * 4 * 4 收敛为 totalLength 常量复用。仅改动测试文件,不影响 kernel 行为。
主要改动
- 输入初始化:在
ICPU_RUN_KF前将x/y缓冲区转换为float*并填入已知值xFloat[i] = i、yFloat[i] = 2i,使 kernel 输出具备可校验的期望基准 - 输出校验:kernel 运行后新增逐元素断言
EXPECT_EQ(zFloat[i], xFloat[i] + yFloat[i]),并带索引信息的失败提示消息,使计算错误会触发用例失败 - 常量收敛:新增
constexpr size_t totalLength = 32UL * 4UL * 4UL * 4UL,替代三处重复的魔数32 * 4 * 4 * 4字节尺寸计算,并复用于tilingDatafromBin->totalLength赋值


compile


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.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/ops-ras | ✅ 陈兴宇, yue-ma (2/2) | ✅ yue-ma, 陈兴宇 (2/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
2403_87936996, thanks for your pull request. All authors of the commits have signed the CLA. 👍


流水线任务触发成功
任务链接 [5b0aa6e8ac1f47baacf957d247cb1ef3][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-09-03 13:10:43] CI执行结束


流水线任务触发成功
任务链接 [748afd9471864acf9c4ebebe9aa6883d][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> |
[2026-09-03 13:12:59] CI执行结束


/compile 已全绿(6 个任务 ✅)。修复要点:test_case_0 原为零断言且输入未初始化,现补齐已知值输入(x=i, y=2i)与逐元素位级校验(z[i]==x[i]+y[i],fp32 位精确)。@LiuZonggu 恳请检视合入,谢谢!(对应 issue #27)


compile


流水线任务触发成功
任务链接 [bb2d9a1e052a40fb9b8d29d71179c8c0][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| PreSmoke_ATK_Test_A2 | ✅ SUCCESS | >>>>> |
[2026-09-04 09:46:56] CI执行结束


流水线任务触发成功
任务链接 [d7c250d2afa849f1a37f094e38495b06][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_mobile_station_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_single_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| UT_Test_ophost | ✅ SUCCESS | ||
| UT_Test_opapi | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> |
[2026-09-04 09:59:28] CI执行结束


/lgtm
/approve


Problem
examples/add_example/tests/ut/op_kernel/test_add_example.cpp的test_case_0零断言(EXPECT_*/ASSERT_*数量为 0)且输入 x/y 分配后未初始化——ICPU_RUN_KF 之后直接释放内存,kernel 计算错误(甚至写出垃圾)也不会导致用例失败(对应 #27)。Root cause
原实现只演示了 kernel 运行机制,缺少输入构造与结果校验。
Fix
x[i]=i, y[i]=2iz[i] == x[i] + y[i](float32 加法位精确,位级比较;期望值 3i 在 fp32 下精确可表示)totalLength常量复用Verification
test_add_example_tiling.cpp校验 tiling 输出、fast_kernel_launch_example/tests/add/test_add.py校验计算结果,本修复补齐 kernel UT 的校验缺口仅改测试文件,不影响 kernel 行为。