pytorch/test/cpp/api
Will Feng ce3d024727 Make options.name_ private, and change all callsites to use options.name() (#26419)
Summary:
The implementation of several modules in C++ frontend currently has calls to `options.name_`,  which is bad practice because `options.name_` should be a private options field and we should use `options.name()` to access its value. This PR makes `options.name_` actually private and changes all callsites of `options.name_` to `options.name()`.

After this change, we can change all module options to have a map as the underlying data structure, and require that all options must be able to be stored in `c10::IValue`. These changes together would make serializing module options much easier.

Note that this PR is BC-breaking in the following way:

Previously, calling `options.name_` in C++ module implementation works because `options.name_`  was a public field. After this PR, `options.name_` becomes private, and to get the value of `options.name_` we should call `options.name()`, and to set the value of `options.name_` we should call `options.name(new_value)`.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/26419

Differential Revision: D17481507

Pulled By: yf225

fbshipit-source-id: 93e4ed0e1d79ef57104ad748809d03e25da61ed3
2019-09-19 14:48:22 -07:00
..
any.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -07:00
autograd.cpp Improve handling of mixed-type tensor operations (#22273) 2019-09-05 18:26:09 -07:00
CMakeLists.txt Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -07:00
dataloader.cpp add sorting policy to ChunkDataset (#23053) 2019-07-29 12:34:02 -07:00
expanding-array.cpp Rewrite C++ API tests in gtest (#11953) 2018-09-21 21:28:16 -07:00
functional.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -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 Fix torch::nn::init::orthogonal_ with CNNs (#18915) 2019-04-09 10:39:15 -07:00
integration.cpp Move isnan to C++ (#15722) 2019-01-08 10:42:33 -08:00
jit.cpp Add Pickler C++ API (#23241) 2019-08-12 14:43:31 -07:00
memory.cpp Hide c10::optional and nullopt in torch namespace (#12927) 2018-10-26 00:08:04 -07:00
misc.cpp C++ API parity: at::Tensor::grad 2019-09-18 09:20:38 -07:00
module.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -07:00
modulelist.cpp Adding ModuleList to modules.h (#25346) 2019-08-29 10:49:22 -07:00
modules.cpp C++ API parity: at::Tensor::grad 2019-09-18 09:20:38 -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 C++ unregister_module function for Module (#26088) 2019-09-12 18:38:57 -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 Make options.name_ private, and change all callsites to use options.name() (#26419) 2019-09-19 14:48:22 -07:00
sequential.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -07:00
serialize.cpp Re-organize C++ API torch::nn folder structure (#26262) 2019-09-17 10:07:29 -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 Revert D15920763: Move TensorOptions to ATen/core 2019-08-13 12:07:18 -07:00
tensor_options.cpp Revert D15920763: Move TensorOptions to ATen/core 2019-08-13 12:07:18 -07:00
tensor.cpp C++ API parity: at::Tensor::output_nr 2019-09-19 09:11:40 -07:00
torch_include.cpp Add get/set_num_interop_threads into torch.h include (#20659) 2019-05-20 00:34:59 -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.