Pull Request已成功合入, 合并人@CANN-robot
(感谢 maohp_hw 的贡献)haipingmao,感谢您的提交,建议在完成PR充分自验证后,再触发线上构建任务。
若您的PR已具备检视条件,可根据下表的责任田,@对应的committer进行代码检视,我们会在第一时间对您的提交进行处理。
代码责任田:
| module | committer |
|---|---|
| adv_api | chenyiyuan, wuyang_hw |
| basic_api | chenyiyuan, wuyang_hw |
| c_api | pangfd, haipingmao |
| cmake | xun_zhuge, DragonBornHD84 |
| docs | munanhw, ai_xin |
| examples | changxianyu, bianque |
| simt_api | wulinyu, zhanghao_0689 |
| scripts | xun_zhuge, kevin365 |
| tools | YANXI_ZHAO, XuebinYang, sjtulxh |
💡 如您不确定可以@谁,可以直接@我或者ascend-c sig的maintainer,xun_zhuge和ascendhjh,我们会为您分配合适的committer进行代码检视。
再次感谢您参与CANN的社区贡献。


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 |
|---|---|---|
| examples | ✅ bianque, Lycheeeee (2/2) | ✅ bianque (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
haipingmao, thanks for your pull request. All authors of the commits have signed the CLA. 👍


compile


流水线任务触发成功
任务链接 [735696d2e2214f17a8cc2397f35797b6][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| SCA | ✅ SUCCESS | >>>>> | |
| antipoison | ✅ SUCCESS | >>>>> | |
| codecheck | ✅ SUCCESS | >>>>> | |
| codecheck_Pr | ✅ SUCCESS | ||
| pre_comment | ✅ SUCCESS | >>>>> | |
| codecheck_codestyle | ✅ SUCCESS | >>>>> | |
| codecheck_precommit | ✅ SUCCESS | >>>>> | |
| StaticCheck_md | ✅ SUCCESS |
[2026-08-26 17:40:36] CI执行结束


流水线任务触发成功
任务链接 [ada877d6645e46ea80d53781f730e9c9][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| PreSmoke_A900_npupool | ✅ SUCCESS | >>>>> |
[2026-08-26 17:56:24] CI执行结束


流水线任务触发成功
任务链接 [627aafe1ed6f46ac8c8138b81bcea7db][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_adv_test_one | ✅ SUCCESS | ||
| UT_Test_adv_test_two | ✅ SUCCESS | ||
| UT_Test_basic_test_one | ✅ SUCCESS | ||
| UT_Test_basic_test_two | ✅ SUCCESS | ||
| UT_Test_basic_test_three | ✅ SUCCESS | ||
| UT_Test_basic_test_four | ✅ SUCCESS | ||
| UT_Test_basic_test_five | ✅ SUCCESS | ||
| UT_Test_arm | ✅ SUCCESS | ||
| API_Check | ✅ SUCCESS | >>>>> | |
| UT_Test_report | ✅ SUCCESS | >>>>> |
[2026-08-26 18:03:42] CI执行结束


描述
修复Fmod高阶API样例的数据生成问题。
原数据生成脚本使用如下方式生成
src0:src0 = generate_random_data(0.0, 0.0, [159], dtype)由于随机范围上下限相同,generate_random_data会通过np.full生成159
个0.0。根据Fmod计算公式:
Fmod(x, y) = x - Trunc(x / y) * y
当src0为0且src1非0时,计算结果始终为0。因此原样例生成的src0和
golden数据全部为0,导致精度验证退化。即使Kernel错误地始终输出0,
样例也可能通过,无法有效验证Fmod的正常取余逻辑。
修改方案
修改文件:
examples/01_simd_cpp_api/04_advanced_api/10_math/fmod/scripts/
gen_data.py
具体修改如下:
np.random.seed(123321)
保证每次生成的数据一致,避免CI测试数据随机变化。同时避免随机数据
偶发落在整数商边界附近,引入不同硬件实现之间的舍入差异。
src0 = generate_random_data(-10.0, 10.0, src_shape, dtype)
使用跨正负数的非退化随机区间,避免输入全部为0,并覆盖正、负被除
数场景。
src1 = generate_random_data(0.5, 5.0, src_shape, dtype)
src1[1::2] = -src1[1::2]
先生成绝对值范围为[0.5, 5.0]的除数,再将奇数位置改为负数:
src0[:4] = [2.0, 2.0, -3.0, -3.0]
src1[:4] = [1.5, -1.5, 1.1, -1.1]
前4组数据用于覆盖被除数和除数的四种符号组合:
其中Fmod(2.0, 1.5)和Fmod(-3.0, 1.1)与样例README中的计算示例保持
一致。
该设计还可以验证Fmod余数符号跟随被除数src0,不受除数src1符号影
响。
影响范围
本次修改仅涉及Fmod样例的Python数据生成脚本:
测试
已完成以下验证:
[0.5, 0.5, -0.79999995, -0.79999995]
使用float32模拟Fmod计算路径,结果与np.fmod的最大绝对误差约为
3.58e-7,低于样例现有的1e-4精度阈值。
使用相同随机种子重复执行,生成文件内容一致。
关联Issue
关联的Issue #1480
文档更新
无需更新文档。固定测试数据与README中已有的Fmod计算示例保持一致。
类型标签