This is an automated email from the ASF dual-hosted git repository.
tlopex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new ddfec9c3d6 [Tests] Remove the now-unused tvm.testing.parameters()
helper (#19807)
ddfec9c3d6 is described below
commit ddfec9c3d670358dd75225f1cf9fbfb6c9b0cdfa
Author: Shushi Hong <[email protected]>
AuthorDate: Wed Jun 17 00:32:33 2026 -0400
[Tests] Remove the now-unused tvm.testing.parameters() helper (#19807)
All in-tree uses of tvm.testing.parameters() were migrated to native
pytest.mark.parametrize in #19803, so remove the helper itself along
with the plugin machinery that only served it:
- python/tvm/testing/utils.py: delete the parameters() function and the
_parametrize_group counter.
- python/tvm/testing/plugin.py: delete
_parametrize_correlated_parameters and its call in
pytest_generate_tests.
- tests/python/testing/test_tvm_testing_features.py: drop the
joint-parameter tests that exercised parameters() (the parameter() and
fixture() tests stay).
This removes the public tvm.testing.parameters symbol;
tvm.testing.parameter (singular) and tvm.testing.fixture are unchanged.
Use pytest.mark.parametrize instead.
---
python/tvm/testing/plugin.py | 30 ----------
python/tvm/testing/utils.py | 71 -----------------------
tests/python/testing/test_tvm_testing_features.py | 22 +------
3 files changed, 1 insertion(+), 122 deletions(-)
diff --git a/python/tvm/testing/plugin.py b/python/tvm/testing/plugin.py
index 91aeb6374f..8f7cd0c516 100644
--- a/python/tvm/testing/plugin.py
+++ b/python/tvm/testing/plugin.py
@@ -69,7 +69,6 @@ def pytest_addoption(parser):
def pytest_generate_tests(metafunc):
"""Called once per unit test, modifies/parametrizes it as needed."""
- _parametrize_correlated_parameters(metafunc)
_auto_parametrize_target(metafunc)
_add_target_specific_marks(metafunc)
@@ -320,35 +319,6 @@ def _target_to_requirement(target):
return []
-def _parametrize_correlated_parameters(metafunc):
- parametrize_needed = {}
-
- for name, fixturedefs in
metafunc.definition._fixtureinfo.name2fixturedefs.items():
- fixturedef = fixturedefs[-1]
- if hasattr(fixturedef.func, "parametrize_group") and hasattr(
- fixturedef.func, "parametrize_values"
- ):
- group = fixturedef.func.parametrize_group
- values = fixturedef.func.parametrize_values
- ids = fixturedef.func.parametrize_ids
- if group in parametrize_needed:
- assert ids == parametrize_needed[group]["ids"]
- else:
- parametrize_needed[group] = {"ids": ids, "params": []}
- parametrize_needed[group]["params"].append((name, values))
-
- for parametrize_group in parametrize_needed.values():
- params = parametrize_group["params"]
- ids = parametrize_group["ids"]
- if len(params) == 1:
- name, values = params[0]
- metafunc.parametrize(name, values, indirect=True, ids=ids)
- else:
- names = ",".join(name for name, values in params)
- value_sets = zip(*[values for name, values in params])
- metafunc.parametrize(names, value_sets, indirect=True, ids=ids)
-
-
# pytest-xdist isn't required but is used in CI, so guard on its presence
if HAVE_XDIST:
diff --git a/python/tvm/testing/utils.py b/python/tvm/testing/utils.py
index c686bc1184..8f5c56eb5b 100644
--- a/python/tvm/testing/utils.py
+++ b/python/tvm/testing/utils.py
@@ -794,77 +794,6 @@ def parameter(*values, ids=None, by_dict=None):
return as_fixture
-_parametrize_group = 0
-
-
-def parameters(*value_sets, ids=None):
- """Convenience function to define pytest parametrized fixtures.
-
- Declaring a variable using tvm.testing.parameters will define a
- parametrized pytest fixture that can be used by test
- functions. Like :py:func:`tvm.testing.parameter`, this is intended
- for cases that have no setup cost, such as strings, integers,
- tuples, etc. For cases that have a significant setup cost, please
- use :py:func:`tvm.testing.fixture` instead.
-
- Unlike :py:func:`tvm.testing.parameter`, if a test function
- accepts multiple parameters defined using a single call to
- ``tvm.testing.parameters``, then the test will only be run once
- for each set of parameters, not for all combinations of
- parameters.
-
- These parameter definitions apply to all tests in a module. If a
- specific test should have different values for some parameters,
- that test should be marked with ``@pytest.mark.parametrize``.
-
- Parameters
- ----------
- values : List[tuple]
-
- A list of parameter value sets. Each set of values represents
- a single combination of values to be tested. A unit test that
- accepts parameters defined will be run once for every set of
- parameters in the list.
-
- ids : List[str], optional
-
- A list of names for the parameter sets. If None, pytest will
- generate a name from each parameter set. These generated names may
- not be readable/useful for composite types such as tuples.
-
- Returns
- -------
- List[function]
- Function outputs from pytest.fixture. These should be unpacked
- into individual named parameters.
-
- Example
- -------
- >>> size, dtype = tvm.testing.parameters( (16,'float32'), (512,'float16') )
- >>> def test_feature_x(size, dtype):
- >>> # Test code here
- >>> assert( (size,dtype) in [(16,'float32'), (512,'float16')])
-
- """
- global _parametrize_group
- parametrize_group = _parametrize_group
- _parametrize_group += 1
-
- outputs = []
- for param_values in zip(*value_sets):
- # Optional cls parameter in case a parameter is defined inside a
- # class scope.
- def fixture_func(*_cls, request):
- return request.param
-
- fixture_func.parametrize_group = parametrize_group
- fixture_func.parametrize_values = param_values
- fixture_func.parametrize_ids = ids
- outputs.append(pytest.fixture(fixture_func))
-
- return outputs
-
-
def fixture(func=None, *, cache_return_value=False):
"""Convenience function to define pytest fixtures.
diff --git a/tests/python/testing/test_tvm_testing_features.py
b/tests/python/testing/test_tvm_testing_features.py
index 3cf6d019e6..071da7b9bc 100644
--- a/tests/python/testing/test_tvm_testing_features.py
+++ b/tests/python/testing/test_tvm_testing_features.py
@@ -108,7 +108,7 @@ class TestTargetAutoParametrization:
assert target != "llvm"
-class TestJointParameter:
+class TestParameter:
param1_vals = [1, 2, 3]
param2_vals = ["a", "b", "c"]
@@ -116,32 +116,12 @@ class TestJointParameter:
param1 = tvm.testing.parameter(*param1_vals)
param2 = tvm.testing.parameter(*param2_vals)
- joint_usages = 0
- joint_param_vals = list(zip(param1_vals, param2_vals))
- joint_param_ids = ["apple", "pear", "banana"]
- joint_param1, joint_param2 = tvm.testing.parameters(*joint_param_vals,
ids=joint_param_ids)
-
def test_using_independent(self, param1, param2):
type(self).independent_usages += 1
def test_independent(self):
assert self.independent_usages == len(self.param1_vals) *
len(self.param2_vals)
- def test_using_joint(self, joint_param1, joint_param2):
- type(self).joint_usages += 1
- assert (joint_param1, joint_param2) in self.joint_param_vals
-
- def test_joint(self):
- assert self.joint_usages == len(self.joint_param_vals)
-
- def test_joint_test_id(self, joint_param1, joint_param2, request):
- param_string = (
- request.node.name.replace(request.node.originalname, "")
- .replace("[", "")
- .replace("]", "")
- )
- assert param_string in self.joint_param_ids
-
class TestFixtureCaching:
param1_vals = [1, 2, 3]