-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[API compatibility] change gelu api for paddle #74485
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
[API compatibility] change gelu api for paddle #74485
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #74485 +/- ##
===========================================
Coverage ? 100.00%
===========================================
Files ? 2
Lines ? 6
Branches ? 0
===========================================
Hits ? 6
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| [ 0.84119201, 1.39957154]]) | ||
| """ | ||
|
|
||
| if isinstance(approximate, bool): |
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.
加上
if approximate == "tanh":
approximate = True
elif approximate == "none":
approximate = False
就行
python/paddle/nn/layer/activation.py
Outdated
| ) -> None: | ||
| super().__init__() | ||
| self._approximate = approximate | ||
| self._origin_approximate = approximate |
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.
这些转换不用做,直接保留 self._approximate = approximate,并透传到function里去就行,function也是支持str的
zhwesky2010
left a comment
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
|
|
||
| def gelu( | ||
| x: Tensor, approximate: bool = False, name: str | None = None | ||
| x: Tensor, approximate: str | bool = False, name: str | None = None |
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.
| x: Tensor, approximate: str | bool = False, name: str | None = None | |
| x: Tensor, approximate: Literal["tanh", "none"] | bool = False, name: str | None = None |
* change gelu api * simple gelu function and class * replace str with literal
PR Category
User ExperiencePR Types
New featuresDescription
Add the case where the approximate parameter is a string (“none" and "tanh") for gelu function and GELU class