You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Make tests backend aware by introducing TorchaudioTestCase and reset backend for each TestCase.
* Set backends for the test cases that require specific backend.
Copy file name to clipboardExpand all lines: test/README.md
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,16 @@ The following test modules are defined for corresponding `torchaudio` module/fun
44
44
45
45
## Adding test
46
46
47
+
The following is the current practice of torchaudio test suite.
48
+
49
+
1. Unless the tests are related to I/O, use synthetic data. [`common_utils`](./common_utils.py) has some data generator functions.
50
+
1. When you add a new test case, use `common_utils.TorchaudioTestCase` as base class unless you are writing tests that are common to CPU / CUDA.
51
+
- Set class memeber `dtype`, `device` and `backend` for the desired behavior.
52
+
- If you do not set `backend` value in your test suite, then I/O functions will be unassigned and attempt to load/save file will fail.
53
+
- For `backend` value, in addition to available backends, you can also provide the value "default" and backend will be picked automatically based on availability.
54
+
1. If you are writing tests that should pass on diffrent dtype/devices, write a common class inheriting `common_utils.TestBaseMixin`, then inherit `common_utils.PytorchTestCase` and define class attributes (`dtype` / `device` / `backend`) there. See [Torchscript consistency test implementation](./torchscript_consistency_impl.py) and test definitions for [CPU](./torchscript_consistency_cpu_test.py) and [CUDA](./torchscript_consistency_cuda_test.py) devices.
55
+
1. For numerically comparing Tensors, use `assertEqual` method from `common_utils.PytorchTestCase` class. This method has a better support for a wide variety of Tensor types.
56
+
47
57
When you add a new feature(functional/transform), consider the following
48
58
49
59
1. When you add a new feature, please make it Torchscript-able and batch-consistent unless it degrades the performance. Please add the tests to see if the new feature meet these requirements.
0 commit comments