Pull Request has been successfully merged by CANN-robot.
(Thank you for Jie Yin's contribution.)变更摘要
本 PR 为 IR 的 func builder(RootFunctionBuilder,即 ir_func_builder.cpp)相关测试引入"检查或渲染"(check/render)的 golden 快照机制:test_common.py 中的 check_snapshot 由接收字符串改为接收 Path,并新增 PYPTO_RENDER_IR 环境变量开关,设置后直接把 str(func) 写入 golden 文件完成渲染/更新,否则读取 golden 文件做 diff 校验。同时将多份测试中内联的 IR 字符串迁移为独立的 .pypto golden 文件,并将所有调用点统一改为按路径传入。
主要改动
check_snapshot支持渲染模式:python/tests/ut/ir/test_common.py中check_snapshot(func, golden_path)改为接收Path类型,新增PYPTO_RENDER_IR环境变量分支——置位时写入str(func)到 golden 路径并打印Updated:后返回,否则读取 golden 与str(func)做 strip 后对比并输出 unified diff。- func builder 测试接入 golden 快照:
test_ir_func_builder.py的_run_root_only新增golden_name参数,在canonicalize/dce/create_root_functions之前通过check_snapshot(prog, golden_path)对 program 做快照;并新增test_ir_func_builder_data/目录下 11 个.pyptogolden 文件覆盖各分支场景。 - 外部化冗余 token 测试的内联基准:
test_remove_redundant_pass.py将 16 组内联的BEFORE_IR_*/IR_*字符串常量抽取到test_remove_redundant_pass_data/目录下的.pypto文件,测试改为以路径形式传给check_snapshot。 - 移除 infer token pass 测试的归一化逻辑:
test_infer_pass.py删除_NormalizedSnapshot类、_normalize_token_names正则归一化及_check_snapshot包装,统一改用check_snapshot;同时test_for_input.pypto、test_for_output.pypto、test_for_read_output.pypto三个 golden 文件中的loop_idx_N占位符替换为具体编号(如loop_idx_28、loop_idx_10)。 - 批量迁移快照调用点:
test_attr_move.py、test_token_pass_inplace.py以及test_merge_pass/下多个测试(test_fillpad.py、test_merge_pass1.py~test_merge_pass8.py等)将check_snapshot(func, IR.read_text())改为check_snapshot(func, IR),统一以Path传入 golden 文件。


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


compile


流水线任务触发成功
任务链接 [c26e5a11f85140c9bb2c2c00f4805b02][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| Compile_Ascend_X86 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_X86_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM | ✅ SUCCESS | >>>>> | >>>>> |
| Compile_Ascend_ARM_ubuntu24 | ✅ SUCCESS | >>>>> | >>>>> |
| pre_comment | ✅ SUCCESS | >>>>> | |
| UT_Test_Py3_ninja_simulation | ✅ SUCCESS | ||
| UT_Test_Py3_ninja | ✅ SUCCESS | >>>>> | |
| UT_Test_Cpp_make_gnu_part_1 | ✅ SUCCESS | ||
| UT_Test_Cpp_make_gnu_part_2 | ✅ SUCCESS | ||
| UT_Test_Cpp_make_gnu_part_3 | ✅ SUCCESS | ||
| UT_Test_Cpp_make_clang_part1 | ✅ SUCCESS | ||
| UT_Test_Cpp_make_clang_part2 | ✅ SUCCESS | ||
| UT_Test_Cpp_make_clang_part3 | ✅ SUCCESS | ||
| UT_Test_kirinx90 | ✅ SUCCESS | ||
| UT_Test_kirin9030 | ✅ SUCCESS | ||
| UT_Test_report | ✅ SUCCESS | >>>>> | |
| PreSmoke_A900 | ✅ SUCCESS | >>>>> |
[2026-08-27 21:16:46] CI执行结束


流水线任务触发成功
任务链接 [70869aec1ca04fbab5ae2ec6aad1ac88][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| get_pr_file | ✅ SUCCESS | ||
| static-check | ✅ SUCCESS | ||
| compile | ✅ SUCCESS |
[2026-08-27 21:17:39] CI执行结束


/check-pr


The following labels are not ready.
lgtm: Please wait for reviewers to review the code.
approved: Please wait for committers to review the code.


/approve


/lgtm


feat(IR): Check or render the func builder