Module tflite.Buffer

Expand source code
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: tflite

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

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

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

    @classmethod
    def GetRootAsBuffer(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    @classmethod
    def BufferBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
        return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)

    # Buffer
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

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

    # Buffer
    def DataAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

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

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

def BufferStart(builder): builder.StartObject(1)
def Start(builder):
    return BufferStart(builder)
def BufferAddData(builder, data): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0)
def AddData(builder, data):
    return BufferAddData(builder, data)
def BufferStartDataVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def StartDataVector(builder, numElems):
    return BufferStartDataVector(builder, numElems)
def BufferEnd(builder): return builder.EndObject()
def End(builder):
    return BufferEnd(builder)

Functions

def AddData(builder, data)
Expand source code
def AddData(builder, data):
    return BufferAddData(builder, data)
def BufferAddData(builder, data)
Expand source code
def BufferAddData(builder, data): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0)
def BufferEnd(builder)
Expand source code
def BufferEnd(builder): return builder.EndObject()
def BufferStart(builder)
Expand source code
def BufferStart(builder): builder.StartObject(1)
def BufferStartDataVector(builder, numElems)
Expand source code
def BufferStartDataVector(builder, numElems): return builder.StartVector(1, numElems, 1)
def End(builder)
Expand source code
def End(builder):
    return BufferEnd(builder)
def Start(builder)
Expand source code
def Start(builder):
    return BufferStart(builder)
def StartDataVector(builder, numElems)
Expand source code
def StartDataVector(builder, numElems):
    return BufferStartDataVector(builder, numElems)

Classes

class Buffer
Expand source code
class Buffer(object):
    __slots__ = ['_tab']

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

    @classmethod
    def GetRootAsBuffer(cls, buf, offset=0):
        """This method is deprecated. Please switch to GetRootAs."""
        return cls.GetRootAs(buf, offset)
    @classmethod
    def BufferBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
        return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)

    # Buffer
    def Init(self, buf, pos):
        self._tab = flatbuffers.table.Table(buf, pos)

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

    # Buffer
    def DataAsNumpy(self):
        o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
        if o != 0:
            return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
        return 0

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

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

Static methods

def BufferBufferHasIdentifier(buf, offset, size_prefixed=False)
Expand source code
@classmethod
def BufferBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
    return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
def GetRootAs(buf, offset=0)
Expand source code
@classmethod
def GetRootAs(cls, buf, offset=0):
    n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
    x = Buffer()
    x.Init(buf, n + offset)
    return x
def GetRootAsBuffer(buf, offset=0)

This method is deprecated. Please switch to GetRootAs.

Expand source code
@classmethod
def GetRootAsBuffer(cls, buf, offset=0):
    """This method is deprecated. Please switch to GetRootAs."""
    return cls.GetRootAs(buf, offset)

Methods

def Data(self, j)
Expand source code
def Data(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.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
    return 0
def DataAsNumpy(self)
Expand source code
def DataAsNumpy(self):
    o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
    if o != 0:
        return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
    return 0
def DataIsNone(self)
Expand source code
def DataIsNone(self):
    o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
    return o == 0
def DataLength(self)
Expand source code
def DataLength(self):
    o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
    if o != 0:
        return self._tab.VectorLen(o)
    return 0
def Init(self, buf, pos)
Expand source code
def Init(self, buf, pos):
    self._tab = flatbuffers.table.Table(buf, pos)