pytorch/test/cpp/api
Shahriar 91a260cef9 Adding MSELoss, KLDivLoss and BCELoss to C++ front-end (#27156)
Summary:
This PR adds ```MSELoss```, ```KLDivLoss``` and ```BCELoss```. The tests for ```BCELoss``` fail with the following error:
```
unknown file: Failure
C++ exception with description "autograd_meta() INTERNAL ASSERT FAILED at /home/shahriar/Contrib/pytorch/c10/core/TensorImpl.h:533, please report a bug to PyTorch. set_requires_grad is not implemented for Tensor (set_requires_grad at /home/shahriar/Contrib/pytorch/c10/core/TensorImpl.h:533)
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/27156

Differential Revision: D17960323

Pulled By: yf225

fbshipit-source-id: 84b8431064f2f573679c03a8d7994e3e2f81a4d1
2019-10-17 22:07:01 -07:00
..
any.cpp Separate libtorch tests from libtorch build. (#26927) 2019-10-02 08:04:52 -07:00
autograd.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
CMakeLists.txt Use torch::variant for enums in C++ API 2019-10-16 22:40:57 -07:00
dataloader.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
enum.cpp Use torch::variant for enums in C++ API 2019-10-16 22:40:57 -07:00
expanding-array.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
functional.cpp Adding MSELoss, KLDivLoss and BCELoss to C++ front-end (#27156) 2019-10-17 22:07:01 -07:00
init_baseline.h Kaiming Initialization (#14718) 2019-02-15 14:58:22 -08:00
init_baseline.py Kaiming Initialization (#14718) 2019-02-15 14:58:22 -08:00
init.cpp Use torch::variant for enums in C++ API 2019-10-16 22:40:57 -07:00
integration.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
jit.cpp Remove attempToRecoverType (#26767) 2019-10-16 11:07:13 -07:00
memory.cpp Hide c10::optional and nullopt in torch namespace (#12927) 2018-10-26 00:08:04 -07:00
misc.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
module.cpp Allow passing undefined Tensor to Module::register_parameter (#27948) 2019-10-15 10:10:42 -07:00
modulelist.cpp Implement torch.nn.Embedding / EmbeddingBag in PyTorch C++ API (#26358) 2019-10-08 22:13:39 -07:00
modules.cpp Adding MSELoss, KLDivLoss and BCELoss to C++ front-end (#27156) 2019-10-17 22:07:01 -07:00
nn_utils.cpp Add clip_grad_norm_ to c++ api (#26140) 2019-10-04 13:50:36 -07:00
optim_baseline.h Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
optim_baseline.py Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
optim.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -07:00
ordered_dict.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
parallel.cpp C++ API parity: at::Tensor::grad 2019-09-18 09:20:38 -07:00
README.md Rewrite C++ API tests in gtest (#11953) 2018-09-21 21:28:16 -07:00
rnn.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
sequential.cpp Implement torch.nn.Embedding / EmbeddingBag in PyTorch C++ API (#26358) 2019-10-08 22:13:39 -07:00
serialize.cpp Make JIT Serialization support arbitrary std::function<> IO (#28039) 2019-10-15 22:12:04 -07:00
static.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -07:00
support.h Add TORCH_WARN_ONCE, and use it in Tensor.data<T>() (#25207) 2019-08-27 21:42:44 -07:00
tensor_cuda.cpp Deprecate tensor.data<T>(), and codemod tensor.data<T>() to tensor.data_ptr<T>() (#24886) 2019-08-21 20:11:24 -07:00
tensor_options_cuda.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
tensor_options.cpp Change C++ API test files to only include torch/torch.h (#27067) 2019-10-10 09:46:29 -07:00
tensor.cpp codemod at::ArrayRef and torch::IntArrayRef to std::vector in C++ API tests (#27884) 2019-10-14 18:00:30 -07:00
torch_include.cpp Relax set_num_threads restriction in parallel native case (#27947) 2019-10-16 21:53:36 -07:00

C++ Frontend Tests

In this folder live the tests for PyTorch's C++ Frontend. They use the GoogleTest test framework.

CUDA Tests

To make a test runnable only on platforms with CUDA, you should suffix your test with _CUDA, e.g.

TEST(MyTestSuite, MyTestCase_CUDA) { }

To make it runnable only on platforms with at least two CUDA machines, suffix it with _MultiCUDA instead of _CUDA, e.g.

TEST(MyTestSuite, MyTestCase_MultiCUDA) { }

There is logic in main.cpp that detects the availability and number of CUDA devices and supplies the appropriate negative filters to GoogleTest.

Integration Tests

Integration tests use the MNIST dataset. You must download it by running the following command from the PyTorch root folder:

$ python tools/download_mnist.py -d test/cpp/api/mnist

The required paths will be referenced as test/cpp/api/mnist/... in the test code, so you must run the integration tests from the PyTorch root folder.