# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

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

    # ReductionParam
    def Dim(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

    # ReductionParam
    def DimAsNumpy(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

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

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

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

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

    # ReductionParam
    def DType(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 1

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

def ReductionParamStart(builder): builder.StartObject(6)
def Start(builder):
    return ReductionParamStart(builder)
def ReductionParamAddOperation(builder, operation): builder.PrependInt8Slot(0, operation, 0)
def AddOperation(builder, operation):
    return ReductionParamAddOperation(builder, operation)
def ReductionParamAddDim(builder, dim): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(dim), 0)
def AddDim(builder, dim):
    return ReductionParamAddDim(builder, dim)
def ReductionParamStartDimVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartDimVector(builder, numElems):
    return ReductionParamStartDimVector(builder, numElems)
def ReductionParamAddCoeff(builder, coeff): builder.PrependFloat32Slot(2, coeff, 0.0)
def AddCoeff(builder, coeff):
    return ReductionParamAddCoeff(builder, coeff)
def ReductionParamAddKeepDims(builder, keepDims): builder.PrependBoolSlot(3, keepDims, 0)
def AddKeepDims(builder, keepDims):
    return ReductionParamAddKeepDims(builder, keepDims)
def ReductionParamAddDType(builder, dType): builder.PrependInt32Slot(4, dType, 1)
def AddDType(builder, dType):
    return ReductionParamAddDType(builder, dType)
def ReductionParamAddReduction(builder, reduction): builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(reduction), 0)
def AddReduction(builder, reduction):
    return ReductionParamAddReduction(builder, reduction)
def ReductionParamEnd(builder): return builder.EndObject()
def End(builder):
    return ReductionParamEnd(builder)