Module tflite.Tensor
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 Tensor(object):
__slots__ = ['_tab']
@classmethod
def GetRootAs(cls, buf, offset=0):
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
x = Tensor()
x.Init(buf, n + offset)
return x
@classmethod
def GetRootAsTensor(cls, buf, offset=0):
"""This method is deprecated. Please switch to GetRootAs."""
return cls.GetRootAs(buf, offset)
@classmethod
def TensorBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
# Tensor
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
# Tensor
def Shape(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
# Tensor
def ShapeAsNumpy(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
# Tensor
def ShapeLength(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
if o != 0:
return self._tab.VectorLen(o)
return 0
# Tensor
def ShapeIsNone(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
return o == 0
# Tensor
def Type(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
return 0
# Tensor
def Buffer(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
if o != 0:
return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
return 0
# Tensor
def Name(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
if o != 0:
return self._tab.String(o + self._tab.Pos)
return None
# Tensor
def Quantization(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from tflite.QuantizationParameters import QuantizationParameters
obj = QuantizationParameters()
obj.Init(self._tab.Bytes, x)
return obj
return None
# Tensor
def IsVariable(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
if o != 0:
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return False
# Tensor
def Sparsity(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
if o != 0:
x = self._tab.Indirect(o + self._tab.Pos)
from tflite.SparsityParameters import SparsityParameters
obj = SparsityParameters()
obj.Init(self._tab.Bytes, x)
return obj
return None
# Tensor
def ShapeSignature(self, j):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
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
# Tensor
def ShapeSignatureAsNumpy(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
if o != 0:
return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o)
return 0
# Tensor
def ShapeSignatureLength(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
if o != 0:
return self._tab.VectorLen(o)
return 0
# Tensor
def ShapeSignatureIsNone(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
return o == 0
# Tensor
def HasRank(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
if o != 0:
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return False
def TensorStart(builder): builder.StartObject(9)
def Start(builder):
return TensorStart(builder)
def TensorAddShape(builder, shape): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0)
def AddShape(builder, shape):
return TensorAddShape(builder, shape)
def TensorStartShapeVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartShapeVector(builder, numElems):
return TensorStartShapeVector(builder, numElems)
def TensorAddType(builder, type): builder.PrependInt8Slot(1, type, 0)
def AddType(builder, type):
return TensorAddType(builder, type)
def TensorAddBuffer(builder, buffer): builder.PrependUint32Slot(2, buffer, 0)
def AddBuffer(builder, buffer):
return TensorAddBuffer(builder, buffer)
def TensorAddName(builder, name): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def AddName(builder, name):
return TensorAddName(builder, name)
def TensorAddQuantization(builder, quantization): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(quantization), 0)
def AddQuantization(builder, quantization):
return TensorAddQuantization(builder, quantization)
def TensorAddIsVariable(builder, isVariable): builder.PrependBoolSlot(5, isVariable, 0)
def AddIsVariable(builder, isVariable):
return TensorAddIsVariable(builder, isVariable)
def TensorAddSparsity(builder, sparsity): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(sparsity), 0)
def AddSparsity(builder, sparsity):
return TensorAddSparsity(builder, sparsity)
def TensorAddShapeSignature(builder, shapeSignature): builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(shapeSignature), 0)
def AddShapeSignature(builder, shapeSignature):
return TensorAddShapeSignature(builder, shapeSignature)
def TensorStartShapeSignatureVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def StartShapeSignatureVector(builder, numElems):
return TensorStartShapeSignatureVector(builder, numElems)
def TensorAddHasRank(builder, hasRank): builder.PrependBoolSlot(8, hasRank, 0)
def AddHasRank(builder, hasRank):
return TensorAddHasRank(builder, hasRank)
def TensorEnd(builder): return builder.EndObject()
def End(builder):
return TensorEnd(builder)
Functions
def AddBuffer(builder, buffer)
-
Expand source code
def AddBuffer(builder, buffer): return TensorAddBuffer(builder, buffer)
def AddHasRank(builder, hasRank)
-
Expand source code
def AddHasRank(builder, hasRank): return TensorAddHasRank(builder, hasRank)
def AddIsVariable(builder, isVariable)
-
Expand source code
def AddIsVariable(builder, isVariable): return TensorAddIsVariable(builder, isVariable)
def AddName(builder, name)
-
Expand source code
def AddName(builder, name): return TensorAddName(builder, name)
def AddQuantization(builder, quantization)
-
Expand source code
def AddQuantization(builder, quantization): return TensorAddQuantization(builder, quantization)
def AddShape(builder, shape)
-
Expand source code
def AddShape(builder, shape): return TensorAddShape(builder, shape)
def AddShapeSignature(builder, shapeSignature)
-
Expand source code
def AddShapeSignature(builder, shapeSignature): return TensorAddShapeSignature(builder, shapeSignature)
def AddSparsity(builder, sparsity)
-
Expand source code
def AddSparsity(builder, sparsity): return TensorAddSparsity(builder, sparsity)
def AddType(builder, type)
-
Expand source code
def AddType(builder, type): return TensorAddType(builder, type)
def End(builder)
-
Expand source code
def End(builder): return TensorEnd(builder)
def Start(builder)
-
Expand source code
def Start(builder): return TensorStart(builder)
def StartShapeSignatureVector(builder, numElems)
-
Expand source code
def StartShapeSignatureVector(builder, numElems): return TensorStartShapeSignatureVector(builder, numElems)
def StartShapeVector(builder, numElems)
-
Expand source code
def StartShapeVector(builder, numElems): return TensorStartShapeVector(builder, numElems)
def TensorAddBuffer(builder, buffer)
-
Expand source code
def TensorAddBuffer(builder, buffer): builder.PrependUint32Slot(2, buffer, 0)
def TensorAddHasRank(builder, hasRank)
-
Expand source code
def TensorAddHasRank(builder, hasRank): builder.PrependBoolSlot(8, hasRank, 0)
def TensorAddIsVariable(builder, isVariable)
-
Expand source code
def TensorAddIsVariable(builder, isVariable): builder.PrependBoolSlot(5, isVariable, 0)
def TensorAddName(builder, name)
-
Expand source code
def TensorAddName(builder, name): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
def TensorAddQuantization(builder, quantization)
-
Expand source code
def TensorAddQuantization(builder, quantization): builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(quantization), 0)
def TensorAddShape(builder, shape)
-
Expand source code
def TensorAddShape(builder, shape): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0)
def TensorAddShapeSignature(builder, shapeSignature)
-
Expand source code
def TensorAddShapeSignature(builder, shapeSignature): builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(shapeSignature), 0)
def TensorAddSparsity(builder, sparsity)
-
Expand source code
def TensorAddSparsity(builder, sparsity): builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(sparsity), 0)
def TensorAddType(builder, type)
-
Expand source code
def TensorAddType(builder, type): builder.PrependInt8Slot(1, type, 0)
def TensorEnd(builder)
-
Expand source code
def TensorEnd(builder): return builder.EndObject()
def TensorStart(builder)
-
Expand source code
def TensorStart(builder): builder.StartObject(9)
def TensorStartShapeSignatureVector(builder, numElems)
-
Expand source code
def TensorStartShapeSignatureVector(builder, numElems): return builder.StartVector(4, numElems, 4)
def TensorStartShapeVector(builder, numElems)
-
Expand source code
def TensorStartShapeVector(builder, numElems): return builder.StartVector(4, numElems, 4)
Classes
class Tensor
-
Expand source code
class Tensor(object): __slots__ = ['_tab'] @classmethod def GetRootAs(cls, buf, offset=0): n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) x = Tensor() x.Init(buf, n + offset) return x @classmethod def GetRootAsTensor(cls, buf, offset=0): """This method is deprecated. Please switch to GetRootAs.""" return cls.GetRootAs(buf, offset) @classmethod def TensorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) # Tensor def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos) # Tensor def Shape(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 # Tensor def ShapeAsNumpy(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 # Tensor def ShapeLength(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) if o != 0: return self._tab.VectorLen(o) return 0 # Tensor def ShapeIsNone(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) return o == 0 # Tensor def Type(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) return 0 # Tensor def Buffer(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) if o != 0: return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) return 0 # Tensor def Name(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) if o != 0: return self._tab.String(o + self._tab.Pos) return None # Tensor def Quantization(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) from tflite.QuantizationParameters import QuantizationParameters obj = QuantizationParameters() obj.Init(self._tab.Bytes, x) return obj return None # Tensor def IsVariable(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) if o != 0: return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) return False # Tensor def Sparsity(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) from tflite.SparsityParameters import SparsityParameters obj = SparsityParameters() obj.Init(self._tab.Bytes, x) return obj return None # Tensor def ShapeSignature(self, j): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) 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 # Tensor def ShapeSignatureAsNumpy(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) if o != 0: return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) return 0 # Tensor def ShapeSignatureLength(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) if o != 0: return self._tab.VectorLen(o) return 0 # Tensor def ShapeSignatureIsNone(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) return o == 0 # Tensor def HasRank(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) if o != 0: return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) return False
Static methods
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 = Tensor() x.Init(buf, n + offset) return x
def GetRootAsTensor(buf, offset=0)
-
This method is deprecated. Please switch to GetRootAs.
Expand source code
@classmethod def GetRootAsTensor(cls, buf, offset=0): """This method is deprecated. Please switch to GetRootAs.""" return cls.GetRootAs(buf, offset)
def TensorBufferHasIdentifier(buf, offset, size_prefixed=False)
-
Expand source code
@classmethod def TensorBufferHasIdentifier(cls, buf, offset, size_prefixed=False): return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
Methods
def Buffer(self)
-
Expand source code
def Buffer(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) if o != 0: return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos) return 0
def HasRank(self)
-
Expand source code
def HasRank(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20)) if o != 0: return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) return False
def Init(self, buf, pos)
-
Expand source code
def Init(self, buf, pos): self._tab = flatbuffers.table.Table(buf, pos)
def IsVariable(self)
-
Expand source code
def IsVariable(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14)) if o != 0: return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos)) return False
def Name(self)
-
Expand source code
def Name(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) if o != 0: return self._tab.String(o + self._tab.Pos) return None
def Quantization(self)
-
Expand source code
def Quantization(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) from tflite.QuantizationParameters import QuantizationParameters obj = QuantizationParameters() obj.Init(self._tab.Bytes, x) return obj return None
def Shape(self, j)
-
Expand source code
def Shape(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
def ShapeAsNumpy(self)
-
Expand source code
def ShapeAsNumpy(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
def ShapeIsNone(self)
-
Expand source code
def ShapeIsNone(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) return o == 0
def ShapeLength(self)
-
Expand source code
def ShapeLength(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) if o != 0: return self._tab.VectorLen(o) return 0
def ShapeSignature(self, j)
-
Expand source code
def ShapeSignature(self, j): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) 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
def ShapeSignatureAsNumpy(self)
-
Expand source code
def ShapeSignatureAsNumpy(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) if o != 0: return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) return 0
def ShapeSignatureIsNone(self)
-
Expand source code
def ShapeSignatureIsNone(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) return o == 0
def ShapeSignatureLength(self)
-
Expand source code
def ShapeSignatureLength(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18)) if o != 0: return self._tab.VectorLen(o) return 0
def Sparsity(self)
-
Expand source code
def Sparsity(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) from tflite.SparsityParameters import SparsityParameters obj = SparsityParameters() obj.Init(self._tab.Bytes, x) return obj return None
def Type(self)
-
Expand source code
def Type(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos) return 0