# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

import flatbuffers
from flatbuffers.compat import import_numpy
np = import_numpy()

class TensorDescribe(object):
    __slots__ = ['_tab']

    @classmethod
    def GetRootAs(cls, buf, offset=0):
        n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
        x = TensorDescribe()
        x.Init(buf, n + offset)
        return x

    @classmethod
    def GetRootAsTensorDescribe(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    # TensorDescribe
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

    # TensorDescribe
    def Blob(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = Blob()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # TensorDescribe
    def Index(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 0

    # TensorDescribe
    def Name(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

    # TensorDescribe
    def Regions(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            obj = Region()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # TensorDescribe
    def RegionsLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # TensorDescribe
    def RegionsIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        return o == 0

    # TensorDescribe
    def QuantInfo(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = self._tab.Indirect(o + self._tab.Pos)
            obj = TensorQuantInfo()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

def TensorDescribeStart(builder): builder.StartObject(5)
def Start(builder):
    return TensorDescribeStart(builder)
def TensorDescribeAddBlob(builder, blob): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(blob), 0)
def AddBlob(builder, blob):
    return TensorDescribeAddBlob(builder, blob)
def TensorDescribeAddIndex(builder, index): builder.PrependInt32Slot(1, index, 0)
def AddIndex(builder, index):
    return TensorDescribeAddIndex(builder, index)
def TensorDescribeAddName(builder, name): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder, name):
    return TensorDescribeAddName(builder, name)
def TensorDescribeAddRegions(builder, regions): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(regions), 0)
def AddRegions(builder, regions):
    return TensorDescribeAddRegions(builder, regions)
def TensorDescribeStartRegionsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartRegionsVector(builder, numElems):
    return TensorDescribeStartRegionsVector(builder, numElems)
def TensorDescribeAddQuantInfo(builder, quantInfo): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(quantInfo), 0)
def AddQuantInfo(builder, quantInfo):
    return TensorDescribeAddQuantInfo(builder, quantInfo)
def TensorDescribeEnd(builder): return builder.EndObject()
def End(builder):
    return TensorDescribeEnd(builder)