# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

    # Attribute
    def S(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

    # Attribute
    def I(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

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

    # Attribute
    def Key(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.String(o + self._tab.Pos)
        return None

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

    # Attribute
    def F(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 0.0

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

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

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

def AttributeStart(builder): builder.StartObject(9)
def Start(builder):
    return AttributeStart(builder)
def AttributeAddS(builder, s): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(s), 0)
def AddS(builder, s):
    return AttributeAddS(builder, s)
def AttributeAddI(builder, i): builder.PrependInt32Slot(1, i, 0)
def AddI(builder, i):
    return AttributeAddI(builder, i)
def AttributeAddB(builder, b): builder.PrependBoolSlot(2, b, 0)
def AddB(builder, b):
    return AttributeAddB(builder, b)
def AttributeAddKey(builder, key): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(key), 0)
def AddKey(builder, key):
    return AttributeAddKey(builder, key)
def AttributeAddType(builder, type): builder.PrependInt32Slot(4, type, 0)
def AddType(builder, type):
    return AttributeAddType(builder, type)
def AttributeAddF(builder, f): builder.PrependFloat32Slot(5, f, 0.0)
def AddF(builder, f):
    return AttributeAddF(builder, f)
def AttributeAddTensor(builder, tensor): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(tensor), 0)
def AddTensor(builder, tensor):
    return AttributeAddTensor(builder, tensor)
def AttributeAddList(builder, list): builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(list), 0)
def AddList(builder, list):
    return AttributeAddList(builder, list)
def AttributeAddFunc(builder, func): builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(func), 0)
def AddFunc(builder, func):
    return AttributeAddFunc(builder, func)
def AttributeEnd(builder): return builder.EndObject()
def End(builder):
    return AttributeEnd(builder)