From ea00fd0f76c39c650eececc1d640126584357095 Mon Sep 17 00:00:00 2001 From: James Ward Date: Fri, 20 Jan 2023 16:03:50 +0000 Subject: Remove accumulator attributes from all but AVG_POOL2D * Also add missing CustomAttribute.py (flatbuffers generated file) Signed-off-by: James Ward Change-Id: Ib71847e03d622995dd86afcb6ec9ed2bc147ee7a --- python/serializer/tosa_serializer.py | 14 ++---- python/tosa/ConvAttribute.py | 12 +---- python/tosa/CustomAttribute.py | 89 ++++++++++++++++++++++++++++++++++ python/tosa/FullyConnectedAttribute.py | 12 +---- python/tosa/MatMulAttribute.py | 12 +---- python/tosa/TransposeConvAttribute.py | 12 +---- 6 files changed, 97 insertions(+), 54 deletions(-) create mode 100644 python/tosa/CustomAttribute.py (limited to 'python') diff --git a/python/serializer/tosa_serializer.py b/python/serializer/tosa_serializer.py index f579df2..b22cb20 100644 --- a/python/serializer/tosa_serializer.py +++ b/python/serializer/tosa_serializer.py @@ -170,7 +170,7 @@ class TosaSerializerAttribute(TosaSerializerUnion): self.ints.append((a.AddOutputZp, output_zp)) self.ints.append((a.AddAccumDtype, accum_dtype)) - def ConvAttribute(self, pad, stride, dilation, input_zp, weight_zp, accum_dtype): + def ConvAttribute(self, pad, stride, dilation, input_zp, weight_zp): from tosa import ConvAttribute as a, Attribute self.utype = Attribute.Attribute().ConvAttribute @@ -181,11 +181,8 @@ class TosaSerializerAttribute(TosaSerializerUnion): self.intvecs.append((a.AddDilation, dilation)) self.ints.append((a.AddInputZp, input_zp)) self.ints.append((a.AddWeightZp, weight_zp)) - self.ints.append((a.AddAccumDtype, accum_dtype)) - def TransposeConvAttribute( - self, outpad, stride, output_shape, input_zp, weight_zp, accum_dtype - ): + def TransposeConvAttribute(self, outpad, stride, output_shape, input_zp, weight_zp): from tosa import TransposeConvAttribute as a, Attribute self.utype = Attribute.Attribute().TransposeConvAttribute @@ -196,7 +193,6 @@ class TosaSerializerAttribute(TosaSerializerUnion): self.intvecs.append((a.AddOutputShape, output_shape)) self.ints.append((a.AddInputZp, input_zp)) self.ints.append((a.AddWeightZp, weight_zp)) - self.ints.append((a.AddAccumDtype, accum_dtype)) def PadAttribute(self, serializer_builder, padding, pad_const_int, pad_const_fp): from tosa import PadAttribute as a, Attribute @@ -350,7 +346,7 @@ class TosaSerializerAttribute(TosaSerializerUnion): self.intvecs.append((a.AddTable, table)) - def MatMulAttribute(self, A_zp, B_zp, accum_dtype): + def MatMulAttribute(self, A_zp, B_zp): from tosa import MatMulAttribute as a, Attribute self.utype = Attribute.Attribute().MatMulAttribute @@ -358,9 +354,8 @@ class TosaSerializerAttribute(TosaSerializerUnion): self.ints.append((a.AddAZp, A_zp)) self.ints.append((a.AddBZp, B_zp)) - self.ints.append((a.AddAccumDtype, accum_dtype)) - def FullyConnectedAttribute(self, input_zp, weight_zp, accum_dtype): + def FullyConnectedAttribute(self, input_zp, weight_zp): from tosa import FullyConnectedAttribute as a, Attribute self.utype = Attribute.Attribute().FullyConnectedAttribute @@ -368,7 +363,6 @@ class TosaSerializerAttribute(TosaSerializerUnion): self.ints.append((a.AddInputZp, input_zp)) self.ints.append((a.AddWeightZp, weight_zp)) - self.ints.append((a.AddAccumDtype, accum_dtype)) def NegateAttribute(self, input1_zp, output_zp): from tosa import NegateAttribute as a, Attribute diff --git a/python/tosa/ConvAttribute.py b/python/tosa/ConvAttribute.py index c06e8c7..fb22c7a 100644 --- a/python/tosa/ConvAttribute.py +++ b/python/tosa/ConvAttribute.py @@ -123,14 +123,7 @@ class ConvAttribute(object): return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) return 0 - # 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 ConvAttributeStart(builder): builder.StartObject(5) def Start(builder): return ConvAttributeStart(builder) def ConvAttributeAddPad(builder, pad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(pad), 0) @@ -157,9 +150,6 @@ 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/CustomAttribute.py b/python/tosa/CustomAttribute.py new file mode 100644 index 0000000..40d7e88 --- /dev/null +++ b/python/tosa/CustomAttribute.py @@ -0,0 +1,89 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tosa + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class CustomAttribute(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAs(cls, buf, offset=0): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = CustomAttribute() + x.Init(buf, n + offset) + return x + + @classmethod + def GetRootAsCustomAttribute(cls, buf, offset=0): + """This method is deprecated. Please switch to GetRootAs.""" + return cls.GetRootAs(buf, offset) + @classmethod + def CustomAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) + + # CustomAttribute + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + + # CustomAttribute + def Identifier(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.String(o + self._tab.Pos) + return None + + # CustomAttribute + def Config(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.String(o + self._tab.Pos) + return None + + # CustomAttribute + def ImplementationAttrs(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1)) + return 0 + + # CustomAttribute + def ImplementationAttrsAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o) + return 0 + + # CustomAttribute + def ImplementationAttrsLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # CustomAttribute + def ImplementationAttrsIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + return o == 0 + +def CustomAttributeStart(builder): builder.StartObject(3) +def Start(builder): + return CustomAttributeStart(builder) +def CustomAttributeAddIdentifier(builder, identifier): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(identifier), 0) +def AddIdentifier(builder, identifier): + return CustomAttributeAddIdentifier(builder, identifier) +def CustomAttributeAddConfig(builder, config): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(config), 0) +def AddConfig(builder, config): + return CustomAttributeAddConfig(builder, config) +def CustomAttributeAddImplementationAttrs(builder, implementationAttrs): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(implementationAttrs), 0) +def AddImplementationAttrs(builder, implementationAttrs): + return CustomAttributeAddImplementationAttrs(builder, implementationAttrs) +def CustomAttributeStartImplementationAttrsVector(builder, numElems): return builder.StartVector(1, numElems, 1) +def StartImplementationAttrsVector(builder, numElems): + return CustomAttributeStartImplementationAttrsVector(builder, numElems) +def CustomAttributeEnd(builder): return builder.EndObject() +def End(builder): + return CustomAttributeEnd(builder) \ No newline at end of file diff --git a/python/tosa/FullyConnectedAttribute.py b/python/tosa/FullyConnectedAttribute.py index 546ec60..892b0da 100644 --- a/python/tosa/FullyConnectedAttribute.py +++ b/python/tosa/FullyConnectedAttribute.py @@ -42,14 +42,7 @@ class FullyConnectedAttribute(object): return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) return 0 - # 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 FullyConnectedAttributeStart(builder): builder.StartObject(2) def Start(builder): return FullyConnectedAttributeStart(builder) def FullyConnectedAttributeAddInputZp(builder, inputZp): builder.PrependInt32Slot(0, inputZp, 0) @@ -58,9 +51,6 @@ 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 af6ba0b..b42ebfa 100644 --- a/python/tosa/MatMulAttribute.py +++ b/python/tosa/MatMulAttribute.py @@ -42,14 +42,7 @@ class MatMulAttribute(object): return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) return 0 - # 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 MatMulAttributeStart(builder): builder.StartObject(2) def Start(builder): return MatMulAttributeStart(builder) def MatMulAttributeAddAZp(builder, aZp): builder.PrependInt32Slot(0, aZp, 0) @@ -58,9 +51,6 @@ 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/TransposeConvAttribute.py b/python/tosa/TransposeConvAttribute.py index 1a6bbde..a2824e2 100644 --- a/python/tosa/TransposeConvAttribute.py +++ b/python/tosa/TransposeConvAttribute.py @@ -123,14 +123,7 @@ class TransposeConvAttribute(object): return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) return 0 - # 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 TransposeConvAttributeStart(builder): builder.StartObject(5) def Start(builder): return TransposeConvAttributeStart(builder) def TransposeConvAttributeAddOutPad(builder, outPad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(outPad), 0) @@ -157,9 +150,6 @@ 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 -- cgit v1.2.1