Skip to content

Commit

Permalink
fix pass context inheritance for real
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Mar 22, 2023
1 parent c7970dd commit f82ad67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 6 additions & 2 deletions python/tvm/autotvm/measure/measure_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ def build(self, measure_inputs):
shutil.rmtree(self.tmp_dir, ignore_errors=True)
self.tmp_dir = tempfile.mkdtemp()

# Subprocesses can not inherit current PassContext.
# As a workaround we pass it manually to the build_func.
self.build_kwargs["ctx"] = tvm.ir.transform.PassContext.current()

for i in range(0, len(measure_inputs), self.n_parallel):
futures = []
for inp in measure_inputs[i : i + self.n_parallel]:
Expand Down Expand Up @@ -495,7 +499,7 @@ def set_task(self, task):
return server, tracker


def _build_func_common(measure_input, runtime=None, checks=None, build_option=None):
def _build_func_common(measure_input, runtime=None, checks=None, build_option=None, ctx=None):
"""Common part for building a configuration"""
target, task, config = measure_input
target, task.target_host = Target.canon_target_and_host(target, task.target_host)
Expand All @@ -518,7 +522,7 @@ def _build_func_common(measure_input, runtime=None, checks=None, build_option=No
func = vta.build(s, args, target_host=task.target_host)
else:
current_pass_context: tvm.ir.transform.PassContext = (
tvm.ir.transform.PassContext.current()
ctx or tvm.ir.transform.PassContext.current()
)
current_config = dict(current_pass_context.config)
if build_option is not None:
Expand Down
1 change: 0 additions & 1 deletion python/tvm/driver/tvmc/autotuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,6 @@ def tune_model(
runner = local_server

if enable_autoscheduler:

tasks, weights = autoscheduler_get_tuning_tasks(
mod=mod,
params=params,
Expand Down

0 comments on commit f82ad67

Please sign in to comment.