Pull Request has been successfully merged by CANN-robot.
(Thank you for LiuChang's contribution.)变更摘要
该 PR 修复新前端循环展开(loop unroll)中 OOO scope 迭代器计数不正确的问题:将原先集中在 Controller 类(位于 pypto/_controller.py)的编译状态(循环索引生成、函数内标志、ooo scope 迭代器)抽取到新的 CompileState 类(pypto/_compile_state.py),并在新前端循环展开路径(pypto/pil/ops.py 的 _dyn_for/_loop_unroll)中补充 ooo scope 迭代器的重置与递增逻辑,使 sg_set_ooo_scope 能为每个迭代编码出唯一 id,与旧前端 _LoopFunction.Iterator 的行为对齐。
主要改动
- 编译状态迁移至
CompileState: 将Controller上的next_loop_idx、in_function、init_ooo_scope_iter、bump_ooo_scope_iter、get_ooo_scope_iter、begin_function、end_function等接口迁移至新的_compile_state.CompileState,_controller.py、config.py及相关调用点全部改用CompileState。 - 循环展开逐迭代递增 ooo scope iter: 在
ops.py的_loop_unroll中,对 batch 与非 batch 两个分支的每次迭代都调用CompileState.bump_ooo_scope_iter(),保证每个展开迭代获得唯一的 scope 计数。 - 循环入口重置 ooo scope iter: 在
_dyn_for进入循环时调用CompileState.init_ooo_scope_iter()重置计数,使config.py中sg_set_ooo_scope编码(sg_set_ooo_scope * 10000 + get_ooo_scope_iter())在每次循环中产生唯一的迭代 id。 - 测试适配新状态类:
test_function_abort_recording.py中将针对Controller.in_function的断言与导入改为CompileState.in_function,验证函数录制异常时状态重置的行为保持不变。


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


compile


compile


/ai summary


变更摘要
本 PR 修复新前端循环展开(loop unroll)中 OOO scope 迭代器计数不正确的问题:将原先集中在 pypto/_controller.py 的 Controller 类中的编译状态(循环索引生成器、函数内标志、atomic scope 迭代器)抽取到新增的 CompileState 类(pypto/_compile_state.py),并在新前端循环展开路径(pypto/pil/ops.py 的 _dyn_for/_loop_unroll)补充 ooo scope 迭代器的重置与递增逻辑,使 sg_set_ooo_scope 能为每个迭代编码出唯一 id,与旧前端 _LoopFunction.Iterator 的行为对齐。
主要改动
- 新增
CompileState类:在pypto/_compile_state.py新增CompileState,集中承载原Controller的_loop_idx_generator、in_function、_atomic_scope_iter_id状态,并提供init_atomic_scope_iter、bump_atomic_scope_iter、get_atomic_scope_iter、next_loop_idx、begin_function、end_function等类方法。 _controller.py迁移状态与调用:删除Controller类定义及begin_function/end_function函数,function、_LoopFunction.Iterator、loop中原本调用Controller.xxx的地方全部改为CompileState.xxx。- 补充新前端循环展开的迭代计数逻辑:在
pypto/pil/ops.py的_dyn_for循环入口调用CompileState.init_atomic_scope_iter()重置迭代器,在_loop_unroll的 batch 与非 batch 分支每次派发循环体前调用CompileState.bump_atomic_scope_iter()递增,使每个迭代的 scope id 唯一。 - scope id 编码路径跟随迁移:
pypto/config.py的_validate_and_encode_scope_id中从pypto._controller.Controller.get_atomic_scope_iter()改为pypto._compile_state.CompileState.get_atomic_scope_iter()。 - 更新相关单测:
test_function_abort_recording.py中针对函数内标志的断言由Controller.in_function改为CompileState.in_function,并补充CompileState的导入。


/approve


/lgtm


修复新前端循环展开(loop unroll)中 OOO scope 迭代器计数不正确的问题:将原先集中在 Controller 类(位于 pypto/_controller.py)的编译状态(循环索引生成、函数内标志、ooo scope 迭代器)抽取到新的 CompileState 类(pypto/_compile_state.py),并在新前端循环展开路径(pypto/pil/ops.py 的 _dyn_for/_loop_unroll)中补充 ooo scope 迭代器的重置与递增逻辑,使 sg_set_ooo_scope 能为每个迭代编码出唯一 id,与旧前端 _LoopFunction.Iterator 的行为对齐。