You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "tlopex (via GitHub)" <gi...@apache.org> on 2026/06/17 00:13:26 UTC
[PR] [Tests] Migrate tvm.testing.parameters() to pytest.mark.parametrize [tvm]
tlopex opened a new pull request, #19803:
URL: https://github.com/apache/tvm/pull/19803
This pr phases out the custom `tvm.testing.parameters()` helper in favor of native `@pytest.mark.parametrize`. `parameters()` itself is left in place for now and removed in a follow-up, together with updating the framework self-test (`tests/python/testing/test_tvm_testing_features.py`) that exercises it.
Migration rules
- A group consumed only by test functions becomes `@pytest.mark.parametrize`.
- Single-name groups are unwrapped from 1-tuples to bare values.
- A group shared by multiple tests uses a module-level named list; a test that uses only a subset of a group's names is parametrized only on the names in its signature.
- `@pytest.mark.parametrize` is stacked above the existing, unrelated `@tvm.testing.parametrize_targets(...)`, which is kept as-is.
Per-file pytest collection case counts are unchanged, except the two intentional changes below.
Behavior changes (intentional)
- tests/python/relax/test_training_optimizer_numeric.py: the names `lr` and `weight_decay` were rebound across three `parameters()` groups, so `test_sgd` and `test_momentum_sgd` silently used the *adam* group's `lr`/`weight_decay` (and `test_momentum_sgd` cross-producted with it: 2/6/2 = 10 cases). Native parametrize gives each test its own co-located group: 2/3/2 = 7 cases. This fixes that latent rebinding bug; the case count drops 10 -> 7 and `test_momentum_sgd` now exercises its own `weight_decay` values.
- tests/python/target/test_arm_target.py: its `parameters()` group was orphaned (no test consumed those names) — removed the dead definition.
Note: for tests that also use `@tvm.testing.parametrize_targets`, the generated test ids reorder the target (e.g. `test_unary[abs-True-llvm]` -> `test_unary[llvm-abs-True]`); values and case counts are unchanged.
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [Tests] Migrate tvm.testing.parameters() to pytest.mark.parametrize [tvm]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #19803:
URL: https://github.com/apache/tvm/pull/19803#discussion_r3424782113
##########
tests/python/s_tir/base/test_tir_te_extern_primfunc.py:
##########
@@ -172,19 +172,22 @@ def verify_func_4(module):
tvm.testing.assert_allclose(a_np + 1, f.numpy(), rtol=1e-4)
-class TestPrimFuncs:
- func, params, verify = tvm.testing.parameters(
- [func_1, ("A"), verify_func_1],
- [func_2, ("C", "D"), verify_func_2],
- [func_3, ("C", "A", "D", "E"), verify_func_3],
- [func_4, ("C", "A", "D", "E"), verify_func_4],
- )
+_primfunc_cases = [
+ [func_1, ("A"), verify_func_1],
Review Comment:

In Python, `("A")` is evaluated as a simple string `"A"` rather than a 1-tuple. Since `params` is expected to be an iterable of parameter names (strings), passing a plain string will cause the test to iterate over its individual characters (e.g., `'A'`). While this happens to work for a single-character name like `"A"`, it is extremely fragile and will fail with a `KeyError` if the parameter name is changed to a multi-character string (e.g., `"A_buf"`).\n\nPlease change `("A")` to a proper 1-tuple `("A",)` or a list `["A"]` to ensure it is treated as a sequence of strings.
```suggestion
[func_1, ("A",), verify_func_1],
```
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [Tests] Migrate tvm.testing.parameters() to pytest.mark.parametrize [tvm]
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #19803:
URL: https://github.com/apache/tvm/pull/19803
--
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: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org