# automatically generated by the FlatBuffers compiler, do not modify

# namespace: MNN

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

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

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

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

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

    # TensorQuantInfo
    def Zero(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

    # TensorQuantInfo
    def Min(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 -128.0

    # TensorQuantInfo
    def Max(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
        if o != 0:
            return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
        return 127.0

    # TensorQuantInfo
    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

    # TensorQuantInfo
    def Realtype(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 6

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

def TensorQuantInfoStart(builder): builder.StartObject(7)
def Start(builder):
    return TensorQuantInfoStart(builder)
def TensorQuantInfoAddScale(builder, scale): builder.PrependFloat32Slot(0, scale, 0.0)
def AddScale(builder, scale):
    return TensorQuantInfoAddScale(builder, scale)
def TensorQuantInfoAddZero(builder, zero): builder.PrependFloat32Slot(1, zero, 0.0)
def AddZero(builder, zero):
    return TensorQuantInfoAddZero(builder, zero)
def TensorQuantInfoAddMin(builder, min): builder.PrependFloat32Slot(2, min, -128.0)
def AddMin(builder, min):
    return TensorQuantInfoAddMin(builder, min)
def TensorQuantInfoAddMax(builder, max): builder.PrependFloat32Slot(3, max, 127.0)
def AddMax(builder, max):
    return TensorQuantInfoAddMax(builder, max)
def TensorQuantInfoAddType(builder, type): builder.PrependInt32Slot(4, type, 0)
def AddType(builder, type):
    return TensorQuantInfoAddType(builder, type)
def TensorQuantInfoAddRealtype(builder, realtype): builder.PrependInt32Slot(5, realtype, 6)
def AddRealtype(builder, realtype):
    return TensorQuantInfoAddRealtype(builder, realtype)
def TensorQuantInfoAddIsdequant(builder, isdequant): builder.PrependBoolSlot(6, isdequant, 0)
def AddIsdequant(builder, isdequant):
    return TensorQuantInfoAddIsdequant(builder, isdequant)
def TensorQuantInfoEnd(builder): return builder.EndObject()
def End(builder):
    return TensorQuantInfoEnd(builder)