aboutsummaryrefslogtreecommitdiff
path: root/ethosu/vela/weight_compressor.py
diff options
context:
space:
mode:
authorTim Hall <tim.hall@arm.com>2021-06-24 19:31:38 +0100
committertim.hall <tim.hall@arm.com>2021-06-25 17:59:36 +0000
commitb279844cae93353410210597535fdbf495cd0498 (patch)
tree9f6bb80e78ba76ed259cce61565f3571033d643e /ethosu/vela/weight_compressor.py
parent98bfecd20f600a12de2f6a282d2fdbddb23dc081 (diff)
downloadethos-u-vela-b279844cae93353410210597535fdbf495cd0498.tar.gz
MLBEDSW-4819: MLCE: weight_compressor int has no attribute astype
- Added type checking so that the correct type conversion can be used Signed-off-by: Tim Hall <tim.hall@arm.com> Change-Id: Ia83f46029fac7bad63844c090b87d23c2072b105
Diffstat (limited to 'ethosu/vela/weight_compressor.py')
-rw-r--r--ethosu/vela/weight_compressor.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/ethosu/vela/weight_compressor.py b/ethosu/vela/weight_compressor.py
index 5f211393..4ba3dee3 100644
--- a/ethosu/vela/weight_compressor.py
+++ b/ethosu/vela/weight_compressor.py
@@ -315,7 +315,12 @@ def encode_weight_and_scale_tensor(
# Early zero-point correction
quant_buf = weight_tens.quant_values.astype(np.int16)
- weights = quant_buf - weight_tens.quantization.zero_point.astype(np.int16)
+ # the zero point can be either a native or numpy type
+ if isinstance(weight_tens.quantization.zero_point, (int, float)):
+ zero_point = np.int16(weight_tens.quantization.zero_point)
+ else:
+ zero_point = weight_tens.quantization.zero_point.astype(np.int16)
+ weights = quant_buf - zero_point
if len(weights.shape) == 2:
weights = np.expand_dims(np.expand_dims(weights, axis=0), axis=0)