diff options
Diffstat (limited to 'ethosu/vela/tflite/Tensor.py')
-rw-r--r-- | ethosu/vela/tflite/Tensor.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ethosu/vela/tflite/Tensor.py b/ethosu/vela/tflite/Tensor.py index 4c39b7cb..6a947849 100644 --- a/ethosu/vela/tflite/Tensor.py +++ b/ethosu/vela/tflite/Tensor.py @@ -3,6 +3,8 @@ # namespace: tflite import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() class Tensor(object): __slots__ = ['_tab'] @@ -14,6 +16,10 @@ class Tensor(object): x.Init(buf, n + offset) return x + @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) @@ -41,6 +47,11 @@ class Tensor(object): 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: @@ -112,6 +123,11 @@ class Tensor(object): 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 + def TensorStart(builder): builder.StartObject(8) def TensorAddShape(builder, shape): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(shape), 0) def TensorStartShapeVector(builder, numElems): return builder.StartVector(4, numElems, 4) |