-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add isfinite v2 op #26344
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
Add isfinite v2 op #26344
Conversation
|
Thanks for your contribution! |
3532d86 to
c57659e
Compare
a097d21 to
216eba0
Compare
216eba0 to
831f14d
Compare
3ce8ac5 to
b4d0ded
Compare
2025d7a to
59043f9
Compare
TCChenlong
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
python/paddle/tensor/math.py
Outdated
| if in_dygraph_mode(): | ||
| return core.ops.isnan_v2(x) | ||
| helper = LayerHelper("isnan_v2", **locals()) | ||
| check_variable_and_dtype(x, 'x', ['float16', 'float32', 'float64', 'int32', 'int64'], 'is_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.
统一用isnan
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.
@XiaoguangHu01 done
python/paddle/tensor/math.py
Outdated
| paddle.disable_static() | ||
| x_np = np.array([float('-inf'), -2, 3.6, float('inf'), 0, float('-nan'), float('nan')]) | ||
| x = paddle.to_tensor(x_np) | ||
| out = paddle.tensor.isinf(x) |
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.
isnan
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.
@XiaoguangHu01 done
python/paddle/tensor/math.py
Outdated
| if in_dygraph_mode(): | ||
| return core.ops.isinf_v2(x) | ||
| helper = LayerHelper("isinf_v2", **locals()) | ||
| check_variable_and_dtype(x, 'x', ['float16', 'float32', 'float64', 'int32', 'int64'], 'is_inf') |
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.
isinf
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.
@XiaoguangHu01 done
python/paddle/tensor/math.py
Outdated
| if in_dygraph_mode(): | ||
| return core.ops.isfinite_v2(x) | ||
| helper = LayerHelper("isfinite_v2", **locals()) | ||
| check_variable_and_dtype(x, 'x', ['float16', 'float32', 'float64', 'int32', 'int64'], 'is_finite') |
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.
isfinite
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.
Done
| } // namespace operators | ||
| } // namespace paddle | ||
|
|
||
| #define FOR_EACH_KERNEL_V2FUNCTOR(__macro) \ |
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.
Done
2. is_nan->isnan, is_inf->isinf, is_finite->isfinite
XiaoguangHu01
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
TCChenlong
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
PR types
New features
PR changes
APIs
Describe
Add apis of isfinite, isinf, isnan.