Pull Request has been successfully merged by CANN-robot.
(Thank you for Jie Yin's contribution.)变更摘要
该 PR 主要将前端 pass 输出的 IR 从旧的类 Python 文本格式切换到新的文本 IR 格式(如 function foo incast(...) outcast() ...),并为 Python 侧的 ir.Function 绑定新的字符串表示。核心实现位于 io_text_dumper.cpp / io_text_loader.cpp:文本输出器支持可选字段的空值处理,文本加载器同步支持解析可选字段;同时通过 io_text.h 的 TextDump 暴露 Function.__str__。此外,大量 IR 相关测试从内联旧格式 IR 字符串迁移为读取 .pypto 黄金文件,并更新了对应的断言与快照。
主要改动
- 新增
Function的 Python 字符串表示:在python/src/bindings/ir/ir.cpp中引入ir/transforms/io_text.h,并为Function类绑定__str__,使其通过TextDump(self)输出新的文本 IR。 - 文本输出器支持可选字段:
io_text_dumper.cpp中VisitType_仅在tv.ptr.has_value()时输出指针表达式;VisitStmt_对IfStmt在elseBody_缺失时输出空{},避免直接访问空optional。 - 文本加载器支持可选字段解析:
io_text_loader.cpp使用CheckToken(LexerTokenKind::PunComma, true)判断是否存在指针表达式,并据此构造带指针或TensorView的两种形态。 - merge pass 测试迁移到
.pypto黄金文件:test_merge_pass/*.py移除内联的旧格式IR字符串,改为通过Path读取同目录下的*.pypto文件,并新增多个新格式黄金文件。 - 更新测试断言与快照:
test_ir.py、test_infer_pass.py、test_pil.py、test_enum_kwarg_resolution.py、test_tiling.py等测试的期望输出改为新格式,例如"= continue"变为"continue %loop_idx_"、"tiling[0]"变为"getitem(%tiling, 0)"。


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
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 | ✅ tsungl4, 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


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


流水线任务触发成功
任务链接 [193fab9091bc40298e673a4ace2b39c8][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| get_pr_file | ✅ SUCCESS | ||
| static-check | ✅ SUCCESS | ||
| compile | ❌ FAILED |


流水线任务触发成功
任务链接 [e8baeb67c6e944ca8348722986062a3f][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| 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 | ||
| PreSmoke_A900 | ✅ SUCCESS | >>>>> |
[2026-08-15 18:05:28] CI执行结束


流水线任务触发成功
任务链接 [193fab9091bc40298e673a4ace2b39c8][流水线指导]
| 任务名称 | 状态 | 日志 | 下载链接 |
|---|---|---|---|
| get_pr_file | ✅ SUCCESS | ||
| static-check | ✅ SUCCESS | ||
| compile | ✅ SUCCESS |
[2026-08-15 18:06:07] CI执行结束


/approve


/lgtm


feat(IR): frontend pass output new format IR