# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

    # QuantizedFloatParam
    def Weight(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.Int8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
        return 0

    # QuantizedFloatParam
    def WeightAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int8Flags, o)
        return 0

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

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

    # QuantizedFloatParam
    def Bias(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

    # QuantizedFloatParam
    def BiasAsNumpy(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

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

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

    # QuantizedFloatParam
    def Scale(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

    # QuantizedFloatParam
    def ScaleAsNumpy(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

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

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

    # QuantizedFloatParam
    def TensorScale(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

    # QuantizedFloatParam
    def TensorScaleAsNumpy(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

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

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

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

    # QuantizedFloatParam
    def Nbits(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 8

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

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

    # QuantizedFloatParam
    def ClampMin(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return -128

    # QuantizedFloatParam
    def ClampMax(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
        return 127

def QuantizedFloatParamStart(builder): builder.StartObject(10)
def Start(builder):
    return QuantizedFloatParamStart(builder)
def QuantizedFloatParamAddWeight(builder, weight): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(weight), 0)
def AddWeight(builder, weight):
    return QuantizedFloatParamAddWeight(builder, weight)
def QuantizedFloatParamStartWeightVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def StartWeightVector(builder, numElems):
    return QuantizedFloatParamStartWeightVector(builder, numElems)
def QuantizedFloatParamAddBias(builder, bias): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(bias), 0)
def AddBias(builder, bias):
    return QuantizedFloatParamAddBias(builder, bias)
def QuantizedFloatParamStartBiasVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartBiasVector(builder, numElems):
    return QuantizedFloatParamStartBiasVector(builder, numElems)
def QuantizedFloatParamAddScale(builder, scale): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(scale), 0)
def AddScale(builder, scale):
    return QuantizedFloatParamAddScale(builder, scale)
def QuantizedFloatParamStartScaleVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartScaleVector(builder, numElems):
    return QuantizedFloatParamStartScaleVector(builder, numElems)
def QuantizedFloatParamAddTensorScale(builder, tensorScale): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(tensorScale), 0)
def AddTensorScale(builder, tensorScale):
    return QuantizedFloatParamAddTensorScale(builder, tensorScale)
def QuantizedFloatParamStartTensorScaleVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartTensorScaleVector(builder, numElems):
    return QuantizedFloatParamStartTensorScaleVector(builder, numElems)
def QuantizedFloatParamAddMethod(builder, method): builder.PrependInt8Slot(4, method, 0)
def AddMethod(builder, method):
    return QuantizedFloatParamAddMethod(builder, method)
def QuantizedFloatParamAddNbits(builder, nbits): builder.PrependInt32Slot(5, nbits, 8)
def AddNbits(builder, nbits):
    return QuantizedFloatParamAddNbits(builder, nbits)
def QuantizedFloatParamAddZeroPoint(builder, zeroPoint): builder.PrependInt32Slot(6, zeroPoint, 0)
def AddZeroPoint(builder, zeroPoint):
    return QuantizedFloatParamAddZeroPoint(builder, zeroPoint)
def QuantizedFloatParamAddOutputZeroPoint(builder, outputZeroPoint): builder.PrependInt32Slot(7, outputZeroPoint, 0)
def AddOutputZeroPoint(builder, outputZeroPoint):
    return QuantizedFloatParamAddOutputZeroPoint(builder, outputZeroPoint)
def QuantizedFloatParamAddClampMin(builder, clampMin): builder.PrependInt32Slot(8, clampMin, -128)
def AddClampMin(builder, clampMin):
    return QuantizedFloatParamAddClampMin(builder, clampMin)
def QuantizedFloatParamAddClampMax(builder, clampMax): builder.PrependInt32Slot(9, clampMax, 127)
def AddClampMax(builder, clampMax):
    return QuantizedFloatParamAddClampMax(builder, clampMax)
def QuantizedFloatParamEnd(builder): return builder.EndObject()
def End(builder):
    return QuantizedFloatParamEnd(builder)