# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

    # SubGraphProto
    def Name(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

    # SubGraphProto
    def Inputs(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

    # SubGraphProto
    def InputsAsNumpy(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

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

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

    # SubGraphProto
    def Outputs(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

    # SubGraphProto
    def OutputsAsNumpy(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

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

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

    # SubGraphProto
    def Tensors(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return ""

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

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

    # SubGraphProto
    def Nodes(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            x = self._tab.Vector(o)
            x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
            x = self._tab.Indirect(x)
            obj = Op()
            obj.Init(self._tab.Bytes, x)
            return obj
        return None

    # SubGraphProto
    def NodesLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # SubGraphProto
    def NodesIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
        return o == 0

    # SubGraphProto
    def ExtraTensorDescribe(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        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

    # SubGraphProto
    def ExtraTensorDescribeLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # SubGraphProto
    def ExtraTensorDescribeIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        return o == 0

def SubGraphProtoStart(builder): builder.StartObject(6)
def Start(builder):
    return SubGraphProtoStart(builder)
def SubGraphProtoAddName(builder, name): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder, name):
    return SubGraphProtoAddName(builder, name)
def SubGraphProtoAddInputs(builder, inputs): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(inputs), 0)
def AddInputs(builder, inputs):
    return SubGraphProtoAddInputs(builder, inputs)
def SubGraphProtoStartInputsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartInputsVector(builder, numElems):
    return SubGraphProtoStartInputsVector(builder, numElems)
def SubGraphProtoAddOutputs(builder, outputs): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(outputs), 0)
def AddOutputs(builder, outputs):
    return SubGraphProtoAddOutputs(builder, outputs)
def SubGraphProtoStartOutputsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartOutputsVector(builder, numElems):
    return SubGraphProtoStartOutputsVector(builder, numElems)
def SubGraphProtoAddTensors(builder, tensors): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(tensors), 0)
def AddTensors(builder, tensors):
    return SubGraphProtoAddTensors(builder, tensors)
def SubGraphProtoStartTensorsVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartTensorsVector(builder, numElems):
    return SubGraphProtoStartTensorsVector(builder, numElems)
def SubGraphProtoAddNodes(builder, nodes): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(nodes), 0)
def AddNodes(builder, nodes):
    return SubGraphProtoAddNodes(builder, nodes)
def SubGraphProtoStartNodesVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartNodesVector(builder, numElems):
    return SubGraphProtoStartNodesVector(builder, numElems)
def SubGraphProtoAddExtraTensorDescribe(builder, extraTensorDescribe): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(extraTensorDescribe), 0)
def AddExtraTensorDescribe(builder, extraTensorDescribe):
    return SubGraphProtoAddExtraTensorDescribe(builder, extraTensorDescribe)
def SubGraphProtoStartExtraTensorDescribeVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartExtraTensorDescribeVector(builder, numElems):
    return SubGraphProtoStartExtraTensorDescribeVector(builder, numElems)
def SubGraphProtoEnd(builder): return builder.EndObject()
def End(builder):
    return SubGraphProtoEnd(builder)