From 485a11d8cb67c8062c632f0987cd31cedbe93d6d Mon Sep 17 00:00:00 2001 From: James Ward Date: Fri, 5 Aug 2022 13:48:37 +0100 Subject: 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 Change-Id: I54357f02e3776d81958228f699ea5044f2014f4b --- python/tosa/ConvAttribute.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'python/tosa/ConvAttribute.py') 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 -- cgit v1.2.1