-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[C++] Add nn.Bilinear to C++ Frontend #26082
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
|
@MJ10 Thanks a lot for the PR! We might need to remove the changes in third_party/fbgemm because they are unrelated and likely due to out-of-sync submodule. |
|
@yf225 thanks for pointing that out! I've removed it. |
|
@MJ10 Thanks a lot! I am curious would you like to select "allow updates from maintainers" as in https://help.github.com/en/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork? |
|
@yf225 it's already enabled |
|
@yf225 do let me know if any changes are required, would be happy to update this PR :) |
yf225
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.
@MJ10 Thanks so much for the contribution and my sincere apologies for the delay. :( The folder structure of C++ torch::nn modules have changed considerably in the past few weeks, and we have finally settled down on the design. I believe we can easily move this PR to the new design and will be able to merge it very soon. :) Thanks again!
| class TORCH_API BilinearImpl : public Cloneable<BilinearImpl> { | ||
| public: | ||
| BilinearImpl(int64_t in1, int64_t in2, int64_t out) : BilinearImpl(BilinearOptions(in1, in2, out)) {} | ||
| explicit BilinearImpl(BilinearOptions options); |
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.
It would be awesome to change this to
| explicit BilinearImpl(BilinearOptions options); | |
| explicit BilinearImpl(const BilinearOptions& options_); |
to match the design of other torch::nn modules.
|
@yf225 Thanks for the detailed comments! Apologies I couldn't follow the change in the design apologies for the delay. I've made the requested changes. |
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 so much for the changes @MJ10! I left some comments, and we should be able to merge this PR very soon :D
|
|
||
| void BilinearImpl::reset() { | ||
| weight = | ||
| register_parameter("weight", torch::empty({options.out_features_, options.in1_features_, options.in2_features_})); |
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.
options.name_ are private now and we would need to change it to options.name(). (For example, options.out_features_ would be options.out_features().)
|
@MJ10 I fixed a code conflict using the github code editor, and I believe we would need to pull from the remote branch first. :D |
|
|
||
| BilinearOptions::BilinearOptions(int64_t in1_features, int64_t in2_features, int64_t out_features) : in1_features_(in1_features), in2_features_(in2_features), out_features_(out_features) {} | ||
|
|
||
| BilinearImpl::BilinearImpl(BilinearOptions options) : options(options) { |
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.
We would need to also change this to:
| BilinearImpl::BilinearImpl(BilinearOptions options) : options(options) { | |
| BilinearImpl::BilinearImpl(const BilinearOptions& options_) : options(options_) { |
|
@pytorchbot rebase this please |
|
This is blocked by #27948. I will merge that PR as soon as possible to unblock this. |
|
Thanks a lot @yf225 ! |
Summary:
C++ API `Module::register_parameter` should accept undefined Tensor as parameter, which is equivalent to `module.register_parameter("param", None)` in Python API.
This unblocks #26082 and #27156.
Pull Request resolved: #27948
Differential Revision: D17931739
Pulled By: yf225
fbshipit-source-id: 21bdfc88e66e3dc39f3caf608a6a3de48c510fa9
|
@pytorchbot rebase this please |
facebook-github-bot
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.
@yf225 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
Thanks a lot for all the help @yf225 |
…#27948) Summary: C++ API `Module::register_parameter` should accept undefined Tensor as parameter, which is equivalent to `module.register_parameter("param", None)` in Python API. This unblocks pytorch#26082 and pytorch#27156. Pull Request resolved: pytorch#27948 Differential Revision: D17931739 Pulled By: yf225 fbshipit-source-id: 21bdfc88e66e3dc39f3caf608a6a3de48c510fa9
Summary: Adds support for the Bilinear layer to the C++ frontend Pull Request resolved: pytorch#26082 Differential Revision: D17954148 Pulled By: yf225 fbshipit-source-id: 5e746bdea29b00e25969cd7a22044b8059b53687
Adds support for the Bilinear layer to the C++ frontend