# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

    # LayerNorm
    def Axis(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

    # LayerNorm
    def AxisAsNumpy(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

    # LayerNorm
    def AxisLength(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.VectorLen(o)
        return 0

    # LayerNorm
    def AxisIsNone(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        return o == 0

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

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

    # LayerNorm
    def GammaAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
        return 0

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

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

    # LayerNorm
    def Beta(self, j):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            a = self._tab.Vector(o)
            return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
        return 0

    # LayerNorm
    def BetaAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
        return 0

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

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

def LayerNormStart(builder): builder.StartObject(4)
def Start(builder):
    return LayerNormStart(builder)
def LayerNormAddAxis(builder, axis): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(axis), 0)
def AddAxis(builder, axis):
    return LayerNormAddAxis(builder, axis)
def LayerNormStartAxisVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartAxisVector(builder, numElems):
    return LayerNormStartAxisVector(builder, numElems)
def LayerNormAddEpsilon(builder, epsilon): builder.PrependFloat32Slot(1, epsilon, 0.0)
def AddEpsilon(builder, epsilon):
    return LayerNormAddEpsilon(builder, epsilon)
def LayerNormAddGamma(builder, gamma): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(gamma), 0)
def AddGamma(builder, gamma):
    return LayerNormAddGamma(builder, gamma)
def LayerNormStartGammaVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartGammaVector(builder, numElems):
    return LayerNormStartGammaVector(builder, numElems)
def LayerNormAddBeta(builder, beta): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(beta), 0)
def AddBeta(builder, beta):
    return LayerNormAddBeta(builder, beta)
def LayerNormStartBetaVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartBetaVector(builder, numElems):
    return LayerNormStartBetaVector(builder, numElems)
def LayerNormEnd(builder): return builder.EndObject()
def End(builder):
    return LayerNormEnd(builder)