Fix rank 0 support in serialization_lib
Numpy rank 0 files correctly written as shape () instead of (1)
Constant tensors of rank 0 now have data written out
Signed-off-by: Jeremy Johnson <jeremy.johnson@arm.com>
Change-Id: Ie4bad8f798674cdb0484955e9db684f7f4100145
diff --git a/python/serializer/tosa_serializer.py b/python/serializer/tosa_serializer.py
index 9658edf..e6ab3d0 100644
--- a/python/serializer/tosa_serializer.py
+++ b/python/serializer/tosa_serializer.py
@@ -407,12 +407,15 @@
if isinstance(data, np.ndarray):
data = data.flatten().astype(fntype).tolist()
data = list(map(fntype, data))
- self.data = data
elif isinstance(data, list):
data = list(map(fntype, data))
- self.data = data
+ elif data is not None:
+ # Assume data is rank 0 data type
+ data = list(map(fntype, [data]))
else:
- self.data = None
+ data = None
+
+ self.data = data
# Filename for placeholder tensors. These get generated by the test generation
# process and are written to disk, but are considered input tensors by the