# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

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

    # LoopParam
    def OutputIndexes(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

    # LoopParam
    def OutputIndexesAsNumpy(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

    # LoopParam
    def OutputIndexesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LoopParam
    def OutputIndexesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
        return o == 0

    # LoopParam
    def InputIndexes(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.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return 0

    # LoopParam
    def InputIndexesAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
        return 0

    # LoopParam
    def InputIndexesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LoopParam
    def InputIndexesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        return o == 0

    # LoopParam
    def MidTensors(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 = TensorDescribe()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

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

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

    # LoopParam
    def Parallel(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return True

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

    # LoopParam
    def Commands(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            obj = RegionCommand()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # LoopParam
    def CommandsLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LoopParam
    def CommandsIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
        return o == 0

    # LoopParam
    def IsBinary(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
        if o != 0:
            return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
        return False

def LoopParamStart(builder): builder.StartObject(8)
def Start(builder):
    return LoopParamStart(builder)
def LoopParamAddTensorNumber(builder, tensorNumber): builder.PrependInt32Slot(0, tensorNumber, 0)
def AddTensorNumber(builder, tensorNumber):
    return LoopParamAddTensorNumber(builder, tensorNumber)
def LoopParamAddOutputIndexes(builder, outputIndexes): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(outputIndexes), 0)
def AddOutputIndexes(builder, outputIndexes):
    return LoopParamAddOutputIndexes(builder, outputIndexes)
def LoopParamStartOutputIndexesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartOutputIndexesVector(builder, numElems):
    return LoopParamStartOutputIndexesVector(builder, numElems)
def LoopParamAddInputIndexes(builder, inputIndexes): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(inputIndexes), 0)
def AddInputIndexes(builder, inputIndexes):
    return LoopParamAddInputIndexes(builder, inputIndexes)
def LoopParamStartInputIndexesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartInputIndexesVector(builder, numElems):
    return LoopParamStartInputIndexesVector(builder, numElems)
def LoopParamAddMidTensors(builder, midTensors): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(midTensors), 0)
def AddMidTensors(builder, midTensors):
    return LoopParamAddMidTensors(builder, midTensors)
def LoopParamStartMidTensorsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartMidTensorsVector(builder, numElems):
    return LoopParamStartMidTensorsVector(builder, numElems)
def LoopParamAddParallel(builder, parallel): builder.PrependBoolSlot(4, parallel, 1)
def AddParallel(builder, parallel):
    return LoopParamAddParallel(builder, parallel)
def LoopParamAddLoopNumber(builder, loopNumber): builder.PrependInt32Slot(5, loopNumber, 0)
def AddLoopNumber(builder, loopNumber):
    return LoopParamAddLoopNumber(builder, loopNumber)
def LoopParamAddCommands(builder, commands): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(commands), 0)
def AddCommands(builder, commands):
    return LoopParamAddCommands(builder, commands)
def LoopParamStartCommandsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartCommandsVector(builder, numElems):
    return LoopParamStartCommandsVector(builder, numElems)
def LoopParamAddIsBinary(builder, isBinary): builder.PrependBoolSlot(7, isBinary, 0)
def AddIsBinary(builder, isBinary):
    return LoopParamAddIsBinary(builder, isBinary)
def LoopParamEnd(builder): return builder.EndObject()
def End(builder):
    return LoopParamEnd(builder)