Skip to content

Commit d010b69

Browse files
Added flatbuffer parse code for tflite (#1247)
Signed-off-by: Tom Wildenhain <[email protected]>
1 parent 7900e3a commit d010b69

File tree

137 files changed

+5984
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+5984
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ def run(self):
8080
8181
author_email='[email protected]',
8282
url='https://github.com/onnx/tensorflow-onnx',
83-
install_requires=['numpy>=1.14.1', 'onnx>=1.4.1', 'requests', 'six']
83+
install_requires=['numpy>=1.14.1', 'onnx>=1.4.1', 'requests', 'six', 'flatbuffers']
8484
)

tflite/AbsOptions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class AbsOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsAbsOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = AbsOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def AbsOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# AbsOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
def AbsOptionsStart(builder): builder.StartObject(0)
28+
def AbsOptionsEnd(builder): return builder.EndObject()

tflite/ActivationFunctionType.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
class ActivationFunctionType(object):
6+
NONE = 0
7+
RELU = 1
8+
RELU_N1_TO_1 = 2
9+
RELU6 = 3
10+
TANH = 4
11+
SIGN_BIT = 5
12+

tflite/AddNOptions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class AddNOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsAddNOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = AddNOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def AddNOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# AddNOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
def AddNOptionsStart(builder): builder.StartObject(0)
28+
def AddNOptionsEnd(builder): return builder.EndObject()

tflite/AddOptions.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class AddOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsAddOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = AddOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def AddOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# AddOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
# AddOptions
28+
def FusedActivationFunction(self):
29+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30+
if o != 0:
31+
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
32+
return 0
33+
34+
# AddOptions
35+
def PotScaleInt16(self):
36+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
37+
if o != 0:
38+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
39+
return True
40+
41+
def AddOptionsStart(builder): builder.StartObject(2)
42+
def AddOptionsAddFusedActivationFunction(builder, fusedActivationFunction): builder.PrependInt8Slot(0, fusedActivationFunction, 0)
43+
def AddOptionsAddPotScaleInt16(builder, potScaleInt16): builder.PrependBoolSlot(1, potScaleInt16, 1)
44+
def AddOptionsEnd(builder): return builder.EndObject()

tflite/ArgMaxOptions.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class ArgMaxOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsArgMaxOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = ArgMaxOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def ArgMaxOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# ArgMaxOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
# ArgMaxOptions
28+
def OutputType(self):
29+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30+
if o != 0:
31+
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
32+
return 0
33+
34+
def ArgMaxOptionsStart(builder): builder.StartObject(1)
35+
def ArgMaxOptionsAddOutputType(builder, outputType): builder.PrependInt8Slot(0, outputType, 0)
36+
def ArgMaxOptionsEnd(builder): return builder.EndObject()

tflite/ArgMinOptions.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class ArgMinOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsArgMinOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = ArgMinOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def ArgMinOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# ArgMinOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
# ArgMinOptions
28+
def OutputType(self):
29+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30+
if o != 0:
31+
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
32+
return 0
33+
34+
def ArgMinOptionsStart(builder): builder.StartObject(1)
35+
def ArgMinOptionsAddOutputType(builder, outputType): builder.PrependInt8Slot(0, outputType, 0)
36+
def ArgMinOptionsEnd(builder): return builder.EndObject()

tflite/BatchMatMulOptions.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class BatchMatMulOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsBatchMatMulOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = BatchMatMulOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def BatchMatMulOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# BatchMatMulOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
# BatchMatMulOptions
28+
def AdjX(self):
29+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30+
if o != 0:
31+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
32+
return False
33+
34+
# BatchMatMulOptions
35+
def AdjY(self):
36+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
37+
if o != 0:
38+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
39+
return False
40+
41+
# BatchMatMulOptions
42+
def AsymmetricQuantizeInputs(self):
43+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
44+
if o != 0:
45+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
46+
return False
47+
48+
def BatchMatMulOptionsStart(builder): builder.StartObject(3)
49+
def BatchMatMulOptionsAddAdjX(builder, adjX): builder.PrependBoolSlot(0, adjX, 0)
50+
def BatchMatMulOptionsAddAdjY(builder, adjY): builder.PrependBoolSlot(1, adjY, 0)
51+
def BatchMatMulOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): builder.PrependBoolSlot(2, asymmetricQuantizeInputs, 0)
52+
def BatchMatMulOptionsEnd(builder): return builder.EndObject()

