pytorch/test/cpp/api
Mikayla Gawarecki afaee00fec Add python nested_tensor and as_nested_tensor constructors in torch.nested (#85593)
Remove `torch.nested_tensor` which has erroneous behavior wrt gradients (could be either leaf or not leaf). Introduce `torch.nested.nested_tensor` and `torch.nested.as_nested_tensor` in the vein of `torch.tensor` and `torch.as_tensor`. Done in nested `__init__.py` for now but can move to pybind in future (when we want to load from numpy/nested lists ).

Discussed offline with @cpuhrsch and pybind constructor (https://github.com/pytorch/pytorch/pull/85536) was more gnarly than expected, so we can move to that when we do need loading from numpy etc.

Differential Revision: [D39806622](https://our.internmc.facebook.com/intern/diff/D39806622)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/85593
Approved by: https://github.com/drisspg, https://github.com/cpuhrsch
2022-09-28 20:15:02 +00:00
..
any.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
autograd.cpp Add variable_list support to ExtractVariables struct (#84583) 2022-09-16 01:26:22 +00:00
CMakeLists.txt Add torch.nested namespace (#84102) 2022-09-12 16:31:05 +00:00
dataloader.cpp Build MacOS binaries with -Werror (#83049) 2022-08-10 17:29:44 +00:00
dispatch.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
enum.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
expanding-array.cpp
fft.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
functional.cpp [C++ API] Added missing antialiasing path in interpolation C++ api (#84599) 2022-09-13 03:54:07 +00:00
grad_mode.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
imethod.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
inference_mode.cpp Handle implicit real->complex casting for backward of stack (#84993) 2022-09-19 21:20:34 +00:00
init_baseline.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
init_baseline.py
init.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
integration.cpp
jit.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
memory.cpp
meta_tensor.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
misc.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
module.cpp Fix //:module_test Conversion_MultiCUDA (#79926) 2022-06-21 23:32:18 +00:00
moduledict.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
modulelist.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
modules.cpp Lower randint default dtype to the C++ API (#81410) 2022-07-21 16:42:49 +00:00
namespace.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
nested.cpp Add python nested_tensor and as_nested_tensor constructors in torch.nested (#85593) 2022-09-28 20:15:02 +00:00
nn_utils.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
operations.cpp
optim_baseline.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
optim_baseline.py
optim.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
ordered_dict.cpp
parallel_benchmark.cpp
parallel.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
parameterdict.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
parameterlist.cpp
README.md
rnn.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
sequential.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
serialize.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
special.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
static.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
support.cpp
support.h [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_cuda.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_flatten.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_indexing.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_options_cuda.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor_options.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
tensor.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00:00
torch_include.cpp
transformer.cpp [lint] autoformat test/cpp and torch/csrc 2022-06-11 21:11:16 +00: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.