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

Fix backward bug #34582

Merged

Conversation

MingMingShangTian
Copy link
Contributor

@MingMingShangTian MingMingShangTian commented Aug 3, 2021

PR types

Bug fixes

PR changes

APIs

Describe

修复当传入的初始梯度是反向图中的非叶子节点时候,backward API 失败的bug。
问题描述:
image

若在反向图中指定了非叶子节点(图中Pow(x,2)@Grad )的初始梯度值,则该Node不能直接进行反向计算,需要待其上游节点(图中 Pow(y,3)@Grad)执行完成后再进行计算。同时,该上游节点产生的梯度值需要和指定的初始值进行累加后,作为该节点(图中Pow(x,2)@Grad )的输入。

修复方式:

  • 初始化过程中对传入的初始grad 添加梯度累加器,保存了传入的初始梯度值,使得传入的初始梯度值可以和上游计算的梯度进行累加。
  • 筛选叶子 Node 作为真正起始执行的节点,保证了执行顺序的正确性。

@paddle-bot-old
Copy link

paddle-bot-old bot commented Aug 3, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@chenwhql chenwhql left a comment

Choose a reason for hiding this comment

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

LGTM

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