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] fix functool.reduce more safe with intial value, to support empty list #53182

Merged
merged 1 commit into from
Apr 22, 2023

Conversation

zhwesky2010
Copy link
Contributor

@zhwesky2010 zhwesky2010 commented Apr 21, 2023

PR types

Others

PR changes

Others

Description

Pcard-66984

为functool.reduce设置累乘初始值,使其能支持空list更安全;因为后续shape有可能为[],在计算numel时累乘会报错。

>>> from functools import reduce
>>> reduce(lambda x,y:x*y, [])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: reduce() of empty sequence with no initial value
>>> reduce(lambda x,y:x*y, [], 1)
1

@paddle-bot
Copy link

paddle-bot bot commented Apr 21, 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.

@paddle-bot
Copy link

paddle-bot bot commented Apr 21, 2023

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

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 4da9b87 into PaddlePaddle:develop Apr 22, 2023
lijialin03 pushed a commit to lijialin03/Paddle that referenced this pull request Apr 25, 2023
zhwesky2010 added a commit to zhwesky2010/Paddle that referenced this pull request May 8, 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.

2 participants