Pull Request has been successfully merged by CANN-robot.
(Thank you for niulinkai's contribution.)变更摘要
本 PR 修复了 pass 阶段中 reshape 与 assemble 相关逻辑的错误。核心改动集中在 RemoveRedundantAssemble::HanldeForSingleAssemble:原先只要 consumers.size() == 1 中的消费者为 OP_ASSEMBLE 就会删除该节点并折叠,现改为仅针对 COPY_OUT -> ASSEMBLE -> RESHAPE -> OUTCAST 这一特定模式进行折叠,并新增了在多个 COPY_IN 消费者场景下对输入进行重连(rewire)的逻辑,以保留 ReplaceTensor 刷新后的绝对 COPY_IN 属性。同时在 RemoveUnalignedReshape 中补充了对空消费者(无消费者)张量的处理,避免进入 COPY_IN 插桩路径。两处配套单测验证了新逻辑。
主要改动
- 收窄
RemoveRedundantAssemble的折叠条件:HanldeForSingleAssemble新增reshapeToOutcast与rewireCopyIns判定,仅当输出唯一消费者为OP_RESHAPE且节点类型为NodeType::OUTCAST,同时输入输出 magic 相同、生产者全为COPY_OUT、消费者仅含自身与COPY_IN时才执行折叠,避免误删并行的ASSEMBLE。 - 新增
COPY_IN消费者重连逻辑:在rewireCopyIns为真时备份消费者集合,对非自身的COPY_IN消费者调用ReplaceInput(output, input),保留由ReplaceTensor刷新后的绝对COPY_IN属性;同时将MoveTokenDependencyBeforeRemoveOp、SetAsDeleted、HandleCopyOutToAssemble等调用对象由原消费者*cons统一改为当前op。 - 空消费者张量的处理:
RemoveUnalignedReshape::HandleNoCopyInConsumer在完成 UB 检查后,若output->GetConsumers()为空则直接return,不再走插入COPY_IN的路径;checkNonCopyInConsumerExists也将hasNoCopyInConsumer初始化为consumers.empty()。 - 新增单元测试:
test_pre_graph.cpp增加KeepParallelAssemblesWithSiblingCopyIn,验证在存在并行ASSEMBLE与COPY_IN时保留结果并核对COPY_IN的绝对偏移属性;test_remove_unaligned_reshape_op.cpp增加TestTerminalDynamicReshapeSkipsPairedConversion,验证终端动态 reshape 场景下跳过配对转换。


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


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


/approve


/lgtm


变更摘要
本 PR 修复了 pass 阶段中 reshape 与 assemble 相关逻辑的错误。核心改动集中在 RemoveRedundantAssemble::HanldeForSingleAssemble:原先只要 consumers.size() == 1 中的消费者为 OP_ASSEMBLE 就会删除该节点并折叠,现改为仅针对 COPY_OUT -> ASSEMBLE -> RESHAPE -> OUTCAST 这一特定模式进行折叠,并新增了在多个 COPY_IN 消费者场景下对输入进行重连(rewire)的逻辑,以保留 ReplaceTensor 刷新后的绝对 COPY_IN 属性。同时在 RemoveUnalignedReshape 中补充了对空消费者(无消费者)张量的处理,避免进入 COPY_IN 插桩路径。两处配套单测验证了新逻辑。
主要改动
收窄 RemoveRedundantAssemble 的折叠条件:HanldeForSingleAssemble 新增 reshapeToOutcast 与 rewireCopyIns 判定,仅当输出唯一消费者为 OP_RESHAPE 且节点类型为 NodeType::OUTCAST,同时输入输出 magic 相同、生产者全为 COPY_OUT、消费者仅含自身与 COPY_IN 时才执行折叠,避免误删并行的 ASSEMBLE。
新增 COPY_IN 消费者重连逻辑:在 rewireCopyIns 为真时备份消费者集合,对非自身的 COPY_IN 消费者调用 ReplaceInput(output, input),保留由 ReplaceTensor 刷新后的绝对 COPY_IN 属性;同时将 MoveTokenDependencyBeforeRemoveOp、SetAsDeleted、HandleCopyOutToAssemble 等调用对象由原消费者 *cons 统一改为当前 op。
空消费者张量的处理:RemoveUnalignedReshape::HandleNoCopyInConsumer 在完成 UB 检查后,若 output->GetConsumers() 为空则直接 return,不再走插入 COPY_IN 的路径;checkNonCopyInConsumerExists 也将 hasNoCopyInConsumer 初始化为 consumers.empty()。
新增单元测试:test_pre_graph.cpp 增加 KeepParallelAssemblesWithSiblingCopyIn,验证在存在并行 ASSEMBLE 与 COPY_IN 时保留结果并核对 COPY_IN 的绝对偏移属性;test_remove_unaligned_reshape_op.cpp 增加 TestTerminalDynamicReshapeSkipsPairedConversion,验证终端动态 reshape 场景下跳过配对转换。