Skip to content

[S-TIR][Test] Use tvm.testing.main() so schedule tests can run standalone - #20283

Open
Anai-Guo wants to merge 1 commit into
apache:mainfrom
Anai-Guo:fix/s-tir-schedule-test-main-entry
Open

[S-TIR][Test] Use tvm.testing.main() so schedule tests can run standalone#20283
Anai-Guo wants to merge 1 commit into
apache:mainfrom
Anai-Guo:fix/s-tir-schedule-test-main-entry

Conversation

@Anai-Guo

@Anai-Guo Anai-Guo commented Sep 7, 2026

Copy link
Copy Markdown

Problem

Two files under tests/python/s_tir/schedule/ cannot be run standalone.

1. tvm.testing is used but never imported

Both test_tir_schedule_storage_align.py and test_tir_schedule_read_write_at.py
reference tvm.testing while importing only import tvm:

import tvm
from tvm import tirx

tvm/__init__.py does not pull in tvm.testing, so the attribute only resolves
because pytest has already imported the submodule elsewhere in the session.
Running either file directly gives:

AttributeError: module 'tvm' has no attribute 'testing'

These are the only two files in the directory with that gap.

2. test_tir_schedule_storage_align.py has a broken __main__ block

use_block_name = tvm.testing.parameter(by_dict={"block_obj": False, "block_name": True})

def test_storage_align(use_block_name):
    ...

if __name__ == "__main__":
    test_storage_align()          # <-- no argument for the fixture
    test_storage_align_update()
    ...

test_storage_align takes the parametrized use_block_name fixture, so the
first line of the __main__ block raises:

TypeError: test_storage_align() missing 1 required positional argument: 'use_block_name'

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.testing to both files, and replace the
hand-written call list with tvm.testing.main(), which is what 36 of the 39
files in tests/python/s_tir/schedule/ already do (including
test_tir_schedule_read_write_at.py) and which handles parametrized tests
correctly.

Test behaviour under pytest is unchanged — this only affects direct
python tests/python/s_tir/schedule/test_...py invocation.

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant