From 81db8ee8f580d30ec0ca53067df32ef046e6f09e Mon Sep 17 00:00:00 2001 From: Tai Ly Date: Wed, 14 Feb 2024 19:57:38 +0000 Subject: [serialization_lib] Align to Tosa Spec removed attributes for Reshape, Slice and Tile Ops renamed field accum_dtype to acc_type, renamed then_branch/else_branch to then_graph/else_graph renamed cond_branch/body_branch to cond_graph/body_graph Signed-off-by: Tai Ly Change-Id: I2001f19519987d9e64c18b1f11762f9d3b9be4ec --- python/tosa/Attribute.py | 33 +++++------ python/tosa/CondIfAttribute.py | 20 +++---- python/tosa/PoolAttribute.py | 10 ++-- python/tosa/ReshapeAttribute.py | 80 ------------------------- python/tosa/SliceAttribute.py | 119 -------------------------------------- python/tosa/TileAttribute.py | 80 ------------------------- python/tosa/WhileLoopAttribute.py | 20 +++---- 7 files changed, 40 insertions(+), 322 deletions(-) delete mode 100644 python/tosa/ReshapeAttribute.py delete mode 100644 python/tosa/SliceAttribute.py delete mode 100644 python/tosa/TileAttribute.py (limited to 'python/tosa') diff --git a/python/tosa/Attribute.py b/python/tosa/Attribute.py index 2589f71..6abdcfb 100644 --- a/python/tosa/Attribute.py +++ b/python/tosa/Attribute.py @@ -9,21 +9,18 @@ class Attribute(object): TransposeConvAttribute = 3 PadAttribute = 4 AxisAttribute = 5 - ReshapeAttribute = 6 - SliceAttribute = 7 - TileAttribute = 8 - ResizeAttribute = 9 - ClampAttribute = 10 - RescaleAttribute = 11 - MulAttribute = 12 - ArithmeticRightShiftAttribute = 13 - CondIfAttribute = 14 - WhileLoopAttribute = 15 - TransposeAttribute = 16 - TableAttribute = 17 - MatMulAttribute = 18 - FullyConnectedAttribute = 19 - NegateAttribute = 20 - CustomAttribute = 21 - FFTAttribute = 22 - RFFTAttribute = 23 + ResizeAttribute = 6 + ClampAttribute = 7 + RescaleAttribute = 8 + MulAttribute = 9 + ArithmeticRightShiftAttribute = 10 + CondIfAttribute = 11 + WhileLoopAttribute = 12 + TransposeAttribute = 13 + TableAttribute = 14 + MatMulAttribute = 15 + FullyConnectedAttribute = 16 + NegateAttribute = 17 + CustomAttribute = 18 + FFTAttribute = 19 + RFFTAttribute = 20 diff --git a/python/tosa/CondIfAttribute.py b/python/tosa/CondIfAttribute.py index cdecec6..8f2aa9b 100644 --- a/python/tosa/CondIfAttribute.py +++ b/python/tosa/CondIfAttribute.py @@ -29,14 +29,14 @@ class CondIfAttribute(object): self._tab = flatbuffers.table.Table(buf, pos) # CondIfAttribute - def ThenBranch(self): + def ThenGraph(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 # CondIfAttribute - def ElseBranch(self): + def ElseGraph(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: return self._tab.String(o + self._tab.Pos) @@ -48,17 +48,17 @@ def CondIfAttributeStart(builder): def Start(builder): CondIfAttributeStart(builder) -def CondIfAttributeAddThenBranch(builder, thenBranch): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(thenBranch), 0) +def CondIfAttributeAddThenGraph(builder, thenGraph): + builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(thenGraph), 0) -def AddThenBranch(builder, thenBranch): - CondIfAttributeAddThenBranch(builder, thenBranch) +def AddThenGraph(builder, thenGraph): + CondIfAttributeAddThenGraph(builder, thenGraph) -def CondIfAttributeAddElseBranch(builder, elseBranch): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(elseBranch), 0) +def CondIfAttributeAddElseGraph(builder, elseGraph): + builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(elseGraph), 0) -def AddElseBranch(builder, elseBranch): - CondIfAttributeAddElseBranch(builder, elseBranch) +def AddElseGraph(builder, elseGraph): + CondIfAttributeAddElseGraph(builder, elseGraph) def CondIfAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/PoolAttribute.py b/python/tosa/PoolAttribute.py index ea31544..c13e038 100644 --- a/python/tosa/PoolAttribute.py +++ b/python/tosa/PoolAttribute.py @@ -124,7 +124,7 @@ class PoolAttribute(object): return 0 # PoolAttribute - def AccumDtype(self): + def AccType(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) @@ -184,11 +184,11 @@ def PoolAttributeAddOutputZp(builder, outputZp): def AddOutputZp(builder, outputZp): PoolAttributeAddOutputZp(builder, outputZp) -def PoolAttributeAddAccumDtype(builder, accumDtype): - builder.PrependUint32Slot(5, accumDtype, 0) +def PoolAttributeAddAccType(builder, accType): + builder.PrependUint32Slot(5, accType, 0) -def AddAccumDtype(builder, accumDtype): - PoolAttributeAddAccumDtype(builder, accumDtype) +def AddAccType(builder, accType): + PoolAttributeAddAccType(builder, accType) def PoolAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/ReshapeAttribute.py b/python/tosa/ReshapeAttribute.py deleted file mode 100644 index 7df6546..0000000 --- a/python/tosa/ReshapeAttribute.py +++ /dev/null @@ -1,80 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: tosa - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class ReshapeAttribute(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = ReshapeAttribute() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsReshapeAttribute(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def ReshapeAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) - - # ReshapeAttribute - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # ReshapeAttribute - def NewShape(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # ReshapeAttribute - def NewShapeAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # ReshapeAttribute - def NewShapeLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # ReshapeAttribute - def NewShapeIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def ReshapeAttributeStart(builder): - builder.StartObject(1) - -def Start(builder): - ReshapeAttributeStart(builder) - -def ReshapeAttributeAddNewShape(builder, newShape): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(newShape), 0) - -def AddNewShape(builder, newShape): - ReshapeAttributeAddNewShape(builder, newShape) - -def ReshapeAttributeStartNewShapeVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StartNewShapeVector(builder, numElems: int) -> int: - return ReshapeAttributeStartNewShapeVector(builder, numElems) - -def ReshapeAttributeEnd(builder): - return builder.EndObject() - -def End(builder): - return ReshapeAttributeEnd(builder) diff --git a/python/tosa/SliceAttribute.py b/python/tosa/SliceAttribute.py deleted file mode 100644 index 6d8e00b..0000000 --- a/python/tosa/SliceAttribute.py +++ /dev/null @@ -1,119 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: tosa - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class SliceAttribute(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = SliceAttribute() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsSliceAttribute(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def SliceAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) - - # SliceAttribute - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # SliceAttribute - def Start(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SliceAttribute - def StartAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SliceAttribute - def StartLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SliceAttribute - def StartIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # SliceAttribute - def Size(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # SliceAttribute - def SizeAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # SliceAttribute - def SizeLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # SliceAttribute - def SizeIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - -def SliceAttributeStart(builder): - builder.StartObject(2) - -def Start(builder): - SliceAttributeStart(builder) - -def SliceAttributeAddStart(builder, start): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(start), 0) - -def AddStart(builder, start): - SliceAttributeAddStart(builder, start) - -def SliceAttributeStartStartVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StartStartVector(builder, numElems: int) -> int: - return SliceAttributeStartStartVector(builder, numElems) - -def SliceAttributeAddSize(builder, size): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(size), 0) - -def AddSize(builder, size): - SliceAttributeAddSize(builder, size) - -def SliceAttributeStartSizeVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StartSizeVector(builder, numElems: int) -> int: - return SliceAttributeStartSizeVector(builder, numElems) - -def SliceAttributeEnd(builder): - return builder.EndObject() - -def End(builder): - return SliceAttributeEnd(builder) diff --git a/python/tosa/TileAttribute.py b/python/tosa/TileAttribute.py deleted file mode 100644 index 89bf23b..0000000 --- a/python/tosa/TileAttribute.py +++ /dev/null @@ -1,80 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# namespace: tosa - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class TileAttribute(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAs(cls, buf, offset=0): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TileAttribute() - x.Init(buf, n + offset) - return x - - @classmethod - def GetRootAsTileAttribute(cls, buf, offset=0): - """This method is deprecated. Please switch to GetRootAs.""" - return cls.GetRootAs(buf, offset) - @classmethod - def TileAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) - - # TileAttribute - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TileAttribute - def Multiples(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # TileAttribute - def MultiplesAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # TileAttribute - def MultiplesLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # TileAttribute - def MultiplesIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - -def TileAttributeStart(builder): - builder.StartObject(1) - -def Start(builder): - TileAttributeStart(builder) - -def TileAttributeAddMultiples(builder, multiples): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(multiples), 0) - -def AddMultiples(builder, multiples): - TileAttributeAddMultiples(builder, multiples) - -def TileAttributeStartMultiplesVector(builder, numElems): - return builder.StartVector(4, numElems, 4) - -def StartMultiplesVector(builder, numElems: int) -> int: - return TileAttributeStartMultiplesVector(builder, numElems) - -def TileAttributeEnd(builder): - return builder.EndObject() - -def End(builder): - return TileAttributeEnd(builder) diff --git a/python/tosa/WhileLoopAttribute.py b/python/tosa/WhileLoopAttribute.py index 20bc728..5148c26 100644 --- a/python/tosa/WhileLoopAttribute.py +++ b/python/tosa/WhileLoopAttribute.py @@ -29,14 +29,14 @@ class WhileLoopAttribute(object): self._tab = flatbuffers.table.Table(buf, pos) # WhileLoopAttribute - def CondBranch(self): + def CondGraph(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 # WhileLoopAttribute - def BodyBranch(self): + def BodyGraph(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: return self._tab.String(o + self._tab.Pos) @@ -48,17 +48,17 @@ def WhileLoopAttributeStart(builder): def Start(builder): WhileLoopAttributeStart(builder) -def WhileLoopAttributeAddCondBranch(builder, condBranch): - builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(condBranch), 0) +def WhileLoopAttributeAddCondGraph(builder, condGraph): + builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(condGraph), 0) -def AddCondBranch(builder, condBranch): - WhileLoopAttributeAddCondBranch(builder, condBranch) +def AddCondGraph(builder, condGraph): + WhileLoopAttributeAddCondGraph(builder, condGraph) -def WhileLoopAttributeAddBodyBranch(builder, bodyBranch): - builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(bodyBranch), 0) +def WhileLoopAttributeAddBodyGraph(builder, bodyGraph): + builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(bodyGraph), 0) -def AddBodyBranch(builder, bodyBranch): - WhileLoopAttributeAddBodyBranch(builder, bodyBranch) +def AddBodyGraph(builder, bodyGraph): + WhileLoopAttributeAddBodyGraph(builder, bodyGraph) def WhileLoopAttributeEnd(builder): return builder.EndObject() -- cgit v1.2.1