diff options
author | Jan Eilers <jan.eilers@arm.com> | 2021-01-29 14:18:13 +0000 |
---|---|---|
committer | Jan Eilers <jan.eilers@arm.com> | 2021-02-03 09:11:51 +0000 |
commit | 31a7c890207f80afc866f706d797267d78d05a0d (patch) | |
tree | 8b133170fbdf0d87a0a8a5b72c6eaf73fcbb2391 /delegate | |
parent | 74a3cf5755b801cf258177e8e55b4cda64a0c351 (diff) | |
download | armnn-31a7c890207f80afc866f706d797267d78d05a0d.tar.gz |
IVGCVSW-5605 Doxygen: Add the TfLite Delegate to Doxygen docu
* Moves TensorFlowLiteDelegateSupport.md to doxygen
* Renames a few .dox files to represent the structure of the documentation
* Adds sections for build and use guides
* Integrates markdown guides for the delegate into doxygen
Signed-off-by: Jan Eilers <jan.eilers@arm.com>
Change-Id: I68b7a29239be88c0617da9bdfce5323ebf26f5bc
Diffstat (limited to 'delegate')
-rw-r--r-- | delegate/BuildGuideNative.md | 89 | ||||
-rw-r--r-- | delegate/IntegrateDelegateIntoPython.md | 18 | ||||
-rw-r--r-- | delegate/README.md | 4 | ||||
-rw-r--r-- | delegate/TensorFlowLiteDelegateSupport.md | 115 |
4 files changed, 57 insertions, 169 deletions
diff --git a/delegate/BuildGuideNative.md b/delegate/BuildGuideNative.md index 0f591d1d98..6bee1576ea 100644 --- a/delegate/BuildGuideNative.md +++ b/delegate/BuildGuideNative.md @@ -1,38 +1,41 @@ -# Introduction +# Delegate build guide introduction -The ArmNN Delegate can be found within the ArmNN repository but it is a standalone piece of software. However, -it makes use of the ArmNN library. For this reason we have added two options to build the delegate. The first option -allows you to build the delegate together with the ArmNN library, the second option is a standalone build +The Arm NN Delegate can be found within the Arm NN repository but it is a standalone piece of software. However, +it makes use of the Arm NN library. For this reason we have added two options to build the delegate. The first option +allows you to build the delegate together with the Arm NN library, the second option is a standalone build of the delegate. This tutorial uses an Aarch64 machine with Ubuntu 18.04 installed that can build all components natively (no cross-compilation required). This is to keep this guide simple. -1. [Dependencies](#Dependencies) - * [Build Tensorflow for C++](#Build Tensorflow for C++) - * [Build Flatbuffers](#Build Flatbuffers) - * [Build the Arm Compute Library](#Build the Arm Compute Library) - * [Build the ArmNN Library](#Build the ArmNN Library) -2. [Build the TfLite Delegate (Stand-Alone)](#Build the TfLite Delegate (Stand-Alone)) -3. [Build the Delegate together with ArmNN](#Build the Delegate together with ArmNN) -4. [Integrate the ArmNN TfLite Delegate into your project](#Integrate the ArmNN TfLite Delegate into your project) +**Table of content:** +- [Delegate build guide introduction](#delegate-build-guide-introduction) +- [Dependencies](#dependencies) + * [Build Tensorflow for C++](#build-tensorflow-for-c--) + * [Build Flatbuffers](#build-flatbuffers) + * [Build the Arm Compute Library](#build-the-arm-compute-library) + * [Build the Arm NN Library](#build-the-arm-nn-library) +- [Build the TfLite Delegate (Stand-Alone)](#build-the-tflite-delegate--stand-alone-) +- [Build the Delegate together with Arm NN](#build-the-delegate-together-with-arm-nn) +- [Integrate the Arm NN TfLite Delegate into your project](#integrate-the-arm-nn-tflite-delegate-into-your-project) + # Dependencies Build Dependencies: - * Tensorflow and Tensorflow Lite version 2.3.1 + * Tensorflow and Tensorflow Lite. This guide uses version 2.3.1 . Other versions might work. * Flatbuffers 1.12.0 - * ArmNN 20.11 or higher + * Arm NN 20.11 or higher Required Tools: - * Git - * pip - * wget - * zip - * unzip - * cmake 3.7.0 or higher - * scons - * bazel 3.1.0 + * Git. This guide uses version 2.17.1 . Other versions might work. + * pip. This guide uses version 20.3.3 . Other versions might work. + * wget. This guide uses version 1.17.1 . Other versions might work. + * zip. This guide uses version 3.0 . Other versions might work. + * unzip. This guide uses version 6.00 . Other versions might work. + * cmake 3.7.0 or higher. This guide uses version 3.7.2 + * scons. This guide uses version 2.4.1 . Other versions might work. + * bazel. This guide uses version 3.1.0 . Other versions might work. Our first step is to build all the build dependencies I have mentioned above. We will have to create quite a few directories. To make navigation a bit easier define a base directory for the project. At this stage we can also @@ -54,7 +57,7 @@ to this guide. Depending on your operating system and architecture there might b pip3 install -U pip numpy wheel pip3 install -U keras_preprocessing --no-deps -# Bazel has a dependency on JDK +# Bazel has a dependency on JDK (The JDK version depends on the bazel version you want to build) apt-get install openjdk-11-jdk # Build Bazel wget -O bazel-3.1.0-dist.zip https://github.com/bazelbuild/bazel/releases/download/3.1.0/bazel-3.1.0-dist.zip @@ -121,16 +124,16 @@ make install ## Build the Arm Compute Library -The ArmNN library depends on the Arm Compute Library (ACL). It provides a set of functions that are optimized for -both Arm CPUs and GPUs. The Arm Compute Library is used directly by ArmNN to run machine learning workloads on +The Arm NN library depends on the Arm Compute Library (ACL). It provides a set of functions that are optimized for +both Arm CPUs and GPUs. The Arm Compute Library is used directly by Arm NN to run machine learning workloads on Arm CPUs and GPUs. -It is important to have the right version of ACL and ArmNN to make it work. Luckily, ArmNN and ACL are developed -very closely and released together. If you would like to use the ArmNN version "20.11" you can use the same "20.11" +It is important to have the right version of ACL and Arm NN to make it work. Luckily, Arm NN and ACL are developed +very closely and released together. If you would like to use the Arm NN version "20.11" you can use the same "20.11" version for ACL too. -To build the Arm Compute Library on your platform, download the Arm Compute Library and check the branch -out that contains the version you want to use and build it using `scons`. +To build the Arm Compute Library on your platform, download the Arm Compute Library and checkout the branch +that contains the version you want to use and build it using `scons`. ```bash cd $BASEDIR git clone https://review.mlplatform.org/ml/ComputeLibrary @@ -141,9 +144,9 @@ git checkout <branch_name> # e.g. branches/arm_compute_20_11 scons arch=arm64-v8a neon=1 extra_cxx_flags="-fPIC" benchmark_tests=0 validation_tests=0 ``` -## Build the ArmNN Library +## Build the Arm NN Library -After building ACL we can now continue building ArmNN. To do so, download the repository and checkout the same +After building ACL we can now continue building Arm NN. To do so, download the repository and checkout the same version as you did for ACL. Create a build directory and use cmake to build it. ```bash cd $BASEDIR @@ -158,7 +161,7 @@ make # Build the TfLite Delegate (Stand-Alone) -The delegate as well as ArmNN is built using cmake. Create a build directory as usual and build the Delegate +The delegate as well as Arm NN is built using cmake. Create a build directory as usual and build the Delegate with the additional cmake arguments shown below ```bash cd $BASEDIR/armnn/delegate && mkdir build && cd build @@ -166,15 +169,15 @@ cmake .. -DTENSORFLOW_LIB_DIR=$BASEDIR/tensorflow/bazel-bin \ # Directory wh -DTENSORFLOW_ROOT=$BASEDIR/tensorflow \ # The top directory of the tensorflow repository -DTFLITE_LIB_ROOT=$BASEDIR/tensorflow/bazel-bin \ # In our case the same as TENSORFLOW_LIB_DIR -DFLATBUFFERS_ROOT=$BASEDIR/flatbuffers-1.12.0/install \ # The install directory - -DArmnn_DIR=$BASEDIR/armnn/build \ # Directory where the ArmNN library can be found - -DARMNN_SOURCE_DIR=$BASEDIR/armnn # The top directory of the ArmNN repository. - # Required are the includes for ArmNN + -DArmnn_DIR=$BASEDIR/armnn/build \ # Directory where the Arm NN library can be found + -DARMNN_SOURCE_DIR=$BASEDIR/armnn # The top directory of the Arm NN repository. + # Required are the includes for Arm NN make ``` To ensure that the build was successful you can run the unit tests for the delegate that can be found in the build directory for the delegate. [Doctest](https://github.com/onqtam/doctest) was used to create those tests. Using test filters you can -filter out tests that your build is not configured for. In this case, because ArmNN was only built for Cpu +filter out tests that your build is not configured for. In this case, because Arm NN was only built for Cpu acceleration (CpuAcc), we filter for all test suites that have `CpuAcc` in their name. ```bash cd $BASEDIR/armnn/delegate/build @@ -186,12 +189,12 @@ If you have built for Gpu acceleration as well you might want to change your tes ``` -# Build the Delegate together with ArmNN +# Build the Delegate together with Arm NN -In the introduction it was mentioned that there is a way to integrate the delegate build into ArmNN. This is +In the introduction it was mentioned that there is a way to integrate the delegate build into Arm NN. This is pretty straight forward. The cmake arguments that were previously used for the delegate have to be added -to the ArmNN cmake arguments. Also another argument `BUILD_ARMNN_TFLITE_DELEGATE` needs to be added to -instruct ArmNN to build the delegate as well. The new commands to build ArmNN are as follows: +to the Arm NN cmake arguments. Also another argument `BUILD_ARMNN_TFLITE_DELEGATE` needs to be added to +instruct Arm NN to build the delegate as well. The new commands to build Arm NN are as follows: ```bash cd $BASEDIR git clone "https://review.mlplatform.org/ml/armnn" @@ -212,10 +215,10 @@ make The delegate library can then be found in `build/armnn/delegate`. -# Integrate the ArmNN TfLite Delegate into your project +# Integrate the Arm NN TfLite Delegate into your project The delegate can be integrated into your c++ project by creating a TfLite Interpreter and -instructing it to use the ArmNN delegate for the graph execution. This should look similiar +instructing it to use the Arm NN delegate for the graph execution. This should look similiar to the following code snippet. ```objectivec // Create TfLite Interpreter @@ -223,7 +226,7 @@ std::unique_ptr<Interpreter> armnnDelegateInterpreter; InterpreterBuilder(tfLiteModel, ::tflite::ops::builtin::BuiltinOpResolver()) (&armnnDelegateInterpreter) -// Create the ArmNN Delegate +// Create the Arm NN Delegate armnnDelegate::DelegateOptions delegateOptions(backends); std::unique_ptr<TfLiteDelegate, decltype(&armnnDelegate::TfLiteArmnnDelegateDelete)> theArmnnDelegate(armnnDelegate::TfLiteArmnnDelegateCreate(delegateOptions), diff --git a/delegate/IntegrateDelegateIntoPython.md b/delegate/IntegrateDelegateIntoPython.md index 69a5ca00e2..e8624e8f64 100644 --- a/delegate/IntegrateDelegateIntoPython.md +++ b/delegate/IntegrateDelegateIntoPython.md @@ -1,4 +1,4 @@ -# Integrate the TfLite delegate into a python script +# Integrate the TfLite delegate into TfLite using Python If you have built the TfLite delegate as a separate dynamic library then this tutorial will show you how you can integrate it in TfLite to run models using python. @@ -36,13 +36,13 @@ print(output_data) # Prepare the environment Pre-requisites: - * Dynamically build ArmNN Delegate library + * Dynamically build Arm NN Delegate library * python3 (Depends on TfLite version) * virtualenv * numpy (Depends on TfLite version) - * tflite_runtime (>=2.0, depends on ArmNN Delegate) + * tflite_runtime (>=2.0, depends on Arm NN Delegate) -If you haven't built the delegate yet then take a look at the [build guide](BuildBuideNative.md). +If you haven't built the delegate yet then take a look at the [build guide](./BuildGuideNative.md). We recommend creating a virtual environment for this tutorial. For the following code to work python3 is needed. Please also check the documentation of the TfLite version you want to use. There might be additional prerequisites for the python @@ -63,7 +63,7 @@ source myenv/bin/activate Now that the environment is active we can install additional packages we need for our example script. As you can see in the python script at the start of this page, this tutorial uses the `tflite_runtime` rather than the whole tensorflow package. The `tflite_runtime` is a package that wraps the TfLite Interpreter. Therefore it can only be used to run inferences of -TfLite models. But since ArmNN is only an inference engine itself this is a perfect match. The +TfLite models. But since Arm NN is only an inference engine itself this is a perfect match. The `tflite_runtime` is also much smaller than the whole tensorflow package and better suited to run models on mobile and embedded devices. @@ -73,7 +73,7 @@ possible. The TfLite [website](https://www.tensorflow.org/lite/guide/python) poi packages. However, that limits you to specific TfLite and Python versions. For this reason we will build the `tflite_runtime` from source. -You will have downloaded the tensorflow repository in order to build the ArmNN delegate. In there you can find further +You will have downloaded the tensorflow repository in order to build the Arm NN delegate. In there you can find further instructions on how to build the `tflite_runtime` under `tensorflow/lite/tools/pip_package/README.md`. This tutorial uses bazel to build it natively but there are scripts for cross-compilation available as well. ```bash @@ -91,7 +91,7 @@ pip install tensorflow/lite/tools/pip_package/gen/tflite_pip/python3/dist/tflite Your virtual environment is now all setup. Copy the final python script into a python file e.g. `ExternalDelegatePythonTutorial.py`. Modify the python script above and replace `<your-armnn-build-dir>` and -`<your-armnn-repo-dir>` with the directories you have set up. If you've been using the [native build guide](BuildGuideNative.md) +`<your-armnn-repo-dir>` with the directories you have set up. If you've been using the [native build guide](./BuildGuideNative.md) this will be `$BASEDIR/armnn/build` and `$BASEDIR/armnn`. Finally, execute the script: @@ -109,13 +109,13 @@ INFO: TfLiteArmnnDelegate: Created TfLite ArmNN delegate. Info: Shutdown time: 0.28 ms ``` -For more details on what kind of options you can pass to the armnn delegate please check +For more details on what kind of options you can pass to the Arm NN delegate please check [armnn_delegate_adaptor.cpp](src/armnn_external_delegate.cpp). You can also test the functionality of the external delegate adaptor by running some unit tests: ```bash pip install pytest cd armnn/delegate/python/test -# You can deselect tests that require backends that your hardware doesn't support using markers e.g. `-m "not GpuAccTest` +# You can deselect tests that require backends that your hardware doesn't support using markers e.g. -m "not GpuAccTest" pytest --delegate-dir="<your-armnn-build-dir>/armnn/delegate/libarmnnDelegate.so" -m "not GpuAccTest" ``` diff --git a/delegate/README.md b/delegate/README.md index 7430f19c00..ee9f682850 100644 --- a/delegate/README.md +++ b/delegate/README.md @@ -3,5 +3,5 @@ 'armnnDelegate' is a library for accelerating certain TensorFlow Lite operators on Arm hardware by providing the TensorFlow Lite interpreter with an alternative implementation of the operators via its delegation mechanism. -For more information about the TensorFlow Lite operators that are supported, -see [TensorFlowLiteDelegateSupport.md](./TensorFlowLiteDelegateSupport.md). +For more information, like a list of supported operators, please visit our doxygen documentation that can be found +in the [wiki section](https://github.com/ARM-software/armnn/wiki/Documentation) of our github repository. diff --git a/delegate/TensorFlowLiteDelegateSupport.md b/delegate/TensorFlowLiteDelegateSupport.md deleted file mode 100644 index a5d4faf3ef..0000000000 --- a/delegate/TensorFlowLiteDelegateSupport.md +++ /dev/null @@ -1,115 +0,0 @@ -# TensorFlow Lite operators that the Arm NN TensorFlow Lite Delegate supports - -This reference guide provides a list of TensorFlow Lite operators the Arm NN SDK currently supports. - -## Fully supported - -The Arm NN SDK TensorFlow Lite delegate currently supports the following operators: - -* ABS - -* ADD - -* ARGMAX - -* ARGMIN - -* AVERAGE_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE - -* CONCATENATION, Supported Fused Activation: RELU , RELU6 , TANH, NONE - -* CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE - -* DEPTH_TO_SPACE - -* DEPTHWISE_CONV_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE - -* DEQUANTIZE - -* DIV - -* EQUAL - -* ELU - -* EXP - -* FULLY_CONNECTED, Supported Fused Activation: RELU , RELU6 , TANH, NONE - -* GATHER - -* GREATER - -* GREATER_OR_EQUAL - -* HARD_SWISH - -* LESS - -* LESS_OR_EQUAL - -* LOCAL_RESPONSE_NORMALIZATION - -* LOGICAL_AND - -* LOGICAL_NOT - -* LOGICAL_OR - -* LOGISTIC - -* LOG_SOFTMAX - -* L2_NORMALIZATION - -* L2_POOL_2D - -* MAXIMUM - -* MAX_POOL_2D, Supported Fused Activation: RELU , RELU6 , TANH, NONE - -* MEAN - -* MINIMUM - -* MUL - -* NEG - -* NOT_EQUAL - -* PAD - -* QUANTIZE - -* RESHAPE - -* RESIZE_BILINEAR - -* RESIZE_NEAREST_NEIGHBOR - -* RELU - -* RELU6 - -* RSQRT - -* SOFTMAX - -* SPACE_TO_DEPTH - -* SPLIT - -* SPLIT_V - -* SQRT - -* SUB - -* TANH - -* TRANSPOSE - -* TRANSPOSE_CONV - -More machine learning operators will be supported in future releases. |