-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Added fmax and fmin operators #37826
Conversation
✅ This PR's description meets the template requirements! |
Thanks for your contribution! |
ops::ElementwiseFMaxGradKernel<paddle::platform::CPUDeviceContext, int>, | ||
ops::ElementwiseFMaxGradKernel<paddle::platform::CPUDeviceContext, int64_t>); | ||
|
||
REGISTER_OP_VERSION(elementwise_fmax) |
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.
这一段不需要,这是用于 op 兼容性升级的。
The equation is: | ||
|
||
.. math:: | ||
out = fmax(x, y) |
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.
文档里面最好写明 nan 的传播机制。亦即 nan 被认为小于任何值。
out = fmin(x, y) | ||
|
||
**Note**: | ||
``paddle.fmin`` supports broadcasting. If you want know more about broadcasting, please refer to :ref:`user_guide_broadcasting` . |
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.
文档里面最好写明 nan 的传播机制。亦即 nan 被认为大于任何值。
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.
OK 已经添加了
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.
OK 已经添加了
import paddle.fluid.core as core | ||
|
||
|
||
class ApiFMaxTest(unittest.TestCase): |
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.
还缺少 OpTest。
需要继承 OpTest 写 Op 单元测试。可以参考 python/paddle/fluid/tests/unittests/test_elementwise_add_op.py
fmin 也是一样
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.
ok 已经添加了
@@ -295,6 +297,8 @@ | |||
'maximum', | |||
'min', | |||
'minimum', | |||
'fmax', | |||
'fmin', |
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.
这里需要把函数加入此文件的tensor_method_func列表
python/paddle/__init__.py
Outdated
@@ -437,6 +439,8 @@ | |||
'pow', | |||
'zeros_like', | |||
'maximum', | |||
'fmax', | |||
'fmin', |
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.
需要加入此文件的all 列表
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.
已经加了呀
return "Compare two tensors and returns a new tensor containing the " | ||
"element-wise maxima."; |
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.
what's different between fmax and max, shall we describe it more detailed?
return "Compare two tensors and returns a new tensor containing the " | ||
"element-wise minima."; |
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.
what's different between fmin and min, shall we describe it more detailed?
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.
OK
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
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.
approve for no_grad_set_white_list
44c221a
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 types
New features
PR changes
OPs
Describe
Added fmax and fmin operators, and added documentation and unit tests for comparison with competing products.
example:
The reason for the need to modify the 'no_grad_set_white_list.py' file is that because there are two inputs, the reverse of one of them needs to be tested separately, and the operator name needs to be added to the whitelist.