ComputeLibrary icon indicating copy to clipboard operation
ComputeLibrary copied to clipboard

Need help with TensorFlow Model Data Extraction

Open asharma-ampere opened this issue 2 years ago • 6 comments

I want to run inference using ACL. I am using examples/graph_resnet50.cpp and examples/graph_resnet_v2_50.cpp as reference. I got models from following locations: http://download.tensorflow.org/models/resnet_v1_50_2016_08_28.tar.gz http://download.tensorflow.org/models/resnet_v2_50_2017_04_14.tar.gz

These contains .ckpt files only. To convert these using scripts/tensorflow_data_extractor.py, need to supply .meta files for both. I used TensorFlow docker 1.3.0-py3 to get it from slim models. But facing version issues. Can you share .meta files for these?

asharma-ampere avatar Jun 14 '22 17:06 asharma-ampere

Hi @asharma-ampere

The best option is to use ArmNN's ExecuteNetwork tool to run a tflite model through ACL. Please see https://github.com/ARM-software/armnn/tree/branches/armnn_22_05/tests/ExecuteNetwork

Using ExecuteNetwork you can run tflite models as shown below: LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. ./ExecuteNetwork -m ../tflite_models/mobilenet_v2_1.0_224_quant.tflite -c CpuAcc -f tflite-binary -i input -o output

You could use the -e to enable the profiler and read the performance figures.

Hope this helps.

morgolock avatar Jun 27 '22 14:06 morgolock

So there is no way to use graph_xyz examples supplied in ACL (except AlexNet{graph_alexnet.cpp} for which weights are available)?

asharma-ampere avatar Jun 28 '22 19:06 asharma-ampere

Hi @asharma-ampere

ACL does not provide a solution out of the box to go from a tensorflow model to an ACL graph example. The best way to run a tflite model through ACL is using ArmNN's ExecuteNetwork tool.

If you wish to use the ACL graph example you need to find a way to export the model's parameters from the TF file and make sure the layer's names are the same as the ones used in our graph example. The script https://github.com/ARM-software/ComputeLibrary/blob/main/scripts/tensorflow_data_extractor.py is no longer maintained because we advice using ArmNN.

Hope this helps.

morgolock avatar Jun 30 '22 09:06 morgolock

I tried armnn on AWS instance but getting Segmentation fault (core dumped) while using Bfloat16 (--bf16-turbo-mode) (Without --bf16-turbo-mode it works)

How to reproduce: $ mkdir armnn $ cd armnn $ wget https://github.com/ARM-software/armnn/releases/download/v22.05.01/ArmNN-linux-aarch64.tar.gz $ tar -xf ArmNN-linux-aarch64.tar.gz $ wget https://github.com/frogermcs/TFLite-Checker/raw/master/android/ImageClassificationTester/app/src/main/assets/mobilenet_v2_1.0_224.tflite

$ LD_LIBRARY_PATH=. ./ExecuteNetwork -m mobilenet_v2_1.0_224.tflite -c CpuAcc -f tflite-binary -i input -o MobilenetV2/Predictions/Reshape_1 --bf16-turbo-mode

Warning: No input files provided, input tensors will be filled with 0s. Info: ArmNN v29.0.0 Can't load libOpenCL.so: libOpenCL.so: cannot open shared object file: No such file or directory Can't load libGLES_mali.so: libGLES_mali.so: cannot open shared object file: No such file or directory Can't load libmali.so: libmali.so: cannot open shared object file: No such file or directory Couldn't find any OpenCL library. Info: Initialization time: 0.49 ms. Info: Network parsing time: 54.54 ms. Info: Optimization time: 9.88 ms. Segmentation fault (core dumped)

AWS CPU information (for last CPU of system): processor : 63 BogoMIPS : 2100.00 Features : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm ssbs paca pacg dcpodp svei8mm svebf16 i8mm bf16 dgh rng CPU implementer : 0x41 CPU architecture: 8 CPU variant : 0x1 CPU part : 0xd40 CPU revision : 1

asharma-ampere avatar Jul 06 '22 16:07 asharma-ampere

Hi @asharma-ampere

The problem is fixed with the following ArmNN patch: https://review.mlplatform.org/c/ml/armnn/+/7944

Hope this helps.

morgolock avatar Jul 22 '22 10:07 morgolock

Looks like official release is still v22.05.01. I will give it a try as soon as it will be available in the official release.

asharma-ampere avatar Aug 02 '22 20:08 asharma-ampere

It works on Release v22.08.

asharma-ampere avatar Sep 12 '22 21:09 asharma-ampere