Skip to content

Commit

Permalink
[Auto-Schedule][Fix] Fix hang while tune model through rpc (#9032)
Browse files Browse the repository at this point in the history
* [Auto-Schedule][Fix] Fix hang while tune model through rpc

* Fix problem with hang by using deep copy

* Fix with local args

* Update python/tvm/auto_scheduler/measure.py

Co-authored-by: Wuwei Lin <vincentl13x@gmail.com>
  • Loading branch information
echuraev and vinx13 authored Sep 23, 2021
1 parent e887286 commit ee6fe12
Showing 1 changed file with 9 additions and 7 deletions.
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

0 comments on commit ee6fe12

Please sign in to comment.