Skip to content

Conversation

SigureMo
Copy link
Member

@SigureMo SigureMo commented Mar 27, 2025

PR Category

Execute Infrastructure

PR Types

Bug fixes

Description

CSE 之前考虑一个 OP 是否可以安全替换主要考虑的是

  • 自身是否包含 side effect
  • 其输出是否被 inplace op 所修改(即写语义)

但是如果其自身为 inplace op,那么自然满足第一个条件,即包含 side effect,因此,将自身为 inplace 的 op 标记为无法替换的,以免下面的 program 被替换错

{
    (%0) = "pd_op.full" [id:32] () {dtype:float32,place:Place(undefined:0),shape:[1],stop_gradient:[true],value:0} : () -> tensor<1xf32>
    (%1) = "pd_op.increment_" [id:33] (%0) {stop_gradient:[true],value:2} : (tensor<1xf32>) -> tensor<1xf32>
    (%2) = "pd_op.increment_" [id:34] (%0) {stop_gradient:[true],value:2} : (tensor<1xf32>) -> tensor<1xf32>
    (%3) = "pd_op.increment_" [id:35] (%0) {stop_gradient:[true],value:2} : (tensor<1xf32>) -> tensor<1xf32>
    (%4) = "pd_op.increment_" [id:36] (%0) {stop_gradient:[true],value:2} : (tensor<1xf32>) -> tensor<1xf32>
    (%5) = "pd_op.increment_" [id:37] (%0) {stop_gradient:[true],value:2} : (tensor<1xf32>) -> tensor<1xf32>
    () = "builtin.shadow_output" [id:38] (%0) {output_name:"output_0"} : (tensor<1xf32>) -> 
}

Related links

CINN 切默认系列 PR

Copy link

paddle-bot bot commented Mar 27, 2025

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@SigureMo SigureMo merged commit 65f2c27 into PaddlePaddle:develop Mar 31, 2025
33 checks passed
@SigureMo SigureMo deleted the pir/skip-replace-inplace-op-since-it-has-side-effect branch March 31, 2025 06:25
YqGe585 pushed a commit to YqGe585/Paddle that referenced this pull request May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants