[S-TIR][Test] Use tvm.testing.main() so schedule tests can run standalone - #20283
Open
Anai-Guo wants to merge 1 commit into
Open
[S-TIR][Test] Use tvm.testing.main() so schedule tests can run standalone#20283Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
…lone
test_tir_schedule_storage_align.py and test_tir_schedule_read_write_at.py
both call `tvm.testing.*` without importing `tvm.testing`. That only works
under pytest, where the plugin has already imported the submodule; running
either file directly raises
AttributeError: module 'tvm' has no attribute 'testing'
test_tir_schedule_storage_align.py has a second problem: its hand-written
`__main__` block calls
test_storage_align()
but that test takes the parametrized fixture `use_block_name`
(`tvm.testing.parameter(by_dict={"block_obj": False, "block_name": True})`),
so the call raises
TypeError: test_storage_align() missing 1 required positional argument:
'use_block_name'
36 of the 39 files in tests/python/s_tir/schedule already end with
`tvm.testing.main()`, which runs the whole module including parametrized
tests. Adopt that idiom here and add the missing imports.
Signed-off-by: Tai An <antai12232931@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two files under
tests/python/s_tir/schedule/cannot be run standalone.1.
tvm.testingis used but never importedBoth
test_tir_schedule_storage_align.pyandtest_tir_schedule_read_write_at.pyreference
tvm.testingwhile importing onlyimport tvm:tvm/__init__.pydoes not pull intvm.testing, so the attribute only resolvesbecause pytest has already imported the submodule elsewhere in the session.
Running either file directly gives:
These are the only two files in the directory with that gap.
2.
test_tir_schedule_storage_align.pyhas a broken__main__blocktest_storage_aligntakes the parametrizeduse_block_namefixture, so thefirst line of the
__main__block raises:The hand-maintained list is also stale-prone — it has to be updated by hand
every time a test is added.
Fix
Add the missing
import tvm.testingto both files, and replace thehand-written call list with
tvm.testing.main(), which is what 36 of the 39files in
tests/python/s_tir/schedule/already do (includingtest_tir_schedule_read_write_at.py) and which handles parametrized testscorrectly.
Test behaviour under pytest is unchanged — this only affects direct
python tests/python/s_tir/schedule/test_...pyinvocation.🤖 Generated with Claude Code