aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/weight_compressor.py
diff options
context:
space:
mode:
authorLouis Verhaard <louis.verhaard@arm.com>2020-11-02 18:04:27 +0100
committerLouis Verhaard <louis.verhaard@arm.com>2020-11-23 13:39:35 +0100
commitaeae56770f3c19182d32cc63fd32396e061a7648 (patch)
tree95ca2e6c90d81ba8910c8ca9ced68ffa132b7dab /ethosu/vela/weight_compressor.py
parent27d36f003d35413beb51c1de8f33259ddeca7543 (diff)
downloadethos-u-vela-aeae56770f3c19182d32cc63fd32396e061a7648.tar.gz
MLBEDSW-3424: Expose API through separate file
All external APIs are now exposed by api.py. Signed-off-by: Louis Verhaard <louis.verhaard@arm.com> Change-Id: I33f480e424692ac30e9c7d791f583199f31164a7
Diffstat (limited to 'ethosu/vela/weight_compressor.py')
-rw-r--r--ethosu/vela/weight_compressor.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/ethosu/vela/weight_compressor.py b/ethosu/vela/weight_compressor.py
index 0eab1851..40ebcd04 100644
--- a/ethosu/vela/weight_compressor.py
+++ b/ethosu/vela/weight_compressor.py
@@ -17,6 +17,7 @@
# Compresses and pads the weigths. It also calculates the scales and packs with the biases.
import math
from collections import namedtuple
+from typing import Tuple
import numpy as np
@@ -50,14 +51,14 @@ WeightCompressionConfig = namedtuple(
def encode_weights(
accelerator: Accelerator,
weights_volume: np.ndarray,
- dilation_xy: tuple,
+ dilation_xy: Tuple[int, int],
ifm_bitdepth: int,
ofm_block_depth: int,
is_depthwise: bool,
block_traversal: NpuBlockTraversal,
):
"""
- Public facing API to use the Ethos-U weight encoding.
+ Internal implementation of the public facing API to use weight encoding.
:param accelerator: architecture_features.Accelerator enum to pick the correct Ethos-U accelerator
:param weights_volume: numpy.ndarray in OHWI layout with a shape of four
@@ -65,10 +66,10 @@ def encode_weights(
:param ifm_bitdepth: the bitdepth of input feature map
:param ofm_block_depth: the depth of blocks for Ethos-U processing
:param is_depthwise: a boolean indicating these weights are used for a depthwise traversal
- :param block_traversal: indicates how these weights are traversed on sub-kernal basis
+ :param block_traversal: indicates how these weights are traversed on sub-kernel basis
+
:return: a bytearray of compressed weights
"""
-
# Check arg types
assert isinstance(accelerator, Accelerator)
assert isinstance(weights_volume, np.ndarray)
@@ -108,7 +109,7 @@ def encode_weights(
def encode_bias(bias: np.int64, scale: int, shift: int):
"""
- Public facing API to pack bias and scale values as required by the Ethos-U
+ Internal implementation of public facing API to pack bias and scale values as required by the Ethos-U
:param bias: 64bit signed number that includes 40bit signed bias
:param scale: 32bit scale value