tkonolige commented on a change in pull request #8724:
URL: https://github.com/apache/tvm/pull/8724#discussion_r686972182



##########
File path: docs/dev/pytest_target_parametrization.rst
##########
@@ -160,6 +112,64 @@ applied to them.
     def test_function(target, dev, impl):
         # Test code goes here
 
+
+The parametrization functionality is implemented
+on top of pytest marks.  Each test function can
+be decorated with `pytest marks <pytest-marks>`_
+to include metadata.  The most frequently applied
+marks are as follows.
+
+- ``@pytest.mark.gpu`` - Tags a function as using GPU
+  capabilities. This has no effect on its own, but can be paired with
+  command-line arguments ``-m gpu`` or ``-m 'not gpu'`` to restrict
+  which tests pytest will executed.  This should be called on its own,

Review comment:
       ```suggestion
     which tests pytest will executed.  This should not be called on its own,
   ```

##########
File path: docs/dev/pytest_target_parametrization.rst
##########
@@ -160,6 +112,64 @@ applied to them.
     def test_function(target, dev, impl):
         # Test code goes here
 
+
+The parametrization functionality is implemented
+on top of pytest marks.  Each test function can
+be decorated with `pytest marks <pytest-marks>`_
+to include metadata.  The most frequently applied
+marks are as follows.
+
+- ``@pytest.mark.gpu`` - Tags a function as using GPU
+  capabilities. This has no effect on its own, but can be paired with
+  command-line arguments ``-m gpu`` or ``-m 'not gpu'`` to restrict
+  which tests pytest will executed.  This should be called on its own,
+  but is part of other marks used in unit-tests.
+
+- ``@tvm.testing.uses_gpu`` - Applies ``@pytest.mark.gpu``.  This
+  should be used to mark a unit tests that may use the GPU, if one is
+  present.  This decorator is only needed for tests that explicitly
+  loop over ``tvm.testing.enabled_targets()``, but that is no longer
+  the preferred style of writing unit tests (see below).  When using
+  ``tvm.testing.parametrize_targets()``, this decorator is implicit
+  for GPU targets, and does not need to be explicitly applied.
+
+- ``@tvm.testing.requires_gpu`` - Applies ``@tvm.testing.uses_gpu``,
+  and additionally marks that the test should be skipped
+  (``@pytest.mark.skipif``) entirely if no GPU is present.
+
+- ``@tvfm.testing.requires_RUNTIME`` - Several decorators
+  (e.g. ``@tvm.testing.requires_cuda``), each of which skips a test if
+  the specified runtime cannot be used. A runtime cannot be used if it
+  is disabled in the ``config.cmake``, or if a compatible device is
+  not present. For runtimes that use the GPU, this includes
+  ``@tvm.testing.requires_gpu``.
+
+When using parametrized targets, each test run is decorated with the
+``@tvm.testing.requires_RUNTIME`` that corresponds to the target
+being used.  As a result, if a target is disabled in ``config.cmake``
+or does not have appropriate hardware to run, it will be explicitly
+listed as skipped.
+
+There also exists a ``tvm.testing.enabled_targets()`` that returns
+all targets that are enabled and runnable on the current machine,
+based on the environment variable ``TVM_TEST_TARGETS``, the build
+configuration, and the physical hardware present.  Most current tests
+explictly loop over the targets returned from ``enabled_targets()``,
+but it is not recommended for new tests.  The pytest output for this

Review comment:
       ```suggestion
   but it should not be used for new tests.  The pytest output for this
   ```
   Just to make things explicit.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to