Skip to content

Commit

Permalink
[Tests] [TVMC] add tests for filter_tasks utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp v. K committed Aug 22, 2022
1 parent e53e054 commit d249a35
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/python/driver/tvmc/test_autotuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from tvm import autotvm
from tvm.driver import tvmc
from tvm.driver.tvmc.autotuner import filter_tasks


def _get_tasks(model):
Expand Down Expand Up @@ -182,3 +183,23 @@ def test_tune_rpc_tracker_parsing(mock_load_model, mock_tune_model, mock_auto_sc
assert "10.0.0.1" == kwargs["hostname"]
assert "port" in kwargs
assert 9999 == kwargs["port"]


def test_filter_tasks_valid():
filter_tasks(list(range(10)), "list") == ([], True)
filter_tasks(list(range(10)), "help") == ([], True)
filter_tasks(list(range(10)), "all") == ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], False)
filter_tasks(list(range(10)), "5") == ([5], False)
filter_tasks(list(range(10)), "1-5") == ([1, 2, 3, 4, 5], False)
filter_tasks(list(range(10)), "-5") == ([0, 1, 2, 3, 4, 5], False)
filter_tasks(list(range(10)), "6-") == ([6, 7, 8, 9], False)
filter_tasks(list(range(10)), "0,1-3,all") == ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], False)
filter_tasks(list(range(10)), "0,4-5,9,list") == ([0, 4, 5, 9], True)


@pytest.mark.xfail
def test_filter_tasks_invalid():
filter_tasks(list(range(10)), "10")
filter_tasks(list(range(10)), "5,10")
filter_tasks(list(range(10)), "1-10")
filter_tasks(list(range(10)), "-10")

0 comments on commit d249a35

Please sign in to comment.