aboutsummaryrefslogtreecommitdiff
path: root/verif/tosa_serializer.py
diff options
context:
space:
mode:
authorKevin Cheng <kevin.cheng@arm.com>2021-07-28 17:19:23 -0700
committerKevin Cheng <kevin.cheng@arm.com>2021-08-12 15:27:03 -0700
commita9017401461224b9bc81e7b1c770ca6091e0e3fb (patch)
treea9eba569a9ed3862f459b3190787cdbac57da85b /verif/tosa_serializer.py
parent7ffccce9b9a7eeecbad0c0525f1545c2714f8556 (diff)
downloadreference_model-a9017401461224b9bc81e7b1c770ca6091e0e3fb.tar.gz
Support int4 weights read. Added conv2d int8xint4 in test generation.
Signed-off-by: Kevin Cheng <kevin.cheng@arm.com> Change-Id: I61620f160c7dad6aac5fcc3da0a6e97f3bae5b40
Diffstat (limited to 'verif/tosa_serializer.py')
-rw-r--r--verif/tosa_serializer.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/verif/tosa_serializer.py b/verif/tosa_serializer.py
index c4de2a2..b4daaad 100644
--- a/verif/tosa_serializer.py
+++ b/verif/tosa_serializer.py
@@ -386,6 +386,18 @@ class TosaSerializerTensor:
for val in self.data:
val_u8 = np.uint8(val)
u8_data.append(val_u8)
+ elif self.dtype == DType.INT4:
+ in_size = len(self.data)
+ out_size = (in_size + 1) // 2
+ for i in range(out_size):
+ val_0 = self.data[2 * i]
+ if (2 * i + 1) < in_size:
+ val_1 = self.data[2 * i + 1]
+ else:
+ val_1 = 0
+ val_i8 = (val_0 & 0xF) | ((val_1 & 0xF) << 4)
+ val_u8 = np.uint8(val_i8)
+ u8_data.append(val_u8)
elif self.dtype == DType.INT8:
for val in self.data:
val_u8 = np.uint8(val)