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

[Zero-Dim] Support paddle.sum/mean/loss api output 0D, test=allcase #52739

Merged
merged 1 commit into from
Apr 30, 2023

Conversation

zhwesky2010
Copy link
Contributor

@zhwesky2010 zhwesky2010 commented Apr 10, 2023

PR types

New features

PR changes

APIs

Description

Pcard-66984

支持以下API输出0D:

1. paddle.sum
2. paddle.mean
3. paddle.std
4. paddle.var
5. paddle.nanmean
6. paddle.nansum
7. paddle.nn.functional.softmax_with_cross_entropy
8. paddle.nn.functional.nll_loss
9. paddle.nn.functional.ctc_loss
10. paddle.nn.functional.kl_div
11. paddle.nn.functional.mse_loss
12. paddle.nn.functional.npair_loss
13. paddle.nn.functional.smooth_l1_loss

@paddle-bot
Copy link

paddle-bot bot commented Apr 10, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@zhwesky2010 zhwesky2010 force-pushed the sum_mean_0d branch 11 times, most recently from 096e89f to 036b36f Compare April 15, 2023 17:34
@zhwesky2010 zhwesky2010 force-pushed the sum_mean_0d branch 5 times, most recently from 8f04011 to d6bd7f9 Compare April 20, 2023 07:38
@zhwesky2010 zhwesky2010 changed the title [Zero-Dim] Support paddle.sum/mean output 0D,test=allcase [Zero-Dim] Support paddle.sum/mean/max output 0D,test=allcase Apr 20, 2023
@zhwesky2010 zhwesky2010 force-pushed the sum_mean_0d branch 2 times, most recently from 1ba1235 to 09b477d Compare April 21, 2023 13:56
@zhwesky2010 zhwesky2010 changed the title [Zero-Dim] Support paddle.sum/mean/max output 0D,test=allcase [Zero-Dim] Support paddle.sum/mean output 0D,test=allcase Apr 23, 2023
@zhwesky2010 zhwesky2010 force-pushed the sum_mean_0d branch 3 times, most recently from 7cd9db2 to c394876 Compare April 25, 2023 06:36
@zhwesky2010 zhwesky2010 changed the title [Zero-Dim] Support paddle.sum/mean output 0D,test=allcase [Zero-Dim] Support paddle.sum/mean/loss api output 0D, test=allcase Apr 25, 2023
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@aoyulong aoyulong left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -511,7 +511,7 @@ def _prepare_logger(
loss_indices = fetch_indices[group_idx]
assert len(loss_indices) <= 1
for idx in loss_indices:
logs["loss"] = outs[idx][0]
logs["loss"] = outs[idx]
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason to remove the [0]?

Copy link
Contributor Author

@zhwesky2010 zhwesky2010 Apr 28, 2023

Choose a reason for hiding this comment

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

outs是executor的fetch出来的loss结果,原来的fetch出来的是1D,所以这里取了下标0来切片;新的loss为0D:[],所以就不能取下标切片了,直接当成float来用就行。

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhwesky2010 zhwesky2010 merged commit ddf94ae into PaddlePaddle:develop Apr 30, 2023
XiaoguangHu01 pushed a commit that referenced this pull request May 9, 2023
#53601)

* [Zero-Dim] fix functool.reduce more safe with intial value, to support empty list (#53182)

* [Zero-Dim] support 0d tensor for shape and squeeze onednn kernel (#52832)

* support 0d tensor for shape and squeeze onednn kernel

* set python api for shape op ut

* [Zero-Dim] distributed scatter/all_to_all support input 0D tensor (#53186)

* [Zero-Dim] Support paddle.sum/mean/loss api output 0D,test=allcase (#52739)

* [CINN Support 0D-Tensor] CINN supports 0D-Tensor with trick temporarily (#53382)

* [CINN Support 0D-Tensor] CINN supports 0D-Tensor with trick temporarily

* Add unittest

* [CINN Support 0D-Tensor] CINN hack squeeze2 with trick temporarily (#53454)

* fix test_autograd_dynamic (#53473)

Co-authored-by: zhwesky2010 <zhouwei25@baidu.com>

---------

Co-authored-by: YangQun <qun.yang@intel.com>
Co-authored-by: HongyuJia <jiahongyu@baidu.com>
Co-authored-by: HydrogenSulfate <490868991@qq.com>
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.

4 participants