Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tools/tflitefile_tool/select_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def GenerateOperatorCodes(new_builder, sample_model, used_opcodes_dic,
tflite.OperatorCode.OperatorCodeStart(new_builder)
tflite.OperatorCode.OperatorCodeAddBuiltinCode(new_builder,
operator_code.BuiltinCode())

tflite.OperatorCode.OperatorCodeAddDeprecatedBuiltinCode(new_builder,
operator_code.DeprecatedBuiltinCode())
new_operator_code_string = operator_code.CustomCode()
if new_operator_code_string in new_operator_code_string_list:
tflite.OperatorCode.OperatorCodeAddCustomCode(
Expand Down Expand Up @@ -987,6 +988,22 @@ def GenerateBuiltinOption(new_builder, selected_builtin_option, builtin_option_t
new_builder, used_subgraphs_dic[while_option.CondSubgraphIndex()])
return tflite.WhileOptions.WhileOptionsEnd(new_builder)

# BatchMatMulOptions
import tflite.BatchMatMulOptions
if builtin_option_type == tflite.BuiltinOptions.BuiltinOptions().BatchMatMulOptions:

batchmatmul_option = tflite.BatchMatMulOptions.BatchMatMulOptions()
batchmatmul_option.Init(selected_builtin_option.Bytes,
selected_builtin_option.Pos)

tflite.BatchMatMulOptions.BatchMatMulOptionsStart(new_builder)
tflite.BatchMatMulOptions.BatchMatMulOptionsAddAdjX(new_builder, batchmatmul_option.AdjX())
tflite.BatchMatMulOptions.BatchMatMulOptionsAddAdjY(new_builder, batchmatmul_option.AdjY())
tflite.BatchMatMulOptions.BatchMatMulOptionsAddAsymmetricQuantizeInputs(new_builder, batchmatmul_option.AsymmetricQuantizeInputs())

return tflite.BatchMatMulOptions.BatchMatMulOptionsEnd(new_builder)


# Cannot handle builtin option type yet
print("Cannot handle BuiltinOptions {} yet. See BuiltinOptions.py for op name".format(
builtin_option_type))
Expand Down
21 changes: 17 additions & 4 deletions tools/tflitefile_tool/tflite/AbsOptions.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: onert_tflite
# namespace: tflite

import flatbuffers

from flatbuffers.compat import import_numpy
np = import_numpy()

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

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

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

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


def AbsOptionsStart(builder):
builder.StartObject(0)

def Start(builder):
AbsOptionsStart(builder)

def AbsOptionsEnd(builder):
return builder.EndObject()

def End(builder):
return AbsOptionsEnd(builder)
3 changes: 1 addition & 2 deletions tools/tflitefile_tool/tflite/ActivationFunctionType.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: onert_tflite

# namespace: tflite

class ActivationFunctionType(object):
NONE = 0
Expand Down
21 changes: 17 additions & 4 deletions tools/tflitefile_tool/tflite/AddNOptions.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: onert_tflite
# namespace: tflite

import flatbuffers

from flatbuffers.compat import import_numpy
np = import_numpy()

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

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

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

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


def AddNOptionsStart(builder):
builder.StartObject(0)

def Start(builder):
AddNOptionsStart(builder)

def AddNOptionsEnd(builder):
return builder.EndObject()

def End(builder):
return AddNOptionsEnd(builder)
36 changes: 32 additions & 4 deletions tools/tflitefile_tool/tflite/AddOptions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: onert_tflite
# namespace: tflite

import flatbuffers

from flatbuffers.compat import import_numpy
np = import_numpy()

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

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

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

# AddOptions
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
Expand All @@ -26,14 +35,33 @@ def FusedActivationFunction(self):
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
return 0

# AddOptions
def PotScaleInt16(self):
o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
if o != 0:
return bool(self._tab.Get(flatbuffers.number_types.BoolFlags, o + self._tab.Pos))
return True

def AddOptionsStart(builder):
builder.StartObject(1)
builder.StartObject(2)

def Start(builder):
AddOptionsStart(builder)

def AddOptionsAddFusedActivationFunction(builder, fusedActivationFunction):
builder.PrependInt8Slot(0, fusedActivationFunction, 0)

def AddFusedActivationFunction(builder, fusedActivationFunction):
AddOptionsAddFusedActivationFunction(builder, fusedActivationFunction)

def AddOptionsAddPotScaleInt16(builder, potScaleInt16):
builder.PrependBoolSlot(1, potScaleInt16, 1)

def AddPotScaleInt16(builder, potScaleInt16):
AddOptionsAddPotScaleInt16(builder, potScaleInt16)

def AddOptionsEnd(builder):
return builder.EndObject()

def End(builder):
return AddOptionsEnd(builder)
23 changes: 19 additions & 4 deletions tools/tflitefile_tool/tflite/ArgMaxOptions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: onert_tflite
# namespace: tflite

import flatbuffers

from flatbuffers.compat import import_numpy
np = import_numpy()

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

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

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

# ArgMaxOptions
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
Expand All @@ -26,14 +35,20 @@ def OutputType(self):
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
return 0


def ArgMaxOptionsStart(builder):
builder.StartObject(1)

def Start(builder):
ArgMaxOptionsStart(builder)

def ArgMaxOptionsAddOutputType(builder, outputType):
builder.PrependInt8Slot(0, outputType, 0)

def AddOutputType(builder, outputType):
ArgMaxOptionsAddOutputType(builder, outputType)

def ArgMaxOptionsEnd(builder):
return builder.EndObject()

def End(builder):
return ArgMaxOptionsEnd(builder)
23 changes: 19 additions & 4 deletions tools/tflitefile_tool/tflite/ArgMinOptions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
# automatically generated by the FlatBuffers compiler, do not modify

# namespace: onert_tflite
# namespace: tflite

import flatbuffers

from flatbuffers.compat import import_numpy
np = import_numpy()

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

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

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

# ArgMinOptions
def Init(self, buf, pos):
self._tab = flatbuffers.table.Table(buf, pos)
Expand All @@ -26,14 +35,20 @@ def OutputType(self):
return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
return 0


def ArgMinOptionsStart(builder):
builder.StartObject(1)

def Start(builder):
ArgMinOptionsStart(builder)

def ArgMinOptionsAddOutputType(builder, outputType):
builder.PrependInt8Slot(0, outputType, 0)

def AddOutputType(builder, outputType):
ArgMinOptionsAddOutputType(builder, outputType)

def ArgMinOptionsEnd(builder):
return builder.EndObject()

def End(builder):
return ArgMinOptionsEnd(builder)
Loading
Loading