diff options
author | James Peet <james.peet@arm.com> | 2021-07-19 16:47:58 +0100 |
---|---|---|
committer | James Peet <james.peet@arm.com> | 2021-07-26 12:05:57 +0100 |
commit | 7519d50c993d60faa1ea09e56abfbf17cef23b49 (patch) | |
tree | 18bc526a1d1146dc3061f95418b1345bbdc481e8 /ethosu/vela/data_type.py | |
parent | daed1529848465aab221a30008f455f9fa03c8d4 (diff) | |
download | ethos-u-vela-7519d50c993d60faa1ea09e56abfbf17cef23b49.tar.gz |
MLBEDSW-4892: Fix crash affecting biases without quantization.
Remove quant_values attribute from Tensor class.
It only needs a single values attribute, holding either
quantized or unquantized values as appropriate.
Change-Id: Ie96f80ac58061b6077e0f7048dc60209fdfbcafa
Signed-off-by: James Peet <james.peet@arm.com>
Diffstat (limited to 'ethosu/vela/data_type.py')
-rw-r--r-- | ethosu/vela/data_type.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ethosu/vela/data_type.py b/ethosu/vela/data_type.py index 07086d6b..470504d2 100644 --- a/ethosu/vela/data_type.py +++ b/ethosu/vela/data_type.py @@ -18,6 +18,8 @@ import enum from typing import Any +import numpy as np + from .numeric_util import round_up_divide @@ -99,6 +101,16 @@ class DataType: __repr__ = __str__ + def as_numpy_type(self): + numpy_dtype_code = { + BaseType.UnsignedInt: "u", + BaseType.SignedInt: "i", + BaseType.Float: "f", + BaseType.Complex: "c", + } + assert self.type in numpy_dtype_code, f"Failed to interpret {self} as a numpy dtype" + return np.dtype(numpy_dtype_code[self.type] + str(self.size_in_bytes())) + stem_name = { BaseType.UnsignedInt: ("uint%s", True), BaseType.SignedInt: ("int%s", True), |