Skip to content

Commit

Permalink
[AutoScheduler] Propogate global autotvm state to PopenPool workers (#…
Browse files Browse the repository at this point in the history
…8913)

* [AutoScheduler] Propogate global autotvm state to PopenPool workers

* Fix

* lint
  • Loading branch information
vinx13 committed Sep 3, 2021
1 parent c7840d6 commit 8326edd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/tvm/auto_scheduler/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from tvm.driver import build_module
from tvm.ir import transform
from tvm.autotvm.measure.measure_methods import set_cuda_target_arch
from tvm.autotvm.env import AutotvmGlobalScope, reset_global_scope
from tvm.contrib import tar, ndk
from tvm.contrib.popen_pool import PopenWorker, PopenPoolExecutor, StatusKind
from tvm.target import Target
Expand Down Expand Up @@ -692,7 +693,9 @@ def local_builder_build(inputs, timeout, n_parallel, build_func="default", verbo
res : List[BuildResult]
The build results of these MeasureInputs.
"""
executor = PopenPoolExecutor(n_parallel, timeout)
executor = PopenPoolExecutor(
n_parallel, timeout, reset_global_scope, (AutotvmGlobalScope.current,)
)
tuple_res = executor.map_with_error_catching(
local_build_worker,
[
Expand Down
7 changes: 7 additions & 0 deletions python/tvm/autotvm/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ def __init__(self):


GLOBAL_SCOPE = AutotvmGlobalScope()


def reset_global_scope(global_scope):
"""Reset global autotvm state. This is needed to initialize PopenPool workers."""
global GLOBAL_SCOPE
GLOBAL_SCOPE = global_scope
AutotvmGlobalScope.current = global_scope

0 comments on commit 8326edd

Please sign in to comment.