diff options
author | Freddie Liardet <frederick.liardet@arm.com> | 2021-09-21 12:36:43 +0100 |
---|---|---|
committer | Freddie Liardet <frederick.liardet@arm.com> | 2021-10-18 11:13:39 +0000 |
commit | 487d390b94ee93e1d89f5066ef8ca9442ab0a590 (patch) | |
tree | 4ecd1d31ee118a6e708dbff33df12cbcb6e58908 /python/scripts/utils/tflite_helpers.py | |
parent | 841c3e9f68b1954828a9137d6780b6d021354eb7 (diff) | |
download | ComputeLibrary-487d390b94ee93e1d89f5066ef8ca9442ab0a590.tar.gz |
Add user provided JSON operator list build
Allow ACL to be built via a user provided JSON file containing operators, data types and data layouts.
Modify TFLite file to JSON file script to output data layouts.
Fix build issue with "fat_binary" and "high_priority" options.
Resolves: COMPMID-4697, COMPMID-4837
Signed-off-by: Freddie Liardet <frederick.liardet@arm.com>
Change-Id: I08d494151c98f804325707ffd922ffe216813023
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6427
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Gunes Bayir <gunes.bayir@arm.com>
Diffstat (limited to 'python/scripts/utils/tflite_helpers.py')
-rw-r--r-- | python/scripts/utils/tflite_helpers.py | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/python/scripts/utils/tflite_helpers.py b/python/scripts/utils/tflite_helpers.py index 8f8d422743..c2aeaac6a7 100644 --- a/python/scripts/utils/tflite_helpers.py +++ b/python/scripts/utils/tflite_helpers.py @@ -20,6 +20,19 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +_TFLITE_TYPECODE2ACLNAME = { + 0: "fp32", # Float32 + 1: "fp16", # Float16 + 2: "integer", # Int32 + 3: "qasymm8", # Uint8 + # 4: "Unsupported", # Int64 + # 5: "Unsupported", # String + 6: "integer", # Bool + 7: "qsymm16", # Int16 + # 8: "Unsupported", # Complex64 + 9: "qasymm8_signed", # Int8 +} + _TFLITE_TYPECODE2NAME = { 0: "Float32", 1: "Float16", @@ -182,13 +195,36 @@ _TFLITE_TO_ACL = { } +def tflite_typecode2aclname(toc): + """Stringify TFLite data-type opcodes to ACL versions + + Parameters: + ---------- + toc: int + TFLite type opcode + + Returns + ---------- + str + Stringified opcode + + Raises + ------ + ValueError + If opcode does not exist in the map + """ + if toc in _TFLITE_TYPECODE2ACLNAME: + return _TFLITE_TYPECODE2ACLNAME[toc] + else: + raise ValueError("Unknown ACL typecode %d" % toc) + def tflite_typecode2name(toc): - """Stringify TfLite data-type opcodes + """Stringify TFLite data-type opcodes Parameters: ---------- toc: int - TfLite type opcode + TFLite type opcode Returns ---------- @@ -207,12 +243,12 @@ def tflite_typecode2name(toc): def tflite_op2acl(top): - """Map TfLite operators to ComputeLibrary ones + """Map TFLite operators to ComputeLibrary ones Parameters: ---------- top: str - TfLite operator name + TFLite operator name Returns ---------- |