From 390acc52a17906186b699680e9315561b16e1695 Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Mon, 22 Oct 2018 21:55:31 -0700 Subject: [PATCH] [AUTOTVM] Fix measurement for CPU (#1956) --- python/tvm/autotvm/measure/measure_methods.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/tvm/autotvm/measure/measure_methods.py b/python/tvm/autotvm/measure/measure_methods.py index ec3eb7e611e0..975faf71b5a0 100644 --- a/python/tvm/autotvm/measure/measure_methods.py +++ b/python/tvm/autotvm/measure/measure_methods.py @@ -460,7 +460,11 @@ def run_through_rpc(measure_input, build_result, if ref_input: args = [nd.array(x, ctx=ctx) for x in ref_input] else: + # create empty arrays on the remote device and copy them once. + # This can avoid some memory issues that make the measurment results unreliable. args = [nd.empty(x[0], dtype=x[1], ctx=ctx) for x in build_result.arg_info] + args = [nd.array(x, ctx=ctx) for x in args] + ctx.sync() costs = time_f(*args).results if len(costs) > 2: # remove largest and smallest value to reduce variance