pytorch/test/cpp/api
Peter Goldsborough 393ad6582d Use torch:: instead of at:: in all C++ APIs (#13523)
Summary:
In TorchScript and C++ extensions we currently advocate a mix of `torch::` and `at::` namespace usage. In the C++ frontend I had instead exported all symbols from `at::` and some from `c10::` into the `torch::` namespace. This is far, far easier for users to understand, and also avoid bugs around creating tensors vs. variables. The same should from now on be true for the TorchScript C++ API (for running and loading models) and all C++ extensions.

Note that since we're just talking about typedefs, this change does not break any existing code.

Once this lands I will update stuff in `pytorch/tutorials` too.

zdevito ezyang gchanan
Pull Request resolved: https://github.com/pytorch/pytorch/pull/13523

Differential Revision: D12942787

Pulled By: goldsborough

fbshipit-source-id: 76058936bd8707b33d9e5bbc2d0705fc3d820763
2018-11-06 14:32:25 -08:00
..
any.cpp Remove size() from BatchDataset and templatize IndexType (#12960) 2018-11-05 17:13:09 -08:00
CMakeLists.txt Implement DataLoader (#11918) 2018-10-22 10:22:41 -07:00
cursor.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
dataloader.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
expanding-array.cpp Rewrite C++ API tests in gtest (#11953) 2018-09-21 21:28:16 -07:00
integration.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
jit.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
memory.cpp Hide c10::optional and nullopt in torch namespace (#12927) 2018-10-26 00:08:04 -07:00
misc.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
module.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
modules.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08: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 Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
ordered-dict.cpp Rewrite C++ API tests in gtest (#11953) 2018-09-21 21:28:16 -07:00
parallel.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
README.md Rewrite C++ API tests in gtest (#11953) 2018-09-21 21:28:16 -07:00
rnn.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
sequential.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
serialize.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
static.cpp Rewrite C++ API tests in gtest (#11953) 2018-09-21 21:28:16 -07:00
support.h Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
tensor_cuda.cpp Add tensor.to(options) (#13146) 2018-10-29 16:26:06 -07:00
tensor_options_cuda.cpp Replace CUDA-specific set_index(_from) method from DeviceGuard with set_device. (#13275) 2018-10-31 07:55:13 -07:00
tensor_options.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08:00
tensor.cpp Use torch:: instead of at:: in all C++ APIs (#13523) 2018-11-06 14:32:25 -08: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.