From f0cb1abcab287a282a238d660089e23bd0c93c23 Mon Sep 17 00:00:00 2001 From: William Isaksson Date: Mon, 11 Sep 2023 13:00:30 +0000 Subject: MLBEDSW-8035: Update to TensorFlow 2.13 - Adds 3 ops: Bitcast, BitcastXor, RightShift Change-Id: Ia9721c69d4f3da0deba7526addb95a9a54e63adf Signed-off-by: William Isaksson --- README.md | 3 ++- ethosu/vela/operation.py | 3 +++ ethosu/vela/tflite/BitcastOptions.py | 36 +++++++++++++++++++++++++++++++++ ethosu/vela/tflite/BitwiseXorOptions.py | 36 +++++++++++++++++++++++++++++++++ ethosu/vela/tflite/BuiltinOperator.py | 3 +++ ethosu/vela/tflite/BuiltinOptions.py | 3 +++ ethosu/vela/tflite/RightShiftOptions.py | 36 +++++++++++++++++++++++++++++++++ ethosu/vela/tflite_mapping.py | 21 +++++++++++++++++++ 8 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 ethosu/vela/tflite/BitcastOptions.py create mode 100644 ethosu/vela/tflite/BitwiseXorOptions.py create mode 100644 ethosu/vela/tflite/RightShiftOptions.py diff --git a/README.md b/README.md index ce76e3b..52392c9 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,8 @@ Vela is tested by comparing the numerical behaviour of the optimised operators against that of the corresponding TensorFlow Lite reference kernels. The following list indicates which version is used for comparison: -* Vela 3.9.0 to current supports TensorFlow 2.12 +* Vela 3.10.0 to current supports TensorFlow 2.13 +* Vela 3.9.0 supports TensorFlow 2.12 * Vela 3.8.0 supports TensorFlow 2.11 * Vela 3.6.0 to 3.7.0 supports TensorFlow 2.10 * Vela 3.5.0 supports TensorFlow 2.9 diff --git a/ethosu/vela/operation.py b/ethosu/vela/operation.py index 31839c7..94d256c 100644 --- a/ethosu/vela/operation.py +++ b/ethosu/vela/operation.py @@ -334,6 +334,9 @@ class Op(Enum): UnsortedSegmentMax = OperatorInfo() UnsortedSegmentMin = OperatorInfo() UnsortedSegmentSum = OperatorInfo() + Bitcast = OperatorInfo() + BitwiseXor = OperatorInfo() + RightShift = OperatorInfo() @property def info(self): diff --git a/ethosu/vela/tflite/BitcastOptions.py b/ethosu/vela/tflite/BitcastOptions.py new file mode 100644 index 0000000..093dad7 --- /dev/null +++ b/ethosu/vela/tflite/BitcastOptions.py @@ -0,0 +1,36 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tflite + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class BitcastOptions(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAs(cls, buf, offset=0): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = BitcastOptions() + x.Init(buf, n + offset) + return x + + @classmethod + def GetRootAsBitcastOptions(cls, buf, offset=0): + """This method is deprecated. Please switch to GetRootAs.""" + return cls.GetRootAs(buf, offset) + @classmethod + def BitcastOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) + + # BitcastOptions + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + +def BitcastOptionsStart(builder): builder.StartObject(0) +def Start(builder): + return BitcastOptionsStart(builder) +def BitcastOptionsEnd(builder): return builder.EndObject() +def End(builder): + return BitcastOptionsEnd(builder) \ No newline at end of file diff --git a/ethosu/vela/tflite/BitwiseXorOptions.py b/ethosu/vela/tflite/BitwiseXorOptions.py new file mode 100644 index 0000000..4b53d10 --- /dev/null +++ b/ethosu/vela/tflite/BitwiseXorOptions.py @@ -0,0 +1,36 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tflite + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class BitwiseXorOptions(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAs(cls, buf, offset=0): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = BitwiseXorOptions() + x.Init(buf, n + offset) + return x + + @classmethod + def GetRootAsBitwiseXorOptions(cls, buf, offset=0): + """This method is deprecated. Please switch to GetRootAs.""" + return cls.GetRootAs(buf, offset) + @classmethod + def BitwiseXorOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) + + # BitwiseXorOptions + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + +def BitwiseXorOptionsStart(builder): builder.StartObject(0) +def Start(builder): + return BitwiseXorOptionsStart(builder) +def BitwiseXorOptionsEnd(builder): return builder.EndObject() +def End(builder): + return BitwiseXorOptionsEnd(builder) \ No newline at end of file diff --git a/ethosu/vela/tflite/BuiltinOperator.py b/ethosu/vela/tflite/BuiltinOperator.py index 0cce079..ec2c147 100644 --- a/ethosu/vela/tflite/BuiltinOperator.py +++ b/ethosu/vela/tflite/BuiltinOperator.py @@ -162,3 +162,6 @@ class BuiltinOperator(object): ATAN2 = 156 UNSORTED_SEGMENT_MIN = 157 SIGN = 158 + BITCAST = 159 + BITWISE_XOR = 160 + RIGHT_SHIFT = 161 diff --git a/ethosu/vela/tflite/BuiltinOptions.py b/ethosu/vela/tflite/BuiltinOptions.py index 06396b0..7c3b3da 100644 --- a/ethosu/vela/tflite/BuiltinOptions.py +++ b/ethosu/vela/tflite/BuiltinOptions.py @@ -127,3 +127,6 @@ class BuiltinOptions(object): UnsortedSegmentSumOptions = 121 ATan2Options = 122 SignOptions = 123 + BitcastOptions = 124 + BitwiseXorOptions = 125 + RightShiftOptions = 126 diff --git a/ethosu/vela/tflite/RightShiftOptions.py b/ethosu/vela/tflite/RightShiftOptions.py new file mode 100644 index 0000000..f347a60 --- /dev/null +++ b/ethosu/vela/tflite/RightShiftOptions.py @@ -0,0 +1,36 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# namespace: tflite + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class RightShiftOptions(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAs(cls, buf, offset=0): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = RightShiftOptions() + x.Init(buf, n + offset) + return x + + @classmethod + def GetRootAsRightShiftOptions(cls, buf, offset=0): + """This method is deprecated. Please switch to GetRootAs.""" + return cls.GetRootAs(buf, offset) + @classmethod + def RightShiftOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed) + + # RightShiftOptions + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + +def RightShiftOptionsStart(builder): builder.StartObject(0) +def Start(builder): + return RightShiftOptionsStart(builder) +def RightShiftOptionsEnd(builder): return builder.EndObject() +def End(builder): + return RightShiftOptionsEnd(builder) \ No newline at end of file diff --git a/ethosu/vela/tflite_mapping.py b/ethosu/vela/tflite_mapping.py index dba30c4..647430e 100644 --- a/ethosu/vela/tflite_mapping.py +++ b/ethosu/vela/tflite_mapping.py @@ -38,6 +38,8 @@ from .tflite import BatchMatMulOptions from .tflite import BatchToSpaceNDOptions from .tflite import BidirectionalSequenceLSTMOptions from .tflite import BidirectionalSequenceRNNOptions +from .tflite import BitcastOptions +from .tflite import BitwiseXorOptions from .tflite import BroadcastToOptions from .tflite import BucketizeOptions from .tflite import CallOnceOptions @@ -113,6 +115,7 @@ from .tflite import ResizeNearestNeighborOptions from .tflite import ReverseSequenceOptions from .tflite import ReverseV2Options from .tflite import Rfft2dOptions +from .tflite import RightShiftOptions from .tflite import RNNOptions from .tflite import ScatterNdOptions from .tflite import SegmentSumOptions @@ -336,6 +339,9 @@ builtin_options_map = { BuiltinOptions.UnsortedSegmentSumOptions: UnsortedSegmentSumOptions.UnsortedSegmentSumOptions, BuiltinOptions.ATan2Options: ATan2Options.ATan2Options, BuiltinOptions.SignOptions: SignOptions.SignOptions, + BuiltinOptions.BitcastOptions: BitcastOptions.BitcastOptions, + BuiltinOptions.BitwiseXorOptions: BitwiseXorOptions.BitwiseXorOptions, + BuiltinOptions.RightShiftOptions: RightShiftOptions.RightShiftOptions, } @@ -1022,6 +1028,21 @@ builtin_operator_map = { OptionsSerializer("UnsortedSegmentSumOptions"), TFLITE_NO_INDICES, ), + BuiltinOperator.BITCAST: ( + Op.Bitcast, + OptionsSerializer("BitcastOptions"), + TFLITE_NO_INDICES, + ), + BuiltinOperator.BITWISE_XOR: ( + Op.BitwiseXor, + OptionsSerializer("BitwiseXorOptions"), + TFLITE_NO_INDICES, + ), + BuiltinOperator.RIGHT_SHIFT: ( + Op.RightShift, + OptionsSerializer("RightShiftOptions"), + TFLITE_NO_INDICES, + ), BuiltinOperator.CUSTOM: (Op.Custom, CustomOptionsSerializer(), TFLITE_NO_INDICES), } -- cgit v1.2.1