Skip to content
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 nansum api to math #38137

Merged
merged 7 commits into from
Dec 24, 2021
Merged

add nansum api to math #38137

merged 7 commits into from
Dec 24, 2021

Conversation

esythan
Copy link
Contributor

@esythan esythan commented Dec 14, 2021

PR types

New features

PR changes

APIs

Describe

add nansum api

x = np.array([[float('nan'), 0.3, 0.5, 0.9],  
                [0.1, 0.2, float('-nan'), 0.7]]).astype(np.float32)
x = paddle.to_tensor(x)
out1 = paddle.nansum(x)  # [2.7]
out2 = paddle.nansum(x, axis=0)  # [0.1, 0.5, 0.5, 1.6]
out3 = paddle.nansum(x, axis=-1)  # [1.7, 1.0]
out4 = paddle.nansum(x, axis=1, keepdim=True)  # [[1.7], [1.0]]

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@@ -193,6 +193,7 @@
from .tensor.math import square # noqa: F401
from .tensor.math import stanh # noqa: F401
from .tensor.math import sum # noqa: F401
from .tensor.math import nansum # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public api should be add in all list below

@@ -151,6 +151,7 @@
from .math import square # noqa: F401
from .math import stanh # noqa: F401
from .math import sum # noqa: F401
from .math import nansum # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for paddle.Tensor.nansum, we should add nansum in list of tensor_method_func below

Superjomn
Superjomn previously approved these changes Dec 21, 2021
Copy link
Contributor

@Superjomn Superjomn left a 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 Show resolved Hide resolved
python/paddle/tensor/math.py Outdated Show resolved Hide resolved
@esythan esythan changed the title add nansum api add nansum api to math Dec 22, 2021
Copy link
Contributor

@TCChenlong TCChenlong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fuyinno4 fuyinno4 merged commit 6554cc1 into PaddlePaddle:develop Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants