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

[AMP OP&Test]stack & unstack ops fp16 bf16 support #50999

Merged
merged 14 commits into from
Apr 11, 2023

Conversation

piDack
Copy link
Contributor

@piDack piDack commented Feb 28, 2023

PR types

New features

PR changes

Others

Describe

add fp16/bf16 support 4 stack & unstack ops

@paddle-bot
Copy link

paddle-bot bot commented Feb 28, 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 contributor External developers status: proposed labels Feb 28, 2023
@piDack piDack changed the title stack & unstack fp16 bf16 support [bf16]stack & unstack ops fp16 bf16 support Feb 28, 2023
@@ -25,4 +25,6 @@ PD_REGISTER_KERNEL(unstack_grad,
float,
double,
int,
int64_t) {}
int64_t,
Copy link
Contributor

@ZzSean ZzSean Feb 28, 2023

Choose a reason for hiding this comment

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

本次修改暂不修改CPU,只针对GPU

double,
int,
int64_t,
phi::dtype::float16,
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

def initParameters(self):
self.dtype = np.float16

def test_check_grad(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

这里为什么没有直接使用原来的test_check_grad

self.initParameters()
self.op_type = 'unstack'
self.python_api = paddle.unstack
self.x = np.random.random(size=self.input_dim).astype(float)
Copy link
Contributor

Choose a reason for hiding this comment

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

astype(float)需要改成astype(np.float32),否则在python中直接使用float的话会是64bits的


def test_check_grad(self):
place = core.CUDAPlace(0)
with fluid.dygraph.guard():
Copy link
Contributor

Choose a reason for hiding this comment

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

这里反向的写法最好还是跟TestUnStackOpBase保持一致吧

@piDack piDack changed the title [bf16]stack & unstack ops fp16 bf16 support [AMP OP&Test]stack & unstack ops fp16 bf16 support Mar 2, 2023
@@ -64,6 +66,41 @@ def test_check_grad(self):
self.check_grad(['X'], self.get_y_names(), check_eager=True)


def unstack_grad_fp16(dout):
Copy link
Contributor

Choose a reason for hiding this comment

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

需删除

Copy link
Contributor

@ZzSean ZzSean 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

@ZzSean ZzSean 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

@qili93 qili93 left a comment

Choose a reason for hiding this comment

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

LGTM

@qili93 qili93 merged commit dee7d78 into PaddlePaddle:develop Apr 11, 2023
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