Merged
feat(function): Add parallel tag in op assemble #5057
高前程Add on Jul 24
feat(function): Add parallel tag in op assemble #5057
Merged
高前程Add on Jul 24
高前程
高前程Collaborators
Jul 24

前端提供带parallel的assemble接口

likedislike
Pull Request has been successfully merged by CANN-robot.
(Thank you for 高前程's contribution.)
高前程高前程Collaborators
Jul 24 Created pull request, commit c8fbc076
atomgit-bot
atomgit-bot
Jul 24 Comments:

变更摘要

此 PR 为 Assemble 操作引入了一个 parallel 标签,用于标记该操作是否可以并行执行。核心改动涉及 C++ 框架层新增 OpAttributeKey::parallel 属性常量,并在 Assemble / TensorDInnerAssemble 函数签名中增加 bool parallel 参数(默认值为 true),同时将参数值写入 Op 属性。在 pass 层面新增了 IsSingleInputAssembleWithParallelFalse 辅助函数,用于检测单输入且 parallel=false 的 Assemble 操作并据此设置 NORMAL 标记。Python 端同步更新了 assemble 函数的重载签名与实现逻辑,支持 Optional[bool] 类型的 parallel 参数,单源时默认 True、多源时默认 False。

主要改动

  • 新增 parallel Op 属性常量: 在 OpAttributeKey 中声明并定义了静态字符串 parallel,用于在 Op 上存储并行执行标记。
  • Assemble 函数签名扩展: C++ 层的 Assemble 和 TensorDInnerAssemble 函数新增 bool parallel = true 参数,调用链将该值通过 op.SetAttribute(OpAttributeKey::parallel, parallel) 写入 Op 属性。
  • 新增 IsSingleInputAssembleWithParallelFalse 检查函数: 在 pass_utils.cpp 中实现该辅助函数,用于识别单输入且 parallel 属性为 false 的 Assemble Op,并在 InferOutcastWriteConflict 中据此为 outcast 设置 NORMAL 属性。
  • Python assemble 接口更新: 两层重载和最终实现函数均新增 parallel: Optional[bool] = None 参数;当 None 时单源默认 True、多源默认 False,显式传入则以用户值为准。
  • C++ 绑定与类型存根同步: operation.cpp 绑定中 lambda 和 py::arg 均增加 parallel 参数及默认值;__init__.pyi 类型存根同步更新签名。
likedislike
Incorrect?
atomgit-bot
atomgit-bot
Jul 24 Comments:

代码审查

关闭摘要

审查覆盖的 9 个文件:

文件 审查结论
docs/zh/api/operation/pypto-assemble.md 无问题:文档准确描述了 parallel 参数的新语义和默认值推断逻辑
framework/include/tilefwk/tilefwk_op.h 无问题:声明变更与实现一致
framework/src/interface/operation/operation.cpp 无问题:OpAttributeKey::parallel 正确定义
framework/src/interface/operation/operation.h 无问题:parallel 静态常量正确声明
framework/src/interface/operation/operation_impl.cpp 无问题:parallel 参数正确传递并设置为操作属性
framework/src/passes/pass_utils/pass_utils.cpp 2 个 P3 建议(见下方)
python/pypto/operation.py 无问题:None→True/False 的默认值解析逻辑正确
python/pypto/pypto_impl/__init__.pyi 无问题:类型存根正确反映 C++ 绑定的默认值
python/src/bindings/operation.cpp 无问题:pybind11 绑定正确传递 parallel 参数

发现统计:

  • P0: 0
  • P1: 0
  • P2: 0
  • P3: 2

总体风险评估: 低风险

该 PR 为 assemble 操作新增了 parallel 参数,用于控制写回的并行/串行调度。核心逻辑正确,Python 层的默认值推断(单 tensor→True,批量→False)与 C++ 层的默认值和 InferOutcastWriteConflict 中的 IsSingleInputAssembleWithParallelFalse 检测逻辑一致。两个 P3 发现均为维护性建议,不影响运行时正确性。

⚠️ 已识别出整体风险,但无法提取行内评论,请参考整体评估。

likedislike
Incorrect?
CANN-robotCANN-robotCollaborators
Jul 24 Added label: cann-cla/yes
CANN-robot
CANN-robotCollaborators
Jul 24 Comments:

CLA Signature Pass

Immutable01, thanks for your pull request. All authors of the commits have signed the CLA. 👍

likedislike
102 messages are collapsed here。 See more
Jie Yin
Jie YinCollaborators
Aug 4 Comments:

/lgtm

likedislike
CANN-robotCANN-robotCollaborators
Aug 4 Added label: lgtm
Jie Yin
Jie YinCollaborators
Aug 4 Comments:

/approve

likedislike
CANN-robotCANN-robotCollaborators
Aug 4 Added label: approved
CANN-robotCANN-robotCollaborators
Aug 4 Merged pull request