Skip to content

Commit

Permalink
[FIX,AUTOTVM] More descriptive error message when an autotvm task is …
Browse files Browse the repository at this point in the history
…not (#6652)

found.
  • Loading branch information
tkonolige authored Oct 9, 2020
1 parent 1fc47cc commit 0922d17
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions python/tvm/autotvm/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@
from .space import ConfigSpace


def _raise_error(*args, **kwargs): # pylint: disable=unused-argument
raise RuntimeError(
"The function of this task is not found. Possibly the function "
"of this task is registered in another python file "
"which is not imported in this run"
)
def _lookup_task(name):
task = TASK_TABLE.get(name)
if task is None:
raise RuntimeError(
f"Could not find a registered function for the task {name}. It is "
"possible that the function is registered in a python file which was "
"not imported in this run."
)
return task


def serialize_args(args):
Expand Down Expand Up @@ -130,7 +133,7 @@ def __init__(self, name, args):

# init null config space
self.config_space = None
self.func = TASK_TABLE.get(name, _raise_error)
self.func = _lookup_task(name)

# auxiliary info, available after `init_space` is called
self.flop = None
Expand Down Expand Up @@ -185,7 +188,7 @@ def __setstate__(self, state):
self.args = state["args"]
self.kwargs = state["kwargs"]
self.config_space = state["config_space"]
self.func = TASK_TABLE.get(state["name"], _raise_error)
self.func = _lookup_task(state["name"])
self.flop = state["flop"]
self.target = state["target"]
self.target_host = state["target_host"]
Expand Down

0 comments on commit 0922d17

Please sign in to comment.