Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Auto-Schedule][Fix] Fix hang while tune model through rpc #9032

Merged
merged 4 commits into from
Sep 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions python/tvm/auto_scheduler/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,7 @@ def _timed_eval_func(
random_fill = tvm.get_global_func("tvm.contrib.random.random_fill", True)
assert random_fill, "Please make sure USE_RANDOM is ON in the config.cmake"
assert len(args) == len(build_res.args)
loc_args = []
# pylint: disable=consider-using-enumerate
for idx in range(len(args)):
if args[idx] is None:
Expand All @@ -917,11 +918,11 @@ def _timed_eval_func(
get_const_tuple(build_res_arg.shape), build_res_arg.dtype, dev
)
random_fill(empty_array)
args[idx] = empty_array
loc_args.append(empty_array)
else:
args[idx] = ndarray.array(args[idx], dev)
loc_args.append(ndarray.array(args[idx], dev))
dev.sync()
costs = time_f(*args).results
costs = time_f(*loc_args).results
# pylint: disable=broad-except
except Exception:
costs = (MAX_FLOAT,)
Expand Down Expand Up @@ -1112,6 +1113,7 @@ def _rpc_run(
), "Please make sure USE_RANDOM is ON in the config.cmake on the remote devices"

assert len(args) == len(build_res.args)
loc_args = []
# pylint: disable=consider-using-enumerate
for idx in range(len(args)):
if args[idx] is None:
Expand All @@ -1120,16 +1122,16 @@ def _rpc_run(
get_const_tuple(build_res_arg.shape), build_res_arg.dtype, dev
)
random_fill(empty_array)
args[idx] = empty_array
loc_args.append(empty_array)
else:
args[idx] = ndarray.array(args[idx], dev)
loc_args.append(ndarray.array(args[idx], dev))
dev.sync()

# First run for check that the kernel is correct
func.entry_func(*args)
func.entry_func(*loc_args)
dev.sync()

costs = time_f(*args).results
costs = time_f(*loc_args).results

# clean up remote files
remote.remove(build_res.filename)
Expand Down