Skip to content

Commit

Permalink
fix, apply quantization to VTA only
Browse files Browse the repository at this point in the history
  • Loading branch information
tmoreau89 committed Aug 18, 2019
1 parent daa17de commit 6134fae
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions vta/tutorials/frontend/deploy_vision_on_vta.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
# the host, make sure you've set the variables below to the IP of
# your board.
device_host = os.environ.get("VTA_PYNQ_RPC_HOST", "192.168.2.99")
device_port = int(os.environ.get("VTA_PYNQ_RPC_PORT", "9091"))
device_port = os.environ.get("VTA_PYNQ_RPC_PORT", "9091")
if not tracker_host or not tracker_port:
remote = rpc.connect(device_host, int(device_port))
else:
Expand Down Expand Up @@ -172,13 +172,12 @@
shape_dict.update({k: v.shape for k, v in params.items()})
dtype_dict.update({k: str(v.dtype) for k, v in params.items()})

# Perform quantization in Relay
with relay.quantize.qconfig(global_scale=8.0,
skip_conv_layers=[0]):
relay_prog = relay.quantize.quantize(mod["main"], params=params)

# Perform graph packing and constant folding for VTA target
if target.device_name == "vta":
# Perform quantization in Relay
with relay.quantize.qconfig(global_scale=8.0,
skip_conv_layers=[0]):
relay_prog = relay.quantize.quantize(mod["main"], params=params)
# Perform graph packing and constant folding for VTA target
assert env.BLOCK_IN == env.BLOCK_OUT
relay_prog = graph_pack(
relay_prog,
Expand All @@ -187,6 +186,8 @@
env.WGT_WIDTH,
start_name=pack_dict[model][0],
stop_name=pack_dict[model][1])
else:
relay_prog = mod["main"]

# Compile Relay program with AlterOpLayout disabled
with relay.build_config(opt_level=3, disabled_pass={"AlterOpLayout"}):
Expand Down

0 comments on commit 6134fae

Please sign in to comment.