Skip to content

Commit 1772b6c

Browse files
committed
[TVMC] Lint filter_tasks code
1 parent 2d332b3 commit 1772b6c

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

python/tvm/driver/tvmc/autotuner.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,19 @@ def drive_tune(args):
303303

304304

305305
def filter_tasks(
306-
tasks: Optional[Union[auto_scheduler.SearchTask, autotvm.task.Task]],
306+
tasks: Union[List[auto_scheduler.SearchTask], List[autotvm.task.Task]],
307307
expr: str,
308308
):
309+
"""Utility to filter a list of tasks (AutoTVM or AutoScheduler) based on
310+
a user-supplied string expression.
311+
312+
Parameters
313+
----------
314+
tasks: list
315+
A list of extracted AutoTVM or AutoScheduler tasks.
316+
expr: str
317+
User-supplied expression to be used for filtering.
318+
"""
309319
assert isinstance(expr, str), "Expected filter expression of string type"
310320
assert len(expr) > 0, "Got empty filter expression"
311321

@@ -332,7 +342,7 @@ def filter_tasks(
332342
else:
333343
assert isinstance(item, str)
334344
idx = int(item)
335-
assert idx < len(tasks) and idx >= 0
345+
assert 0 <= idx < len(tasks)
336346
selected.append(idx)
337347

338348
if do_filter:
@@ -539,10 +549,9 @@ def tune_model(
539549
logger.info("No tasks have been selected for tuning.")
540550
return None
541551
else:
542-
logger.info(f"Selected {len(tasks)} for tuning.")
552+
logger.info("Selected %s tasks for tuning.", len(tasks))
543553

544554
if enable_autoscheduler:
545-
546555
# Create the autoscheduler tuning options
547556
tuning_options = auto_scheduler.TuningOptions(
548557
num_measure_trials=trials,

0 commit comments

Comments
 (0)