pytorch/test/cpp/api
Peter Goldsborough c5de3314cf Add name() to C++ modules (#7409)
* Add name() to C++ modules

* Use RTTI to get module name by default

* Add functional.cpp to CMakeLists.txt

* Call typeid() inside name() instead of constructor

* Add tests and use default constructor
2018-05-10 08:52:38 -07:00
..
container.cpp Use set_type to implement type conversions in C++ API (#7408) 2018-05-09 17:01:19 -04:00
integration.cpp Use set_type to implement type conversions in C++ API (#7408) 2018-05-09 17:01:19 -04:00
main.cpp Rename autograd namespace to torch and change torch.h into python.h (#7267) 2018-05-04 08:04:57 -07:00
misc.cpp Rename Container to Module in autogradpp and reorg code (#7304) 2018-05-07 14:45:00 -07:00
module.cpp Add name() to C++ modules (#7409) 2018-05-10 08:52:38 -07:00
optim.cpp Rename Container to Module in autogradpp and reorg code (#7304) 2018-05-07 14:45:00 -07:00
README.md Update C++ API tests to use Catch2 (#7108) 2018-04-30 21:36:35 -04:00
rnn.cpp Rename Container to Module in autogradpp and reorg code (#7304) 2018-05-07 14:45:00 -07:00
serialization.cpp Rename Container to Module in autogradpp and reorg code (#7304) 2018-05-07 14:45:00 -07:00

C++ API Tests

In this folder live the tests for PyTorch's C++ API (formerly known as autogradpp). They use the Catch2 test framework.

CUDA Tests

The way we handle CUDA tests is by separating them into a separate TEST_CASE (e.g. we have optim and optim_cuda test cases in optim.cpp), and giving them the [cuda] tag. Then, inside main.cpp we detect at runtime whether CUDA is available. If not, we disable these CUDA tests by appending ~[cuda] to the test specifications. The ~ disables the tag.

One annoying aspect is that Catch only allows filtering on test cases and not sections. Ideally, one could have a section like LSTM inside the RNN test case, and give this section a [cuda] tag to only run it when CUDA is available. Instead, we have to create a whole separate RNN_cuda test case and put all these CUDA sections in there.

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