Skip to content

Commit

Permalink
Update tune_relay_vta.py to support single board (apache#7100)
Browse files Browse the repository at this point in the history
  • Loading branch information
insop authored and electriclilies committed Feb 18, 2021
1 parent 92251b7 commit 81dabba
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions vta/tutorials/autotvm/tune_relay_vta.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 81dabba

Please sign in to comment.