From 85d2d83d6cc8c298e7d8f1bf8eb695efa74c9372 Mon Sep 17 00:00:00 2001 From: Insop Song Date: Sun, 13 Dec 2020 02:07:24 -0800 Subject: [PATCH] Update tune_relay_vta.py to support single board - support single pynq board run, change is credited to 'https://github.com/i24361's change, https://github.com/i24361/incubator-tvm/blob/0472b1f347976229a29be8a6e60b626a0604c8df/vta/tutorials/autotvm/tune_relay_vta_with_one_board.py - fixes the save fail - issues and changes are discussed in https://discuss.tvm.apache.org/t/vta-workaround-for-autotuning-with-one-pynq-z1-board/8091/9 --- vta/tutorials/autotvm/tune_relay_vta.py | 31 +++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/vta/tutorials/autotvm/tune_relay_vta.py b/vta/tutorials/autotvm/tune_relay_vta.py index 2cec62fa9cae..273f0af4af03 100644 --- a/vta/tutorials/autotvm/tune_relay_vta.py +++ b/vta/tutorials/autotvm/tune_relay_vta.py @@ -340,18 +340,6 @@ def _topi_nn_conv2d(*args, **kwargs): def tune_and_evaluate(tuning_opt): - if env.TARGET != "sim": - # Get remote from fleet node - remote = autotvm.measure.request_remote( - env.TARGET, tracker_host, tracker_port, timeout=10000 - ) - # Reconfigure the JIT runtime and FPGA. - vta.reconfig_runtime(remote) - vta.program_fpga(remote, bitstream=None) - else: - # In simulation mode, host the RPC server locally. - remote = rpc.LocalSession() - # Register VTA tuning tasks register_vta_tuning_tasks() @@ -407,6 +395,19 @@ def tune_and_evaluate(tuning_opt): print("Tuning...") tune_tasks(tasks, **tuning_opt) + # evaluate with tuning history + if env.TARGET != "sim": + # Get remote from fleet node + remote = autotvm.measure.request_remote( + env.TARGET, tracker_host, tracker_port, timeout=10000 + ) + # Reconfigure the JIT runtime and FPGA. + vta.reconfig_runtime(remote) + vta.program_fpga(remote, bitstream=None) + else: + # In simulation mode, host the RPC server locally. + remote = rpc.LocalSession() + # compile kernels with history best records with autotvm.tophub.context(target, extra_files=[log_file]): # Compile network @@ -425,9 +426,9 @@ def tune_and_evaluate(tuning_opt): # Export library print("Upload...") temp = utils.tempdir() - lib.save(temp.relpath("graphlib.o")) - remote.upload(temp.relpath("graphlib.o")) - lib = remote.load_module("graphlib.o") + lib.export_library(temp.relpath("graphlib.tar")) + remote.upload(temp.relpath("graphlib.tar")) + lib = remote.load_module("graphlib.tar") # Generate the graph runtime ctx = remote.ext_dev(0) if device == "vta" else remote.cpu(0)