New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PIR] Mark ShareData
as an inplace OP and fix inplace pass
#64195
[PIR] Mark ShareData
as an inplace OP and fix inplace pass
#64195
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greate work!
ShareData
as an inplace OPShareData
as an inplace OP and fix inplace pass
@@ -67,6 +67,19 @@ bool CanBeDeleted(pir::Value value) { | |||
return !(persist_attr && persist_attr.data()); | |||
} | |||
|
|||
bool HasNotUser(const pir::Value& value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bool HasNotUser(const pir::Value& value, | |
bool IsLastestUser(const pir::Value& value, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个函数名字感觉含义不是很清楚,是不是换成 IsLastestUser 更明确一点
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,下个 PR 优化下~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好的,下个 PR 优化下~
是Latest不是Lastest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是Latest不是Lastest
不说还没注意 😂,不过这里语义应该是 Last
,已在 #64317 修改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overrall
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR Category
Execute Infrastructure
PR Types
Bug fixes
Description
修改
ShareData
为一个 inplace OP,否则 Inplace Pass 识别不到 ShareData 的写语义,导致错误地将一个 OP 转为 inplace 的,导致输入错误被更新(比如单测里的u
被错误更新了)目前 Inplace Pass 处理的是有 bug 的,进而没有正确处理上面的情况,因此修改 inplace 判断策略
对于一个待替换的 OP
b
来说(黄色a
、c
已经遍历过,绿色b
正在遍历,蓝色d
、f
待遍历),最多可能的情况如图所示,但如果 OPd
存在,那么不会在b
进行 inplace,因为不是 eager deletion op我们会在遍历时维护一个
use_count_map
和一个inplace_map
,前者用于表示各个 Value 当前的引用计数(初始是Value.use_count()
,之后会逐渐递减),只有自身 use_count 为 0 且相应的 inplace Value use_count 也为 0 的情况才能将该 OP inplacecc @HydrogenSulfate
PCard-66972