tflite/BatchToSpaceNDOptions.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class BatchToSpaceNDOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsBatchToSpaceNDOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = BatchToSpaceNDOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def BatchToSpaceNDOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# BatchToSpaceNDOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
def BatchToSpaceNDOptionsStart(builder): builder.StartObject(0)
28+
def BatchToSpaceNDOptionsEnd(builder): return builder.EndObject()
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# automatically generated by the FlatBuffers compiler, do not modify
2+
3+
# namespace: tflite
4+
5+
import flatbuffers
6+
from flatbuffers.compat import import_numpy
7+
np = import_numpy()
8+
9+
class BidirectionalSequenceLSTMOptions(object):
10+
__slots__ = ['_tab']
11+
12+
@classmethod
13+
def GetRootAsBidirectionalSequenceLSTMOptions(cls, buf, offset):
14+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
15+
x = BidirectionalSequenceLSTMOptions()
16+
x.Init(buf, n + offset)
17+
return x
18+
19+
@classmethod
20+
def BidirectionalSequenceLSTMOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
21+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
22+
23+
# BidirectionalSequenceLSTMOptions
24+
def Init(self, buf, pos):
25+
self._tab = flatbuffers.table.Table(buf, pos)
26+
27+
# BidirectionalSequenceLSTMOptions
28+
def FusedActivationFunction(self):
29+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
30+
if o != 0:
31+
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
32+
return 0
33+
34+
# BidirectionalSequenceLSTMOptions
35+
def CellClip(self):
36+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
37+
if o != 0:
38+
return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
39+
return 0.0
40+
41+
# BidirectionalSequenceLSTMOptions
42+
def ProjClip(self):
43+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
44+
if o != 0:
45+
return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
46+
return 0.0
47+
48+
# BidirectionalSequenceLSTMOptions
49+
def MergeOutputs(self):
50+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
51+
if o != 0:
52+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
53+
return False
54+
55+
# BidirectionalSequenceLSTMOptions
56+
def TimeMajor(self):
57+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
58+
if o != 0:
59+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
60+
return True
61+
62+
# BidirectionalSequenceLSTMOptions
63+
def AsymmetricQuantizeInputs(self):
64+
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
65+
if o != 0:
66+
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
67+
return False
68+
69+
def BidirectionalSequenceLSTMOptionsStart(builder): builder.StartObject(6)
70+
def BidirectionalSequenceLSTMOptionsAddFusedActivationFunction(builder, fusedActivationFunction): builder.PrependInt8Slot(0, fusedActivationFunction, 0)
71+
def BidirectionalSequenceLSTMOptionsAddCellClip(builder, cellClip): builder.PrependFloat32Slot(1, cellClip, 0.0)
72+
def BidirectionalSequenceLSTMOptionsAddProjClip(builder, projClip): builder.PrependFloat32Slot(2, projClip, 0.0)
73+
def BidirectionalSequenceLSTMOptionsAddMergeOutputs(builder, mergeOutputs): builder.PrependBoolSlot(3, mergeOutputs, 0)
74+
def BidirectionalSequenceLSTMOptionsAddTimeMajor(builder, timeMajor): builder.PrependBoolSlot(4, timeMajor, 1)
75+
def BidirectionalSequenceLSTMOptionsAddAsymmetricQuantizeInputs(builder, asymmetricQuantizeInputs): builder.PrependBoolSlot(5, asymmetricQuantizeInputs, 0)
76+
def BidirectionalSequenceLSTMOptionsEnd(builder): return builder.EndObject()

0 commit comments

Comments
 (0)