-
Notifications
You must be signed in to change notification settings - Fork 4.3k
C++ autograd tutorial #921
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
Conversation
|
Deploy preview for pytorch-tutorials-preview ready! Built with commit 7a1634d https://deploy-preview-921--pytorch-tutorials-preview.netlify.com |
75c48f5 to
ea0a7a0
Compare
ea0a7a0 to
cf844b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me.
Just some small questions.
|
|
||
| 1 1 | ||
| 1 1 | ||
| [ CPUFloatType{2,2} ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cpp Tensor print does not show requires_grad and the grad_fn like we do in python?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No it doesn't :( We might want to fix it though to be consistent with Python tensor print. I filed an issue here: pytorch/pytorch#36004.
| } | ||
|
|
||
| static variable_list backward(AutogradContext *ctx, variable_list grad_outputs) { | ||
| auto saved = ctx->get_saved_variables(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not get_saved_tensors() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think this should be get_saved_tensors(), and my guess is that this API was created before the Variable/Tensor merge was completed, and the author wanted to make a distinction between tensors and variables. Now that we don't have this distinction anymore, I think we should change it to match the Python API: pytorch/pytorch#36099.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed all Variables to Tensor now, to minimize the inconsistency with Python to only this get_saved_variables() function :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I guess it is just a remain of the cpp Tensor/Variable merge.
advanced_source/cpp_autograd.rst
Outdated
| ---------- | ||
|
|
||
| You should now have a good overview of PyTorch's C++ autograd API. | ||
| You can find the code examples displayed in this note (yf225 TODO update link) `here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will merge the examples PR and update the link here, when everything else looks good on this PR :)
albanD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks for the updates
|
Note to self: merge pytorch/examples#745 first and update link in this PR Done |
C++ autograd tutorial
Accompanying example code: pytorch/examples#745.