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 inplace api transpose_, t_, normal_,cauchy_, geometric_ #57093

Conversation

GGBond8488
Copy link
Contributor

@GGBond8488 GGBond8488 commented Sep 8, 2023

PR types

New features

PR changes

APIs

Description

Pcard-75099
add inplace api transpose_, t_, cauchy_, geometric_, normal_

@paddle-bot
Copy link

paddle-bot bot commented Sep 8, 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.

@GGBond8488 GGBond8488 changed the title add inplace api transpose_, t_, cauchy_, geometric_ add inplace api transpose_, t_, nromal_,cauchy_, geometric_ Sep 19, 2023
@GGBond8488 GGBond8488 changed the title add inplace api transpose_, t_, nromal_,cauchy_, geometric_ add inplace api transpose_, t_, normal_,cauchy_, geometric_ Sep 19, 2023
# [-0.34646994, -0.45116323, -0.09902662, -0.11397249], # random
# [ 0.433519, 0.39483607, -0.8660099, 0.83664286]] # random
"""
return _C_ops.gaussian_inplace_(x, float(mean), float(std), int(seed))
Copy link
Contributor

Choose a reason for hiding this comment

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

If we want to support the mean and variance of complex numbers, there will be problems with this processing

Copy link
Contributor Author

@GGBond8488 GGBond8488 Sep 19, 2023

Choose a reason for hiding this comment

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

will be replaced by scalar when adding complex support

Comment on lines +54 to +55
float mean,
float std,
Copy link
Contributor

@jeff41404 jeff41404 Sep 19, 2023

Choose a reason for hiding this comment

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

if dtype of x is double, implicit type conversion will be performed in mean and std, resulting in a loss of accuracy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As above

jeff41404
jeff41404 previously approved these changes Sep 19, 2023
@@ -1052,6 +1052,19 @@
func : gather_tree
data_type : ids

- op : gaussian_inplace
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么需要新增单独的inplace算子来着?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

原有的gassian算子没有输入tensor,如果用gaussian+assign的方式梯度计算会不对

Copy link
Contributor Author

Choose a reason for hiding this comment

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

现有的uniform_inplace也是新增的uniform_inpalce算子, uniform+gaussian 可以组合出所有其他的分布,后续用应该也不需要新增其他的这种算子了

chenwhql
chenwhql previously approved these changes Sep 19, 2023
@GGBond8488 GGBond8488 dismissed stale reviews from chenwhql and jeff41404 via 1b1b1e5 September 19, 2023 12:09
>>> import paddle
>>> x = paddle.randn([3, 4])
>>> x.cauchy_(1, 2)
>>> # doctest: +SKIP('random check')
Copy link
Contributor

Choose a reason for hiding this comment

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

像这些部分,设置 paddle.seed 也不能固定输出嘛?因为ci检查时设备也是固定cpu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

seed对目前的分布类没用, paddle.distribution.Cauchy,设置了种子也会随机输出

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

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

LGTM for docs

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

@jeff41404 jeff41404 merged commit 87738f1 into PaddlePaddle:develop Sep 22, 2023
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
…ddle#57093)

* add inplace

* fix transpose inpalce error

* fix error

* fix

* fix

* add gaussian inpalce kernel

* change cauchy_ gepmetric impl

* fix typro

* add test

* remove gaussian test

* fix sample code error

* fix sample code

* fix sample code error
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 16, 2023
…ddle#57093)

* add inplace

* fix transpose inpalce error

* fix error

* fix

* fix

* add gaussian inpalce kernel

* change cauchy_ gepmetric impl

* fix typro

* add test

* remove gaussian test

* fix sample code error

* fix sample code

* fix sample code error
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…ddle#57093)

* add inplace

* fix transpose inpalce error

* fix error

* fix

* fix

* add gaussian inpalce kernel

* change cauchy_ gepmetric impl

* fix typro

* add test

* remove gaussian test

* fix sample code error

* fix sample code

* fix sample code error
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