Skip to content

Commit

Permalink
[microNPU] Upgrade Vela to v3.2.0 (#9635)
Browse files Browse the repository at this point in the history
* [microNPU] Upgrade Vela to v3.2.0

In addition to upgrading the version of Vela, this contains a bug fix
and a fix due to an api change.

The bug fix was found as a result of upgrading the version and ensures
that block traversal mode is calculated before a set of block configs
is found. As a result, valid block configs are calculated consistently
throughout compilation.

The fix for the api change is a cast to the datatype now expected by
Vela due to using strict casting rules.

Change-Id: Icd40d11d37859f660527571d29cfeddd761d60da

* adding version change to gen requirements

Change-Id: I45d2892951558e52c599af34e8d9d2d3fb5eb20b
  • Loading branch information
lhutton1 authored Dec 6, 2021
1 parent 58f4733 commit 498d6d9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions docker/install/ubuntu_install_vela.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,4 @@ set -e
set -u
set -o pipefail

# In a refactor between v2.1.1 and v3.0.0, find_block_configs <appropriate function name> was removed from Vela.
# Since this is still required for the TVM port, it will be reinstated in Vela in a future release.
# Until then, it needs to be pinned to v2.1.1.
pip3 install ethos-u-vela==2.1.1
pip3 install ethos-u-vela==3.2.0
2 changes: 1 addition & 1 deletion python/gen_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
"docutils",
"<0.17",
), # Work around https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
("ethos-u-vela", "==2.1.1"),
("ethos-u-vela", "==3.2.0"),
("future", None),
("h5py", "==2.10.0"),
("image", None),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,6 @@ def _create_npu_op_conv2d(
npu_conv2d_op.rounding_mode = _create_npu_rounding_mode(serial_2d_convolution.rounding_mode)
npu_conv2d_op.upscale = _create_npu_resampling_mode(serial_2d_convolution.upscale)
accel_config = vela_api.get_accelerator_config()
block_config = vela_api.get_optimal_block_config(npu_conv2d_op, accel_config)
npu_conv2d_op.block_config = block_config
weights_shape_ohwi = [
npu_conv2d_op.ofm.shape.depth,
npu_conv2d_op.kernel.height,
Expand All @@ -457,6 +455,8 @@ def _create_npu_op_conv2d(
weights_shape_ohwi=weights_shape_ohwi,
ifm_bitdepth=npu_conv2d_op.ifm.data_type.size_in_bits(),
)
block_config = vela_api.get_optimal_block_config(npu_conv2d_op, accel_config)
npu_conv2d_op.block_config = block_config
return npu_conv2d_op, weights_zero_point


Expand Down
2 changes: 1 addition & 1 deletion python/tvm/relay/backend/contrib/ethosu/vela_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def compress_weights(
layout_transform_indices = {"HWIO": (3, 0, 1, 2), "HWOI": (2, 0, 1, 3), "OHWI": (0, 1, 2, 3)}
assert weights_layout in layout_transform_indices.keys()
assert isinstance(weights_zp, np.int64)
weights = weights.astype(np.int64) - weights_zp
weights = weights.astype(np.int16) - weights_zp
# Vela needs the weights in OHWI layout
weights_ohwi = np.transpose(weights, layout_transform_indices[weights_layout])
shape_ohwi = [
Expand Down

0 comments on commit 498d6d9

Please sign in to comment.