aboutsummaryrefslogtreecommitdiff
path: root/python/tosa
diff options
context:
space:
mode:
authorJames Ward <james.ward@arm.com>2022-08-05 13:48:37 +0100
committerJames Ward <james.ward@arm.com>2022-10-04 13:02:00 +0100
commit485a11d8cb67c8062c632f0987cd31cedbe93d6d (patch)
treec12841ac81114120428418f1c359c3d145610804 /python/tosa
parentc92710d7259558fb0cd9e9b38d0c78da21c6e2d4 (diff)
downloadserialization_lib-485a11d8cb67c8062c632f0987cd31cedbe93d6d.tar.gz
FP16 support in serialization
* Allow serialization of fp16 data * Add package to support integrated half data-type (half_float::half), independent of native float: http://half.sourceforge.net/ * Allow passing of accumulate data-type in serialization Signed-off-by: James Ward <james.ward@arm.com> Change-Id: I54357f02e3776d81958228f699ea5044f2014f4b
Diffstat (limited to 'python/tosa')
-rw-r--r--python/tosa/ConvAttribute.py12
-rw-r--r--python/tosa/DType.py1
-rw-r--r--python/tosa/FullyConnectedAttribute.py12
-rw-r--r--python/tosa/MatMulAttribute.py12
-rw-r--r--python/tosa/PoolAttribute.py12
-rw-r--r--python/tosa/TransposeConvAttribute.py12
6 files changed, 56 insertions, 5 deletions
diff --git a/python/tosa/ConvAttribute.py b/python/tosa/ConvAttribute.py
index fb22c7a..c06e8c7 100644
--- a/python/tosa/ConvAttribute.py
+++ b/python/tosa/ConvAttribute.py
@@ -123,7 +123,14 @@ class ConvAttribute(object):
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0
-def ConvAttributeStart(builder): builder.StartObject(5)
+ # ConvAttribute
+ def AccumDtype(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 0
+
+def ConvAttributeStart(builder): builder.StartObject(6)
def Start(builder):
return ConvAttributeStart(builder)
def ConvAttributeAddPad(builder, pad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pad), 0)
@@ -150,6 +157,9 @@ def AddInputZp(builder, inputZp):
def ConvAttributeAddWeightZp(builder, weightZp): builder.PrependInt32Slot(4, weightZp, 0)
def AddWeightZp(builder, weightZp):
return ConvAttributeAddWeightZp(builder, weightZp)
+def ConvAttributeAddAccumDtype(builder, accumDtype): builder.PrependUint32Slot(5, accumDtype, 0)
+def AddAccumDtype(builder, accumDtype):
+ return ConvAttributeAddAccumDtype(builder, accumDtype)
def ConvAttributeEnd(builder): return builder.EndObject()
def End(builder):
return ConvAttributeEnd(builder) \ No newline at end of file
diff --git a/python/tosa/DType.py b/python/tosa/DType.py
index e6b41ed..27d28c4 100644
--- a/python/tosa/DType.py
+++ b/python/tosa/DType.py
@@ -13,3 +13,4 @@ class DType(object):
INT48 = 7
FLOAT = 8
UINT16 = 9
+ FP16 = 10
diff --git a/python/tosa/FullyConnectedAttribute.py b/python/tosa/FullyConnectedAttribute.py
index 892b0da..546ec60 100644
--- a/python/tosa/FullyConnectedAttribute.py
+++ b/python/tosa/FullyConnectedAttribute.py
@@ -42,7 +42,14 @@ class FullyConnectedAttribute(object):
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0
-def FullyConnectedAttributeStart(builder): builder.StartObject(2)
+ # FullyConnectedAttribute
+ def AccumDtype(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 0
+
+def FullyConnectedAttributeStart(builder): builder.StartObject(3)
def Start(builder):
return FullyConnectedAttributeStart(builder)
def FullyConnectedAttributeAddInputZp(builder, inputZp): builder.PrependInt32Slot(0, inputZp, 0)
@@ -51,6 +58,9 @@ def AddInputZp(builder, inputZp):
def FullyConnectedAttributeAddWeightZp(builder, weightZp): builder.PrependInt32Slot(1, weightZp, 0)
def AddWeightZp(builder, weightZp):
return FullyConnectedAttributeAddWeightZp(builder, weightZp)
+def FullyConnectedAttributeAddAccumDtype(builder, accumDtype): builder.PrependUint32Slot(2, accumDtype, 0)
+def AddAccumDtype(builder, accumDtype):
+ return FullyConnectedAttributeAddAccumDtype(builder, accumDtype)
def FullyConnectedAttributeEnd(builder): return builder.EndObject()
def End(builder):
return FullyConnectedAttributeEnd(builder) \ No newline at end of file
diff --git a/python/tosa/MatMulAttribute.py b/python/tosa/MatMulAttribute.py
index b42ebfa..af6ba0b 100644
--- a/python/tosa/MatMulAttribute.py
+++ b/python/tosa/MatMulAttribute.py
@@ -42,7 +42,14 @@ class MatMulAttribute(object):
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0
-def MatMulAttributeStart(builder): builder.StartObject(2)
+ # MatMulAttribute
+ def AccumDtype(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 0
+
+def MatMulAttributeStart(builder): builder.StartObject(3)
def Start(builder):
return MatMulAttributeStart(builder)
def MatMulAttributeAddAZp(builder, aZp): builder.PrependInt32Slot(0, aZp, 0)
@@ -51,6 +58,9 @@ def AddAZp(builder, aZp):
def MatMulAttributeAddBZp(builder, bZp): builder.PrependInt32Slot(1, bZp, 0)
def AddBZp(builder, bZp):
return MatMulAttributeAddBZp(builder, bZp)
+def MatMulAttributeAddAccumDtype(builder, accumDtype): builder.PrependUint32Slot(2, accumDtype, 0)
+def AddAccumDtype(builder, accumDtype):
+ return MatMulAttributeAddAccumDtype(builder, accumDtype)
def MatMulAttributeEnd(builder): return builder.EndObject()
def End(builder):
return MatMulAttributeEnd(builder) \ No newline at end of file
diff --git a/python/tosa/PoolAttribute.py b/python/tosa/PoolAttribute.py
index 8256a6d..4307114 100644
--- a/python/tosa/PoolAttribute.py
+++ b/python/tosa/PoolAttribute.py
@@ -123,7 +123,14 @@ class PoolAttribute(object):
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0
-def PoolAttributeStart(builder): builder.StartObject(5)
+ # PoolAttribute
+ def AccumDtype(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 0
+
+def PoolAttributeStart(builder): builder.StartObject(6)
def Start(builder):
return PoolAttributeStart(builder)
def PoolAttributeAddPad(builder, pad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pad), 0)
@@ -150,6 +157,9 @@ def AddInputZp(builder, inputZp):
def PoolAttributeAddOutputZp(builder, outputZp): builder.PrependInt32Slot(4, outputZp, 0)
def AddOutputZp(builder, outputZp):
return PoolAttributeAddOutputZp(builder, outputZp)
+def PoolAttributeAddAccumDtype(builder, accumDtype): builder.PrependUint32Slot(5, accumDtype, 0)
+def AddAccumDtype(builder, accumDtype):
+ return PoolAttributeAddAccumDtype(builder, accumDtype)
def PoolAttributeEnd(builder): return builder.EndObject()
def End(builder):
return PoolAttributeEnd(builder) \ No newline at end of file
diff --git a/python/tosa/TransposeConvAttribute.py b/python/tosa/TransposeConvAttribute.py
index a2824e2..1a6bbde 100644
--- a/python/tosa/TransposeConvAttribute.py
+++ b/python/tosa/TransposeConvAttribute.py
@@ -123,7 +123,14 @@ class TransposeConvAttribute(object):
return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
return 0
-def TransposeConvAttributeStart(builder): builder.StartObject(5)
+ # TransposeConvAttribute
+ def AccumDtype(self):
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
+ if o != 0:
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
+ return 0
+
+def TransposeConvAttributeStart(builder): builder.StartObject(6)
def Start(builder):
return TransposeConvAttributeStart(builder)
def TransposeConvAttributeAddOutPad(builder, outPad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(outPad), 0)
@@ -150,6 +157,9 @@ def AddInputZp(builder, inputZp):
def TransposeConvAttributeAddWeightZp(builder, weightZp): builder.PrependInt32Slot(4, weightZp, 0)
def AddWeightZp(builder, weightZp):
return TransposeConvAttributeAddWeightZp(builder, weightZp)
+def TransposeConvAttributeAddAccumDtype(builder, accumDtype): builder.PrependUint32Slot(5, accumDtype, 0)
+def AddAccumDtype(builder, accumDtype):
+ return TransposeConvAttributeAddAccumDtype(builder, accumDtype)
def TransposeConvAttributeEnd(builder): return builder.EndObject()
def End(builder):
return TransposeConvAttributeEnd(builder) \ No newline at end of file