-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[NewIR] add stop_gradient attribute for defining op #55235
[NewIR] add stop_gradient attribute for defining op #55235
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
paddle/ir/core/operation.h
Outdated
@@ -68,6 +68,14 @@ class IR_API alignas(8) Operation final { | |||
attributes_[key] = value; | |||
} | |||
|
|||
Attribute GetAttribute(const std::string &key) const { |
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.
这个函数名直接用attribute就行吧。
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.
那其他两个接口需要换成set_attribute和has_attribute吗?
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.
可以顺便把SetAttribute接口也重命名为 set_attribute。
paddle/ir/core/operation.h
Outdated
@@ -68,6 +68,14 @@ class IR_API alignas(8) Operation final { | |||
attributes_[key] = value; | |||
} | |||
|
|||
Attribute GetAttribute(const std::string &key) const { | |||
return attributes_.at(key); |
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.
是不是可以加一个判断有无的检查?
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.
at好像已经带越界检查了。
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.
可以,我改成用ir_enforce判断一下吧,但是这样感觉和HasAttribute就有点重叠了。使用的时候一般要先用has_attribute判断,在这里再判断下就会判断两次。
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.
at好像已经带越界检查了。
但是at的报错提示不太友好
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
* add stop_gradient attribute for defining op * modify by reviews * fix
* add stop_gradient attribute for defining op * modify by reviews * fix
PR types
New features
PR changes
Others
Description
After this op, the attribute
stop_attribute
of VarDesc will be introduced as the attribute of the defining op of the corresponding value.The operation will be like:
However, it should be noted that not all operation will have a
stop_attribute
currently.Others
Pcard-67164