Skip to content

Conversation

@CarMiranda
Copy link
Contributor

Hi @yf225 , here is the C++ frontend API MultiMarginLoss implementation and tests #27198. Could you review it and tell me if it is okay?

I am not entirely sure I used c10::optional correctly, but options.weight() resulted in a compilation error, so I went with options.weight().value() instead of value_or() to follow the logic in torch.nn._WeightedLoss.register_buffer (where one can pass a None value).

Oh, and are the tests supposed to be skipped or did I do something wrong? I ran pytest test/test_cpp_api_parity.py -k Loss -v , and the L1Loss test passed but the others were skipped...

Thank you for the review in any case!

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.

@CarMiranda Thanks so much for the great work! I left some very minor comments, and we should be able to merge it very soon :D

@CarMiranda CarMiranda requested a review from yf225 October 8, 2019 11:06
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 a lot for the changes @CarMiranda! It seems that there is test failure for the newly added tests, we might need to debug it locally to see what causes the test failure.

@yf225
Copy link
Contributor

yf225 commented Oct 8, 2019

@CarMiranda We can use these steps to run the tests:

@CarMiranda
Copy link
Contributor Author

It looks like the errors came from precision, I just replaced 0.3056 by 0.305556 and that did the trick!
Thank you for your reviews @yf225 !

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 a lot for the awesome work @CarMiranda! I will merge it after CI passes :D

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

@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 3246fdd.

thiagocrepaldi pushed a commit to thiagocrepaldi/pytorch that referenced this pull request Feb 4, 2020
Summary:
Hi yf225 , here is the C++ frontend API MultiMarginLoss implementation and tests pytorch#27198. Could you review it and tell me if it is okay?

I am not entirely sure I used `c10::optional` correctly, but `options.weight()` resulted in a compilation error, so I went with `options.weight().value()` instead of `value_or()` to follow the logic in `torch.nn._WeightedLoss.register_buffer` (where one can pass a `None` value).

Oh, and are the tests supposed to be skipped or did I do something wrong? I ran `pytest test/test_cpp_api_parity.py -k Loss -v` , and the `L1Loss` test passed but the others were skipped...

Thank you for the review in any case!
Pull Request resolved: pytorch#27424

Differential Revision: D17839963

Pulled By: yf225

fbshipit-source-id: f4b6012590cf22d56d42751c214df80cce717cb8
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants