-
Notifications
You must be signed in to change notification settings - Fork 4.3k
C++ frontend Tutorial #408
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 0e665a6 https://deploy-preview-408--pytorch-tutorials-preview.netlify.com |
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.
.
| b = register_parameter("b", torch::randn(M)); | ||
| } | ||
| torch::Tensor forward(torch::Tensor input) { | ||
| return torch::admm(b, input, W); |
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: torch::addmm
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.
thanks
| <https://arxiv.org/abs/1511.06434>`_ -- one of the first and simplest of its | ||
| kind, but entirely sufficient for this task. | ||
|
|
||
| What was a GAN aGAN? |
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.
Is it a typo or an intentional pun?
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.
a pun :)
|
Here's a direct link to the preview for easier reading. https://deploy-preview-408--pytorch-tutorials-preview.netlify.com/advanced/cpp_frontend.html |
|
It looks reasonable. Do you want editing or to ship as is? |
|
looks pretty good and well-structured to me. thanks a lot Peter! :) |
| another_bias = register_parameter("b", torch::randn(M)); | ||
| } | ||
| torch::Tensor forward(torch::Tensor input) { | ||
| return linear(input) + another_bias; |
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.
A compile error occurred at this line when building with vs2017. The error disappeared after I changed linear(input) to linear->forward(input)
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.
there seems to be an issue here regarding the general syntax of the forward pass.
I suppose an overload of the call operator was intended here but as of now is not supported by neither the stable version nor the nightly build of libtorch. I find the overload highly desirable as it lends itself towards the python API and seems way more natural than having to call a forward 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.
I appreciate everyone trying out the examples, but there are some PRs that I am landing before this code works, which is why this tutorial is not yet published. The call operator is coming with pytorch/pytorch#15831 which I'll land right now, and then the example repository, and then this PR
apaszke
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.
Looks great, but I have one question
| torch::load(generator_optimizer, "generator-optimizer-checkpoint.pt"); | ||
| torch::load(discriminator, "discriminator-checkpoint.pt"); | ||
| torch::load( | ||
| discriminator_optimizer, "discriminator-optimizer-checkpoint.pt"); |
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.
Just curious: how does C++ API deal with optimizers holding references to module parameters in this case? In Python one has to be careful to pickle the optimizer together with a module to keep the sharing intact, but in here you're not doing that.
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.
Tensor deserialization is in-place in the C++ serialization API, so the tensors to which the optimizers hold references should stay valid (as I see it)
* Wrote C++ frontend tutorial * Adding image and index entry * Update links to examples repo
An end-to-end tutorial for the C++ frontend.
@soumith @ezyang maybe want to give it a quick glance?