From 87647b7bf1ee89b20aa87768ec8c82f329082db0 Mon Sep 17 00:00:00 2001 From: Benjamin Klimczak Date: Mon, 14 Aug 2023 14:17:45 +0100 Subject: MLIA-881 Update compatible operators for Cortex-A Update the compatibility information of the backend for ArmNN TensorFlow Lite Delegate (classic) to version 23.05. Change-Id: I84693842d1a883f7083a6faf7d5ddcd5ecc34e5d Signed-off-by: Benjamin Klimczak --- README.md | 12 +- src/mlia/backend/armnn_tflite_delegate/__init__.py | 2 +- src/mlia/backend/armnn_tflite_delegate/compat.py | 357 +-------------------- .../backend/armnn_tflite_delegate/ops/__init__.py | 3 + .../backend/armnn_tflite_delegate/ops/v22_08.py | 180 +++++++++++ .../backend/armnn_tflite_delegate/ops/v22_11.py | 181 +++++++++++ .../backend/armnn_tflite_delegate/ops/v23_05.py | 125 ++++++++ src/mlia/resources/target_profiles/cortex-a.toml | 2 +- tests/test_backend_armnn_tflite_delegate_compat.py | 21 ++ tests/test_target_cortex_a_data_analysis.py | 2 +- tests/test_target_cortex_a_operators.py | 17 - 11 files changed, 531 insertions(+), 371 deletions(-) create mode 100644 src/mlia/backend/armnn_tflite_delegate/ops/__init__.py create mode 100644 src/mlia/backend/armnn_tflite_delegate/ops/v22_08.py create mode 100644 src/mlia/backend/armnn_tflite_delegate/ops/v22_11.py create mode 100644 src/mlia/backend/armnn_tflite_delegate/ops/v23_05.py create mode 100644 tests/test_backend_armnn_tflite_delegate_compat.py diff --git a/README.md b/README.md index d12f863..7c9209a 100644 --- a/README.md +++ b/README.md @@ -237,7 +237,7 @@ Ethos-U is supported by these backends: ## Cortex-A The profile *cortex-a* can be used to get the information about supported -operators for Cortex-A CPUs when using the Arm NN TensorFlow Lite delegate. +operators for Cortex-A CPUs when using the Arm NN TensorFlow Lite Delegate. Please, find more details in the section for the [corresponding backend](#arm-nn-tensorflow-lite-delegate). @@ -307,7 +307,7 @@ the following table shows some compatibility information: +============================================================================= | Arm NN | | | | | TensorFlow | x86_64 | Windows 10 | Python>=3.8 | -| Lite delegate | | | | +| Lite Delegate | | | | +----------------------------------------------------------------------------- | Corstone-300 | x86_64 | Not compatible | Python>=3.8 | +----------------------------------------------------------------------------- @@ -319,15 +319,17 @@ the following table shows some compatibility information: +----------------------------------------------------------------------------+ ``` -### Arm NN TensorFlow Lite delegate +### Arm NN TensorFlow Lite Delegate This backend provides general information about the compatibility of operators -with the Arm NN TensorFlow Lite delegate for Cortex-A. It comes pre-installed +with the Arm NN TensorFlow Lite Delegate for Cortex-A. It comes pre-installed with MLIA. +For version 23.05 the classic delegate is used. + For more information see: -* [Arm NN TensorFlow Lite delegate documentation](https://arm-software.github.io/armnn/latest/delegate.xhtml) +* [Arm NN TensorFlow Lite Delegate documentation](https://arm-software.github.io/armnn/latest/delegate.xhtml) ### Corstone-300 diff --git a/src/mlia/backend/armnn_tflite_delegate/__init__.py b/src/mlia/backend/armnn_tflite_delegate/__init__.py index c190088..81b36d2 100644 --- a/src/mlia/backend/armnn_tflite_delegate/__init__.py +++ b/src/mlia/backend/armnn_tflite_delegate/__init__.py @@ -1,6 +1,6 @@ # SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. # SPDX-License-Identifier: Apache-2.0 -"""Arm NN TensorFlow Lite delegate backend module.""" +"""Arm NN TensorFlow Lite Delegate backend module.""" from typing import cast from mlia.backend.armnn_tflite_delegate.compat import ARMNN_TFLITE_DELEGATE diff --git a/src/mlia/backend/armnn_tflite_delegate/compat.py b/src/mlia/backend/armnn_tflite_delegate/compat.py index e2650be..502edae 100644 --- a/src/mlia/backend/armnn_tflite_delegate/compat.py +++ b/src/mlia/backend/armnn_tflite_delegate/compat.py @@ -3,353 +3,18 @@ """Collection of Cortex-A operator compatibility information.""" from __future__ import annotations +from mlia.backend.armnn_tflite_delegate.ops.v22_08 import OPERATORS as ops_v22_08 +from mlia.backend.armnn_tflite_delegate.ops.v22_08 import VERSION as v22_08 +from mlia.backend.armnn_tflite_delegate.ops.v22_11 import OPERATORS as ops_v22_11 +from mlia.backend.armnn_tflite_delegate.ops.v22_11 import VERSION as v22_11 +from mlia.backend.armnn_tflite_delegate.ops.v23_05 import OPERATORS as ops_v23_05 +from mlia.backend.armnn_tflite_delegate.ops.v23_05 import VERSION as v23_05 + ARMNN_TFLITE_DELEGATE: dict = { - "backend": "Arm NN TensorFlow Lite delegate", + "backend": "Arm NN TensorFlow Lite Delegate", "ops": { - "22.08": { - "builtin_ops": { - "ABS": {}, - "ADD": {}, - "ARG_MAX": {}, - "ARG_MIN": {}, - "AVERAGE_POOL_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "BATCH_TO_SPACE_ND": {}, - "CAST": {}, - "CONCATENATION": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "CONV_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "CONV_3D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "DEPTH_TO_SPACE": {}, - "DEPTHWISE_CONV_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "DEQUANTIZE": {}, - "DIV": {}, - "ELU": {}, - "EQUAL": {}, - "EXP": {}, - "EXPAND_DIMS": {}, - "FILL": {}, - "FLOOR": {}, - "FLOOR_DIV": {}, - "FULLY_CONNECTED": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "GATHER": {}, - "GATHER_ND": {}, - "GREATER": {}, - "GREATER_EQUAL": {}, - "HARD_SWISH": {}, - "L2_NORMALIZATION": {}, - "L2_POOL_2D": {}, - "LESS": {}, - "LESS_EQUAL": {}, - "LOCAL_RESPONSE_NORMALIZATION": {}, - "LOG": {}, - "LOGICAL_AND": {}, - "LOGICAL_NOT": {}, - "LOGICAL_OR": {}, - "LOGISTIC": {}, - "LOG_SOFTMAX": {}, - "LSTM": {}, - "MAX_POOL_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "MAXIMUM": {}, - "MEAN": {}, - "MINIMUM": {}, - "MIRROR_PAD": {}, - "MUL": {}, - "NEG": {}, - "NOT_EQUAL": {}, - "PACK": {}, - "PAD": {}, - "PADV2": {}, - "PRELU": {}, - "QUANTIZE": {}, - "RANK": {}, - "REDUCE_MAX": {}, - "REDUCE_MIN": {}, - "REDUCE_PROD": {}, - "RELU": {}, - "RELU_N1_TO_1": {}, - "RELU6": {}, - "RESHAPE": {}, - "RESIZE_BILINEAR": {}, - "RESIZE_NEAREST_NEIGHBOR": {}, - "RSQRT": {}, - "SHAPE": {}, - "SIN": {}, - "SOFTMAX": {}, - "SPACE_TO_BATCH_ND": {}, - "SPACE_TO_DEPTH": {}, - "SPLIT": {}, - "SPLIT_V": {}, - "SQRT": {}, - "SQUEEZE": {}, - "STRIDED_SLICE": {}, - "SUB": {}, - "SUM": {}, - "TANH": {}, - "TRANSPOSE": {}, - "TRANSPOSE_CONV": {}, - "UNIDIRECTIONAL_SEQUENCE_LSTM": {}, - "UNPACK": {}, - }, - # CUSTOM OPERATORS - "custom_ops": { - "AveragePool3D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "SIGN_BIT", - "TANH", - "NONE", - ] - }, - "MaxPool3D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "SIGN_BIT", - "TANH", - "NONE", - ] - }, - }, - }, - "22.11": { - "builtin_ops": { - "ABS": {}, - "ADD": {}, - "ARG_MAX": {}, - "ARG_MIN": {}, - "AVERAGE_POOL_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "BATCH_MATMUL": {}, - "BATCH_TO_SPACE_ND": {}, - "CAST": {}, - "CONCATENATION": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "CONV_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "CONV_3D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "DEPTH_TO_SPACE": {}, - "DEPTHWISE_CONV_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "DEQUANTIZE": {}, - "DIV": {}, - "ELU": {}, - "EQUAL": {}, - "EXP": {}, - "EXPAND_DIMS": {}, - "FILL": {}, - "FLOOR": {}, - "FLOOR_DIV": {}, - "FULLY_CONNECTED": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "GATHER": {}, - "GATHER_ND": {}, - "GREATER": {}, - "GREATER_EQUAL": {}, - "HARD_SWISH": {}, - "L2_NORMALIZATION": {}, - "L2_POOL_2D": {}, - "LESS": {}, - "LESS_EQUAL": {}, - "LOCAL_RESPONSE_NORMALIZATION": {}, - "LOG": {}, - "LOGICAL_AND": {}, - "LOGICAL_NOT": {}, - "LOGICAL_OR": {}, - "LOGISTIC": {}, - "LOG_SOFTMAX": {}, - "LSTM": {}, - "MAX_POOL_2D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "TANH", - "NONE", - ] - }, - "MAXIMUM": {}, - "MEAN": {}, - "MINIMUM": {}, - "MIRROR_PAD": {}, - "MUL": {}, - "NEG": {}, - "NOT_EQUAL": {}, - "PACK": {}, - "PAD": {}, - "PADV2": {}, - "PRELU": {}, - "QUANTIZE": {}, - "RANK": {}, - "REDUCE_MAX": {}, - "REDUCE_MIN": {}, - "REDUCE_PROD": {}, - "RELU": {}, - "RELU_N1_TO_1": {}, - "RELU6": {}, - "RESHAPE": {}, - "RESIZE_BILINEAR": {}, - "RESIZE_NEAREST_NEIGHBOR": {}, - "RSQRT": {}, - "SHAPE": {}, - "SIN": {}, - "SOFTMAX": {}, - "SPACE_TO_BATCH_ND": {}, - "SPACE_TO_DEPTH": {}, - "SPLIT": {}, - "SPLIT_V": {}, - "SQRT": {}, - "SQUEEZE": {}, - "STRIDED_SLICE": {}, - "SUB": {}, - "SUM": {}, - "TANH": {}, - "TRANSPOSE": {}, - "TRANSPOSE_CONV": {}, - "UNIDIRECTIONAL_SEQUENCE_LSTM": {}, - "UNPACK": {}, - }, - # CUSTOM OPERATORS - "custom_ops": { - "AveragePool3D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "SIGN_BIT", - "TANH", - "NONE", - ] - }, - "MaxPool3D": { - "supported_fused_activation": [ - "RELU", - "RELU6", - "RELU_N1_TO_1", - "SIGMOID", - "SIGN_BIT", - "TANH", - "NONE", - ] - }, - }, - }, + v22_08: ops_v22_08, + v22_11: ops_v22_11, + v23_05: ops_v23_05, }, } diff --git a/src/mlia/backend/armnn_tflite_delegate/ops/__init__.py b/src/mlia/backend/armnn_tflite_delegate/ops/__init__.py new file mode 100644 index 0000000..3173d8a --- /dev/null +++ b/src/mlia/backend/armnn_tflite_delegate/ops/__init__.py @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: Copyright 2023, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Operator support of the ArmNN TensorFlow Lite Delegate.""" diff --git a/src/mlia/backend/armnn_tflite_delegate/ops/v22_08.py b/src/mlia/backend/armnn_tflite_delegate/ops/v22_08.py new file mode 100644 index 0000000..c1d2a7d --- /dev/null +++ b/src/mlia/backend/armnn_tflite_delegate/ops/v22_08.py @@ -0,0 +1,180 @@ +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Collection of Cortex-A operator compatibility information.""" +from __future__ import annotations + +# pylint: disable=duplicate-code + +VERSION = "22.08" +OPERATORS = { + "builtin_ops": { + "ABS": {}, + "ADD": {}, + "ARG_MAX": {}, + "ARG_MIN": {}, + "AVERAGE_POOL_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "BATCH_TO_SPACE_ND": {}, + "CAST": {}, + "CONCATENATION": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "CONV_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "CONV_3D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "DEPTH_TO_SPACE": {}, + "DEPTHWISE_CONV_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "DEQUANTIZE": {}, + "DIV": {}, + "ELU": {}, + "EQUAL": {}, + "EXP": {}, + "EXPAND_DIMS": {}, + "FILL": {}, + "FLOOR": {}, + "FLOOR_DIV": {}, + "FULLY_CONNECTED": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "GATHER": {}, + "GATHER_ND": {}, + "GREATER": {}, + "GREATER_EQUAL": {}, + "HARD_SWISH": {}, + "L2_NORMALIZATION": {}, + "L2_POOL_2D": {}, + "LESS": {}, + "LESS_EQUAL": {}, + "LOCAL_RESPONSE_NORMALIZATION": {}, + "LOG": {}, + "LOGICAL_AND": {}, + "LOGICAL_NOT": {}, + "LOGICAL_OR": {}, + "LOGISTIC": {}, + "LOG_SOFTMAX": {}, + "LSTM": {}, + "MAX_POOL_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "MAXIMUM": {}, + "MEAN": {}, + "MINIMUM": {}, + "MIRROR_PAD": {}, + "MUL": {}, + "NEG": {}, + "NOT_EQUAL": {}, + "PACK": {}, + "PAD": {}, + "PADV2": {}, + "PRELU": {}, + "QUANTIZE": {}, + "RANK": {}, + "REDUCE_MAX": {}, + "REDUCE_MIN": {}, + "REDUCE_PROD": {}, + "RELU": {}, + "RELU_N1_TO_1": {}, + "RELU6": {}, + "RESHAPE": {}, + "RESIZE_BILINEAR": {}, + "RESIZE_NEAREST_NEIGHBOR": {}, + "RSQRT": {}, + "SHAPE": {}, + "SIN": {}, + "SOFTMAX": {}, + "SPACE_TO_BATCH_ND": {}, + "SPACE_TO_DEPTH": {}, + "SPLIT": {}, + "SPLIT_V": {}, + "SQRT": {}, + "SQUEEZE": {}, + "STRIDED_SLICE": {}, + "SUB": {}, + "SUM": {}, + "TANH": {}, + "TRANSPOSE": {}, + "TRANSPOSE_CONV": {}, + "UNIDIRECTIONAL_SEQUENCE_LSTM": {}, + "UNPACK": {}, + }, + # CUSTOM OPERATORS + "custom_ops": { + "AveragePool3D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "SIGN_BIT", + "TANH", + "NONE", + ] + }, + "MaxPool3D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "SIGN_BIT", + "TANH", + "NONE", + ] + }, + }, +} diff --git a/src/mlia/backend/armnn_tflite_delegate/ops/v22_11.py b/src/mlia/backend/armnn_tflite_delegate/ops/v22_11.py new file mode 100644 index 0000000..80c6ca2 --- /dev/null +++ b/src/mlia/backend/armnn_tflite_delegate/ops/v22_11.py @@ -0,0 +1,181 @@ +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Collection of Cortex-A operator compatibility information.""" +from __future__ import annotations + +# pylint: disable=duplicate-code + +VERSION = "22.11" +OPERATORS = { + "builtin_ops": { + "ABS": {}, + "ADD": {}, + "ARG_MAX": {}, + "ARG_MIN": {}, + "AVERAGE_POOL_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "BATCH_MATMUL": {}, + "BATCH_TO_SPACE_ND": {}, + "CAST": {}, + "CONCATENATION": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "CONV_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "CONV_3D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "DEPTH_TO_SPACE": {}, + "DEPTHWISE_CONV_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "DEQUANTIZE": {}, + "DIV": {}, + "ELU": {}, + "EQUAL": {}, + "EXP": {}, + "EXPAND_DIMS": {}, + "FILL": {}, + "FLOOR": {}, + "FLOOR_DIV": {}, + "FULLY_CONNECTED": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "GATHER": {}, + "GATHER_ND": {}, + "GREATER": {}, + "GREATER_EQUAL": {}, + "HARD_SWISH": {}, + "L2_NORMALIZATION": {}, + "L2_POOL_2D": {}, + "LESS": {}, + "LESS_EQUAL": {}, + "LOCAL_RESPONSE_NORMALIZATION": {}, + "LOG": {}, + "LOGICAL_AND": {}, + "LOGICAL_NOT": {}, + "LOGICAL_OR": {}, + "LOGISTIC": {}, + "LOG_SOFTMAX": {}, + "LSTM": {}, + "MAX_POOL_2D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", + "NONE", + ] + }, + "MAXIMUM": {}, + "MEAN": {}, + "MINIMUM": {}, + "MIRROR_PAD": {}, + "MUL": {}, + "NEG": {}, + "NOT_EQUAL": {}, + "PACK": {}, + "PAD": {}, + "PADV2": {}, + "PRELU": {}, + "QUANTIZE": {}, + "RANK": {}, + "REDUCE_MAX": {}, + "REDUCE_MIN": {}, + "REDUCE_PROD": {}, + "RELU": {}, + "RELU_N1_TO_1": {}, + "RELU6": {}, + "RESHAPE": {}, + "RESIZE_BILINEAR": {}, + "RESIZE_NEAREST_NEIGHBOR": {}, + "RSQRT": {}, + "SHAPE": {}, + "SIN": {}, + "SOFTMAX": {}, + "SPACE_TO_BATCH_ND": {}, + "SPACE_TO_DEPTH": {}, + "SPLIT": {}, + "SPLIT_V": {}, + "SQRT": {}, + "SQUEEZE": {}, + "STRIDED_SLICE": {}, + "SUB": {}, + "SUM": {}, + "TANH": {}, + "TRANSPOSE": {}, + "TRANSPOSE_CONV": {}, + "UNIDIRECTIONAL_SEQUENCE_LSTM": {}, + "UNPACK": {}, + }, + # CUSTOM OPERATORS + "custom_ops": { + "AveragePool3D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "SIGN_BIT", + "TANH", + "NONE", + ] + }, + "MaxPool3D": { + "supported_fused_activation": [ + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "SIGN_BIT", + "TANH", + "NONE", + ] + }, + }, +} diff --git a/src/mlia/backend/armnn_tflite_delegate/ops/v23_05.py b/src/mlia/backend/armnn_tflite_delegate/ops/v23_05.py new file mode 100644 index 0000000..ff41820 --- /dev/null +++ b/src/mlia/backend/armnn_tflite_delegate/ops/v23_05.py @@ -0,0 +1,125 @@ +# SPDX-FileCopyrightText: Copyright 2023, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Collection of Cortex-A operator compatibility information.""" +from __future__ import annotations + +# pylint: disable=duplicate-code + +VERSION = "23.05" +SUPPORTED_FUSED_ACTIVATION_FUNCTIONS = [ + "NONE", + "RELU", + "RELU6", + "RELU_N1_TO_1", + "SIGMOID", + "TANH", +] +OPERATORS = { + "builtin_ops": { + "ABS": {}, + "ADD": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "ARG_MAX": {}, + "ARG_MIN": {}, + "AVERAGE_POOL_2D": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "BATCH_MATMUL": {}, + "BATCH_TO_SPACE_ND": {}, + "CAST": {}, + "CEIL": {}, + "CONCATENATION": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "CONV_2D": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "CONV_3D": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "DEPTH_TO_SPACE": {}, + "DEPTHWISE_CONV_2D": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "DEQUANTIZE": {}, + "DIV": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "ELU": {}, + "EQUAL": {}, + "EXP": {}, + "EXPAND_DIMS": {}, + "FILL": {}, + "FLOOR": {}, + "FLOOR_DIV": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "FULLY_CONNECTED": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "GATHER": {}, + "GATHER_ND": {}, + "GREATER": {}, + "GREATER_EQUAL": {}, + "HARD_SWISH": {}, + "L2_NORMALIZATION": {}, + "L2_POOL_2D": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "LESS": {}, + "LESS_EQUAL": {}, + "LOCAL_RESPONSE_NORMALIZATION": {}, + "LOG": {}, + "LOGICAL_AND": {}, + "LOGICAL_NOT": {}, + "LOGICAL_OR": {}, + "LOGISTIC": {}, + "LOG_SOFTMAX": {}, + "LSTM": {}, + "MAX_POOL_2D": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "MAXIMUM": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "MEAN": {}, + "MINIMUM": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "MIRROR_PAD": {}, + "MUL": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "NEG": {}, + "NOT_EQUAL": {}, + "PACK": {}, + "PAD": {}, + "PADV2": {}, + "PRELU": {}, + "QUANTIZE": {}, + "REDUCE_MAX": {}, + "REDUCE_MIN": {}, + "REDUCE_PROD": {}, + "RELU": {}, + "RELU_N1_TO_1": {}, + "RELU6": {}, + "RESHAPE": {}, + "RESIZE_BILINEAR": {}, + "RESIZE_NEAREST_NEIGHBOR": {}, + "RSQRT": {}, + "SHAPE": {}, + "SIN": {}, + "SLICE": {}, + "SOFTMAX": {}, + "SPACE_TO_BATCH_ND": {}, + "SPACE_TO_DEPTH": {}, + "SPLIT": {}, + "SPLIT_V": {}, + "SQRT": {}, + "SQUEEZE": {}, + "STRIDED_SLICE": {}, + "SUB": {"supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS}, + "SUM": {}, + "TANH": {}, + "TRANSPOSE": {}, + "TRANSPOSE_CONV": {}, + "UNIDIRECTIONAL_SEQUENCE_LSTM": {}, + "UNPACK": {}, + }, + # CUSTOM OPERATORS + "custom_ops": { + "AveragePool3D": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + "MaxPool3D": { + "supported_fused_activation": SUPPORTED_FUSED_ACTIVATION_FUNCTIONS + }, + }, +} diff --git a/src/mlia/resources/target_profiles/cortex-a.toml b/src/mlia/resources/target_profiles/cortex-a.toml index e8c76bf..3781206 100644 --- a/src/mlia/resources/target_profiles/cortex-a.toml +++ b/src/mlia/resources/target_profiles/cortex-a.toml @@ -4,4 +4,4 @@ target="cortex-a" [backend.armnn-tflite-delegate] -version="22.11" +version="23.05" diff --git a/tests/test_backend_armnn_tflite_delegate_compat.py b/tests/test_backend_armnn_tflite_delegate_compat.py new file mode 100644 index 0000000..658e707 --- /dev/null +++ b/tests/test_backend_armnn_tflite_delegate_compat.py @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright 2022-2023, Arm Limited and/or its affiliates. +# SPDX-License-Identifier: Apache-2.0 +"""Tests for ArmNN TensorFlow Lite Delegate backend.""" +from typing import cast + +from mlia.backend.armnn_tflite_delegate import compat +from mlia.nn.tensorflow.tflite_graph import TFL_OP + + +def test_compat_data() -> None: + """Make sure all data contains the necessary items.""" + builtin_tfl_ops = {op.name for op in TFL_OP} + assert "backend" in compat.ARMNN_TFLITE_DELEGATE + assert "ops" in compat.ARMNN_TFLITE_DELEGATE + + ops = cast(dict, compat.ARMNN_TFLITE_DELEGATE["ops"]) + for data in ops.values(): + assert "builtin_ops" in data + for comp in data["builtin_ops"]: + assert comp in builtin_tfl_ops + assert "custom_ops" in data diff --git a/tests/test_target_cortex_a_data_analysis.py b/tests/test_target_cortex_a_data_analysis.py index e033ef9..73d1126 100644 --- a/tests/test_target_cortex_a_data_analysis.py +++ b/tests/test_target_cortex_a_data_analysis.py @@ -47,7 +47,7 @@ BACKEND_INFO = f"{ARMNN_TFLITE_DELEGATE['backend']} {VERSION}" Operator( "CUSTOM", "somewhere else", - activation_func=TFL_ACTIVATION_FUNCTION.SIGN_BIT, + activation_func=TFL_ACTIVATION_FUNCTION.RELU6, custom_name="MaxPool3D", ), ], diff --git a/tests/test_target_cortex_a_operators.py b/tests/test_target_cortex_a_operators.py index 8bc48e6..56d6c7b 100644 --- a/tests/test_target_cortex_a_operators.py +++ b/tests/test_target_cortex_a_operators.py @@ -2,33 +2,16 @@ # SPDX-License-Identifier: Apache-2.0 """Tests for Cortex-A operator compatibility.""" from pathlib import Path -from typing import cast import pytest import tensorflow as tf -from mlia.backend.armnn_tflite_delegate import compat -from mlia.nn.tensorflow.tflite_graph import TFL_OP from mlia.nn.tensorflow.utils import convert_to_tflite from mlia.target.cortex_a.config import CortexAConfiguration from mlia.target.cortex_a.operators import CortexACompatibilityInfo from mlia.target.cortex_a.operators import get_cortex_a_compatibility_info -def test_compat_data() -> None: - """Make sure all data contains the necessary items.""" - builtin_tfl_ops = {op.name for op in TFL_OP} - assert "backend" in compat.ARMNN_TFLITE_DELEGATE - assert "ops" in compat.ARMNN_TFLITE_DELEGATE - - ops = cast(dict, compat.ARMNN_TFLITE_DELEGATE["ops"]) - for data in ops.values(): - assert "builtin_ops" in data - for comp in data["builtin_ops"]: - assert comp in builtin_tfl_ops - assert "custom_ops" in data - - def check_get_cortex_a_compatibility_info( model_path: Path, expected_success: bool, -- cgit v1.2.1