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

[XPU] add bfloat16 support for gaussian and uniform #58662

Merged

Conversation

houj04
Copy link
Contributor

@houj04 houj04 commented Nov 3, 2023

PR types

New features

PR changes

OPs

Description

给XPU下的gaussianuniform算子增加bfloat16的类型支持。
此外,在之前的UniformKernel中,没有使用XDNN提供的API,原因未知。本PR把它的实现改成了直接调用XDNN提供的random函数。

Copy link

paddle-bot bot commented Nov 3, 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 paddle-bot bot added the contributor External developers label Nov 3, 2023
Copy link
Contributor

@lj970926 lj970926 left a comment

Choose a reason for hiding this comment

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

LGTM

using XPUType = typename XPUTypeTrait<T>::Type;
int64_t real_seed = seed != 0 ? seed : dev_ctx.GetGenerator()->Random64();

// int random(Context* ctx, T* x, int64_t len, T min, T max, int64_t seed);
Copy link
Contributor

Choose a reason for hiding this comment

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

cpu的分支是否需要保留?
一个需求是用相同的初始化seed,然后xpu/cpu对比输出,xpu::random的结果和cpu能对齐?

Copy link
Contributor Author

@houj04 houj04 Nov 6, 2023

Choose a reason for hiding this comment

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

这种场景下面用export XPU_BLACK_LIST="uniform_random,gaussian_random"的办法解决?
目前gaussian_random也没有保留“从CPU拷贝”的功能。

@houj04 houj04 merged commit b0db77e into PaddlePaddle:develop Nov 6, 2023
28 checks passed
zeroRains pushed a commit to zeroRains/Paddle that referenced this pull request Nov 8, 2023
* [XPU] add bfloat16 support for gaussian and uniform

* fix zero dim.
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* [XPU] add bfloat16 support for gaussian and uniform

* fix zero dim.
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
* [XPU] add bfloat16 support for gaussian and uniform

* fix zero dim.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants