diff options
author | Tim Hall <tim.hall@arm.com> | 2021-06-24 19:31:38 +0100 |
---|---|---|
committer | tim.hall <tim.hall@arm.com> | 2021-06-25 17:59:36 +0000 |
commit | b279844cae93353410210597535fdbf495cd0498 (patch) | |
tree | 9f6bb80e78ba76ed259cce61565f3571033d643e | |
parent | 98bfecd20f600a12de2f6a282d2fdbddb23dc081 (diff) | |
download | ethos-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
-rw-r--r-- | ethosu/vela/weight_compressor.py | 7 |
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) |