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

[dy2static]implement tensor.cuda() in static graph #56092

Merged
merged 4 commits into from
Aug 11, 2023

Conversation

liudongxue01
Copy link
Contributor

@liudongxue01 liudongxue01 commented Aug 8, 2023

PR types

Others

PR changes

APIs

Description

  • tensor.cuda() is empty implementation in static graph mode, but on the dygraph mode, this api performs the memory-copying behaviour(H2D or D2D).
  • So on dy2static mode, the model result would not be equivalent as on dygraph mode.
  • Upon above, we implemented the memory-copying logic code in this api using 'memcpy' operator.
  • We alse add some fixup logic in interpreter_util.cc as a workaround of the bugs in 'memcpy' kernel.
  • Note: 'memcpy' operator does not have corresponding backward node, so we set 'stop_gradient=True' on the result tensor object.

Others

Pcard-73789

@paddle-bot
Copy link

paddle-bot bot commented Aug 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.

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

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

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

@Aurelius84 Aurelius84 merged commit a6a4985 into PaddlePaddle:develop Aug 11, 2023
26 of 27 checks passed
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.

5 participants