xref: /aosp_15_r20/external/pytorch/test/cpp/api/README.md (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1*da0073e9SAndroid Build Coastguard Worker# C++ Frontend Tests
2*da0073e9SAndroid Build Coastguard Worker
3*da0073e9SAndroid Build Coastguard WorkerIn this folder live the tests for PyTorch's C++ Frontend. They use the
4*da0073e9SAndroid Build Coastguard Worker[GoogleTest](https://github.com/google/googletest) test framework.
5*da0073e9SAndroid Build Coastguard Worker
6*da0073e9SAndroid Build Coastguard Worker## CUDA Tests
7*da0073e9SAndroid Build Coastguard Worker
8*da0073e9SAndroid Build Coastguard WorkerTo make a test runnable only on platforms with CUDA, you should suffix your
9*da0073e9SAndroid Build Coastguard Workertest with `_CUDA`, e.g.
10*da0073e9SAndroid Build Coastguard Worker
11*da0073e9SAndroid Build Coastguard Worker```cpp
12*da0073e9SAndroid Build Coastguard WorkerTEST(MyTestSuite, MyTestCase_CUDA) { }
13*da0073e9SAndroid Build Coastguard Worker```
14*da0073e9SAndroid Build Coastguard Worker
15*da0073e9SAndroid Build Coastguard WorkerTo make it runnable only on platforms with at least two CUDA machines, suffix
16*da0073e9SAndroid Build Coastguard Workerit with `_MultiCUDA` instead of `_CUDA`, e.g.
17*da0073e9SAndroid Build Coastguard Worker
18*da0073e9SAndroid Build Coastguard Worker```cpp
19*da0073e9SAndroid Build Coastguard WorkerTEST(MyTestSuite, MyTestCase_MultiCUDA) { }
20*da0073e9SAndroid Build Coastguard Worker```
21*da0073e9SAndroid Build Coastguard Worker
22*da0073e9SAndroid Build Coastguard WorkerThere is logic in `main.cpp` that detects the availability and number of CUDA
23*da0073e9SAndroid Build Coastguard Workerdevices and supplies the appropriate negative filters to GoogleTest.
24*da0073e9SAndroid Build Coastguard Worker
25*da0073e9SAndroid Build Coastguard Worker## Integration Tests
26*da0073e9SAndroid Build Coastguard Worker
27*da0073e9SAndroid Build Coastguard WorkerIntegration tests use the MNIST dataset. You must download it by running the
28*da0073e9SAndroid Build Coastguard Workerfollowing command from the PyTorch root folder:
29*da0073e9SAndroid Build Coastguard Worker
30*da0073e9SAndroid Build Coastguard Worker```sh
31*da0073e9SAndroid Build Coastguard Worker$ python tools/download_mnist.py -d test/cpp/api/mnist
32*da0073e9SAndroid Build Coastguard Worker```
33*da0073e9SAndroid Build Coastguard Worker
34*da0073e9SAndroid Build Coastguard WorkerThe required paths will be referenced as `test/cpp/api/mnist/...` in the test
35*da0073e9SAndroid Build Coastguard Workercode, so you *must* run the integration tests from the PyTorch root folder.
36