Skip to content

Conversation

@gtamba
Copy link
Contributor

@gtamba gtamba commented Oct 3, 2019

Addresses #27048

PR Summary:

Files Added:

torch/csrc/api/include/torch/nn/options/normalization.h
torch/csrc/api/include/torch/nn/functional/normalization.h

Files Modified:

test/cpp/api/functional.cpp
torch/csrc/api/include/torch/nn/functional.h


@yf225 : I couldn't find a C++ equivalent of gradcheck(), is there such a function or is it sufficient to call .backward() in the test body? I don't think any solutions are checked for the Python tests.

@gtamba
Copy link
Contributor Author

gtamba commented Oct 3, 2019

@yf225 : This might be a silly question but do I need to do anything additional to get the new files included in the build targets? I couldn't find hints from other pull requests unless they were .cpp modules but now trying to build the test binary gives me a not in namespace error.

edit: Okay sorry I missed this but I I needed to add my headers to functional.h

Copy link
Contributor

@yf225 yf225 left a comment

Choose a reason for hiding this comment

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

@gtamba Thanks a lot for the great work! My sincere apologies for the delay in reviewing as I was out of office last week. I left some minor comments in the PR, and we should be able to merge it very soon :D

@yf225
Copy link
Contributor

yf225 commented Oct 7, 2019

@pytorchbot rebase this please

@gtamba
Copy link
Contributor Author

gtamba commented Oct 8, 2019

@yf225 : it seems that the bot has done a merge instead of a rebase, should I reset the head to my initial commit before the merge, add my changes and then rebase to hide the merge commit or is that all right? (I'm assuming that this sort of small PR is expected with 1 commit )

@yf225
Copy link
Contributor

yf225 commented Oct 8, 2019

@gtamba : it's totally alright and I think we should work on top of the merge commit. At PR merge time, all commits in this PR will automatically be squashed into one commit, so we don't need to worry about the number of commits we make to this PR :D

@gtamba gtamba changed the title [WIP] Add nn::functional::normalize() to C++ Frontend Add nn::functional::normalize() to C++ Frontend Oct 8, 2019
@gtamba
Copy link
Contributor Author

gtamba commented Oct 8, 2019

@pytorchbot retest this please

@gtamba
Copy link
Contributor Author

gtamba commented Oct 8, 2019

@pytorchbot retest this please

@gtamba
Copy link
Contributor Author

gtamba commented Oct 8, 2019

@pytorchbot rebase this please

@zou3519 zou3519 added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Oct 10, 2019
@gtamba gtamba force-pushed the norm_cpp branch 2 times, most recently from 4d936a7 to 849fb5e Compare October 12, 2019 14:48
@yf225
Copy link
Contributor

yf225 commented Oct 13, 2019

@gtamba I feel that we might need to add TORCH_API to all functions in torch/csrc/api/include/torch/arg.h, although it's really weird why we would need this. :/


inline Tensor normalize(
const Tensor& input,
const NormalizeOptions& options,
Copy link
Contributor

Choose a reason for hiding this comment

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

When we confirm that options = {} doesn't cause the problem, I believe we should change it back to options = {}, and it would be awesome to have a test for the F::normalize(input) (i.e. no options) use case as well :D Thanks so much for your help @gtamba !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yf225 : Can I still make these changes? I notice that facebook-bot is trying to land the pull request, and I didn't add the test for no options yet

Copy link
Contributor

Choose a reason for hiding this comment

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

@gtamba : Yes sorry this is my fault - didn't notice this before trying to land yesterday :( I saw you updated the PR (thanks a lot :D) and I will try to land it again

@gtamba
Copy link
Contributor Author

gtamba commented Oct 13, 2019

@gtamba I feel that we might need to add TORCH_API to all functions in torch/csrc/api/include/torch/arg.h, although it's really weird why we would need this. :/

I noticed that most other functions of the functional module also have a base NN Module and I couldn't find one which only has options included this way without a cpp counterpart declaration. I wonder if that could have something to do with it. But yeah I am confused from the error it's saying that it can't resolve the Options struct's internal variables, but the Options struct is pretty much identical to any other options struct in functional/

@yf225
Copy link
Contributor

yf225 commented Oct 13, 2019

@gtamba I think your assessment is correct, and I just pushed a commit to add TORCH_API to arg.h so that we don't need to have the cpp counterpart declaration. Hopefully that would work :)

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a 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.

Copy link
Contributor

@yf225 yf225 left a 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 awesome work @gtamba!

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@yf225 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@yf225 has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@yf225 merged this pull request in cc5c34a.

@gtamba gtamba deleted the norm_cpp branch October 17, 2019 09:35
@yf225
Copy link
Contributor

yf225 commented Oct 21, 2019

@gtamba Curious are you currently working on the Dropout modules? Please let me know if there is anything I can do to make the implementation easier. Thanks a lot for your help!

@gtamba
Copy link
Contributor Author

gtamba commented Oct 22, 2019

@yf225 : Yes I'm currently working on the dropout modules, it took me a while to get started due to other commitments but I should have an initial PR up soon!

@yf225
Copy link
Contributor

yf225 commented Oct 22, 2019

@gtamba Awesome thanks so much for your help! Please keep me posted how it goes :D

@gtamba
Copy link
Contributor Author

gtamba commented Oct 31, 2019

@yf225 : I am sorry for the delayed update, certain things came in the way and I could not work on this for a while. I noticed that #28424 has some relevant changes that might overlap with the rest of the dropout modules, I think I can follow the changes in Dropoutoptions in this PR? (Or just wait for it to get merged :))

@yf225
Copy link
Contributor

yf225 commented Oct 31, 2019

@gtamba : No worries about it at all! :D Yes I think #28424 is related and we also have some internal mandate to have the Dropout modules done within the next two weeks - curious do you mind if I take over the Dropout modules work instead? Thanks so much for your help again!

@gtamba
Copy link
Contributor Author

gtamba commented Nov 1, 2019

@yf225 : That's totally fine it makes sense. If you're working on something else presently though, I should have a draft PR soon and it should wrap up shortly (+ code review) after the weekend, but iterations would make it risk taking too long. Feel free to hand me anything else. Again I apologize sorry for the delay

@yf225
Copy link
Contributor

yf225 commented Nov 1, 2019

@gtamba : Thanks so much for your help! Yes in that case I think if we can have it done over the next week or so it would be really awesome (I can personally help with the iterations by making changes to the PR if necessary). Please keep me posted on how it goes :D Thanks again!

thiagocrepaldi pushed a commit to thiagocrepaldi/pytorch that referenced this pull request Feb 4, 2020
Summary:
Addresses pytorch#27048

PR Summary:

Files Added:

_torch/csrc/api/include/torch/nn/options/normalization.h
torch/csrc/api/include/torch/nn/functional/normalization.h_

Files Modified:

_test/cpp/api/functional.cpp
torch/csrc/api/include/torch/nn/functional.h_

 ---

yf225 : I couldn't find a C++ equivalent of gradcheck(), is there such a function or is it sufficient to call .backward() in the test body? I don't think any solutions are checked for the Python tests.
Pull Request resolved: pytorch#27280

Differential Revision: D17902109

Pulled By: yf225

fbshipit-source-id: 1bce1a88103d0f1848633fec90fde95ea8f3d1ed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpp Related to C++ API open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants