pytorch/test/cpp
Carlos Miranda 3246fddfd6 Implement C++ API torch::nn::MultiMarginLoss. (#27424)
Summary:
Hi yf225 , here is the C++ frontend API MultiMarginLoss implementation and tests https://github.com/pytorch/pytorch/issues/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: https://github.com/pytorch/pytorch/pull/27424

Differential Revision: D17839963

Pulled By: yf225

fbshipit-source-id: f4b6012590cf22d56d42751c214df80cce717cb8
2019-10-09 14:44:41 -07:00
..
api Implement C++ API torch::nn::MultiMarginLoss. (#27424) 2019-10-09 14:44:41 -07:00
common Trim libshm deps, move tempfile.h to c10 (#17019) 2019-02-13 19:38:35 -08:00
dist_autograd Add send and recv backward functions for builtin operators RPC. (#25527) 2019-10-03 01:18:46 -07:00
jit Add OPN instruction and vararg operator table (#27104) 2019-10-04 09:35:53 -07:00
__init__.py Add train() / eval() / is_training() to C++ ScriptModule API (#16044) 2019-02-01 13:07:38 -08:00