Skip to content

Conversation

@zbt78
Copy link
Contributor

@zbt78 zbt78 commented Jan 15, 2024

PR types

Others

PR changes

OPs

Description

@paddle-bot
Copy link

paddle-bot bot commented Jan 15, 2024

你的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 Jan 15, 2024
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jan 16, 2024
@zbt78
Copy link
Contributor Author

zbt78 commented Jan 16, 2024

研发大哥 麻烦review一下~

#else
a.real = a.real * b.real - a.imag * b.imag;
a.imag = a.imag * b.real + b.imag * a.real;
T r = a.real * b.real - a.imag * b.imag;
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 Author

Choose a reason for hiding this comment

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

这里是我学习cumprod的代码时发现的,在cpu端梯度反向传播时会进行复数的*=操作,然后产生错误。比如说这张图中,x_grad[0][0]的梯度应该是conj(1 + x[1][0]) = conj(1 + 2 + 3j)=3-3j,但是这里用了*=,相应的计算逻辑是conj(1 + 1 *= x[1][0])=conj(1 + [(1 * 2 - 0*3) + (0*2+3*2)j])=conj(3+6j)。应该就是因为在计算a.imag时使用了新的a.real导致的。

self.check_grad(['X'], 'Out', max_relative_error=0.01, check_pir=True)
if self.dtype == np.complex64 or self.dtype == np.complex128:
self.check_grad(
['X'], 'Out', max_relative_error=0.03, check_pir=True
Copy link
Contributor

Choose a reason for hiding this comment

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

我看这里对于复数类型的进行了特判,将设置max_relatice_error=0.03,绝对误差相差多少呢,max_relatice_error=0.02能否通过呢

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里我在本机测试的是0.02多一点,所以扩大到0.03了

Copy link
Contributor

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

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

LGTM,新提PR修改下中英文文档吧
image
修改中文文档时顺便修一下格式问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers HappyOpenSource 快乐开源活动issue与PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants