aboutsummaryrefslogtreecommitdiff
path: root/23.05/md__build_guide_android_n_d_k.xhtml
blob: 9da1ad92ed7c0e271853865188a51a8a0ada082b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
<!-- Copyright (c) 2020 ARM Limited. -->
<!--                                 -->
<!-- SPDX-License-Identifier: MIT    -->
<!--                                 -->
<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="robots" content="NOINDEX, NOFOLLOW" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>ArmNN: How to use the Android NDK to build Arm NN</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <img alt="ArmNN" src="Arm_NN_horizontal_blue.png" style="max-width: 10rem; margin-top: .5rem; margin-left 10px"/>
  <td style="padding-left: 0.5em;">
   <div id="projectname">
   &#160;<span id="projectnumber">23.05</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('md__build_guide_android_n_d_k.xhtml',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">How to use the Android NDK to build Arm NN </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#initial-setup">Initial Setup</a></li>
<li><a href="#download-the-android-ndk-and-make-a-standalone-toolchain">Download the Android NDK and make a standalone toolchain</a></li>
<li><a href="#install-cmake">Install Cmake</a></li>
<li><a href="#build-flatbuffers">Build Flatbuffers</a></li>
<li><a href="#download-arm-nn">Download Arm NN</a></li>
<li><a href="#get-and-build-tflite">Get And Build TFLite</a></li>
<li><a href="#build-arm-compute-library">Build Arm Compute Library</a></li>
<li><a href="#build-arm-nn">Build Arm NN</a></li>
<li><a href="#build-standalone-sample-dynamic-backend">Build Standalone Sample Dynamic Backend</a></li>
<li><a href="#run-the-arm-nn-unit-tests-on-an-android-device">Run the Arm NN unit tests on an Android device</a></li>
</ul>
<h1>Introduction</h1>
<p>These are step-by-step instructions for using the Android NDK to build Arm NN. They have been tested on a clean installation of Ubuntu 18.04 and 20.04, and should also work with other OS versions. The instructions show how to build the Arm NN core library and its dependencies.</p>
<p>For ease of use there is a shell script version of this guide located in the scripts directory called <a href="scripts/build_android_ndk_guide.sh">build_android_ndk_guide.sh</a>. Run the script with a -h flag to see the command line parameters.</p>
<p>The shell script version of this guide (build_android_ndk_guide.sh) also provides user the option to use the Arm NN and ComputeLibrary available in your BASE_DIR, instead of downloading a new version. BASE_DIR is path to the script file, which is armnn/scripts/.</p>
<h1>Initial Setup</h1>
<p>First, we need to specify the Android version and the directories you want to build Arm NN in and to install some applications required to build Arm NN and its dependencies.</p>
<div class="fragment"><div class="line">export ANDROID_API=30</div>
<div class="line">export WORKING_DIR=$HOME/armnn-devenv</div>
<div class="line">export NDK_DIR=$WORKING_DIR/android-ndk-r25</div>
<div class="line">export NDK_TOOLCHAIN_ROOT=$NDK_DIR/toolchains/llvm/prebuilt/linux-x86_64</div>
<div class="line">export PATH=$NDK_TOOLCHAIN_ROOT/bin/:$PATH</div>
</div><!-- fragment --><p>You may want to append the above export variables commands to your <code>~/.bashrc</code> (or <code>~/.bash_profile</code> in macOS).</p>
<p>The ANDROID_API variable should be set to the Android API version number you are using. For example, "30" for Android R. The WORKING_DIR can be any directory you have write permissions to.</p>
<h2>Required Applications</h2>
<p>Git is required to obtain Arm NN. If this has not been already installed then install it using: </p><div class="fragment"><div class="line">sudo apt install git</div>
</div><!-- fragment --><p>Arm Compute Library requires SCons. If this has not been already installed then install it using: </p><div class="fragment"><div class="line">sudo apt install scons</div>
</div><!-- fragment --><p>CMake is required to build Arm NN and its dependencies. If this has not been already installed then install it using: </p><div class="fragment"><div class="line">sudo apt install cmake</div>
</div><!-- fragment --><h1>Download the Android NDK and make a standalone toolchain</h1>
<p>Download the Android NDK from <a href="https://developer.android.com/ndk/downloads/index.html">the official website</a>: </p><div class="fragment"><div class="line">mkdir -p $WORKING_DIR</div>
<div class="line">cd $WORKING_DIR</div>
<div class="line"># For Mac OS, change the NDK download link accordingly.</div>
<div class="line">wget https://dl.google.com/android/repository/android-ndk-r25-linux.zip</div>
<div class="line">unzip android-ndk-r25-linux.zip</div>
</div><!-- fragment --><p>With Android NDK-25, you no longer need to use the make_standalone_toolchain script to create a toolchain for a specific version of Android. Android's current preference is for you to just specify the architecture and operating system while setting the compiler and just use the ndk directory.</p>
<h1>Install Cmake</h1>
<p>Cmake 3.19rc3 or later is required to build Arm NN. If you are using Ubuntu 20.04 the command given in <a href="#initial-setup">Initial Setup</a> should install a usable version. If you're using Ubuntu 18.04 you may need to compile cmake yourself.</p>
<div class="fragment"><div class="line">cd $WORKING_DIR</div>
<div class="line">sudo apt-get install libssl-dev</div>
<div class="line">wget https://github.com/Kitware/CMake/releases/download/v3.19.0-rc3/cmake-3.19.0-rc3.tar.gz</div>
<div class="line">tar -zxvf cmake-3.19.0-rc3.tar.gz</div>
<div class="line">cd cmake-3.19.0-rc3</div>
<div class="line">./bootstrap --prefix=$WORKING_DIR/cmake/install</div>
<div class="line">make all install</div>
<div class="line">cd..</div>
</div><!-- fragment --><h1>Build Flatbuffers</h1>
<p>Download Flatbuffers: </p><div class="fragment"><div class="line">cd $WORKING_DIR</div>
<div class="line">wget https://github.com/google/flatbuffers/archive/v2.0.6.tar.gz</div>
<div class="line">tar xf v2.0.6.tar.gz</div>
</div><!-- fragment --><p>Build Flatbuffers for x86: </p><div class="fragment"><div class="line">cd $WORKING_DIR/flatbuffers-2.0.6</div>
<div class="line"> </div>
<div class="line">rm -f CMakeCache.txt</div>
<div class="line"> </div>
<div class="line">rm -rf build-x86</div>
<div class="line">mkdir build-x86</div>
<div class="line">cd build-x86</div>
<div class="line"> </div>
<div class="line">rm -rf $WORKING_DIR/flatbuffers-x86</div>
<div class="line">mkdir $WORKING_DIR/flatbuffers-x86</div>
<div class="line"> </div>
<div class="line">CXXFLAGS=&quot;-fPIC&quot; $CMAKE .. \</div>
<div class="line">    -DFLATBUFFERS_BUILD_FLATC=1 \</div>
<div class="line">    -DCMAKE_INSTALL_PREFIX:PATH=$WORKING_DIR/flatbuffers-x86</div>
<div class="line"> </div>
<div class="line">make all install -j16</div>
</div><!-- fragment --><p>Note: -fPIC is added to allow users to use the libraries in shared objects.</p>
<p>Build Flatbuffers for Android: </p><div class="fragment"><div class="line">cd $WORKING_DIR/flatbuffers-2.0.6</div>
<div class="line"> </div>
<div class="line">rm -f CMakeCache.txt</div>
<div class="line"> </div>
<div class="line">rm -rf build-android</div>
<div class="line">mkdir build-android</div>
<div class="line">cd build-android</div>
<div class="line"> </div>
<div class="line">rm -rf $WORKING_DIR/flatbuffers-android</div>
<div class="line">mkdir $WORKING_DIR/flatbuffers-android</div>
<div class="line"> </div>
<div class="line">CC=/usr/bin/aarch64-linux-gnu-gcc CXX=/usr/bin/aarch64-linux-gnu-g++ \</div>
<div class="line">CXXFLAGS=&quot;-fPIC&quot; \</div>
<div class="line">cmake .. \</div>
<div class="line">    -DCMAKE_ANDROID_NDK=$NDK_DIR \</div>
<div class="line">    -DCMAKE_SYSTEM_NAME=Android \</div>
<div class="line">    -DCMAKE_SYSTEM_VERSION=$ANDROID_API \</div>
<div class="line">    -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \</div>
<div class="line">    -DCMAKE_CXX_FLAGS=--std=c++14 \</div>
<div class="line">    -DFLATBUFFERS_BUILD_FLATC=OFF \</div>
<div class="line">    -DCMAKE_BUILD_TYPE=Release \</div>
<div class="line">    -DFLATBUFFERS_BUILD_TESTS=OFF \</div>
<div class="line">    -DCMAKE_INSTALL_PREFIX=$WORKING_DIR/flatbuffers-android</div>
<div class="line"> </div>
<div class="line">make all install -j16</div>
</div><!-- fragment --><h1>Download Arm NN</h1>
<p>Clone Arm NN:</p>
<div class="fragment"><div class="line">cd $WORKING_DIR</div>
<div class="line">git clone https://github.com/ARM-software/armnn.git</div>
</div><!-- fragment --><p>Checkout the Arm NN branch: </p><div class="fragment"><div class="line">cd armnn</div>
<div class="line">git checkout &lt;branch_name&gt;</div>
<div class="line">git pull</div>
</div><!-- fragment --><p>For example, if you want to check out the 23.02 release branch: </p><div class="fragment"><div class="line">cd armnn</div>
<div class="line">git checkout branches/armnn_23_02</div>
<div class="line">git pull</div>
</div><!-- fragment --><h1>Get And Build TFLite</h1>
<p>This optional step is only required if you intend to build the TFLite delegate or parser for Arm NN.</p>
<p>First clone Tensorflow manually and check out the version Arm NN was tested with: </p><div class="fragment"><div class="line">cd $WORKING_DIR</div>
<div class="line">git clone https://github.com/tensorflow/tensorflow.git</div>
<div class="line">cd tensorflow</div>
<div class="line">git fetch &amp;&amp; git checkout &quot;6f692f73cb2043b4a0b0446539cd8c15b3dd9220&quot;</div>
</div><!-- fragment --><p>Or use the script that Arm NN provides: </p><div class="fragment"><div class="line">git fetch &amp;&amp; git checkout $(../armnn/scripts/get_tensorflow.sh -p)</div>
</div><!-- fragment --><p>Next, set variable TFLITE_ROOT_DIR and build Tensorflow Lite: </p><div class="fragment"><div class="line">export TFLITE_ROOT_DIR=$WORKING_DIR/tensorflow/tensorflow/lite</div>
<div class="line">cd $WORKING_DIR</div>
<div class="line">mkdir -p tflite-out/android</div>
<div class="line">cd tflite-out/android</div>
<div class="line"> </div>
<div class="line">CMARGS=&quot;-DTFLITE_ENABLE_XNNPACK=OFF \</div>
<div class="line">        -DFLATBUFFERS_BUILD_FLATC=OFF \</div>
<div class="line">        -DBUILD_SHARED_LIBS=OFF \</div>
<div class="line">        -DBUILD_TESTING=OFF&quot;</div>
<div class="line"> </div>
<div class="line">CMARGS=&quot;$CMARGS -DCMAKE_TOOLCHAIN_FILE=$NDK_DIR/build/cmake/android.toolchain.cmake \</div>
<div class="line">    -DANDROID_ABI=arm64-v8a \</div>
<div class="line">    -DANDROID_PLATFORM=$ANDROID_API&quot;</div>
<div class="line"> </div>
<div class="line">cmake $CMARGS $TFLITE_ROOT_DIR</div>
<div class="line"> </div>
<div class="line">cd $WORKING_DIR</div>
<div class="line">cmake --build tflite-out/android -j 16</div>
</div><!-- fragment --><p>Now generate the Tensorflow Lite Schema for the TFLite parser: </p><div class="fragment"><div class="line">cd $WORKING_DIR</div>
<div class="line">mkdir -p $WORKING_DIR/tflite-out/tensorflow/tensorflow/lite/schema</div>
<div class="line"> </div>
<div class="line">SCHEMA_LOCATION=$WORKING_DIR/tensorflow/tensorflow/lite/schema/schema.fbs</div>
<div class="line">cp $SCHEMA_LOCATION $WORKING_DIR/tflite-out/tensorflow/tensorflow/lite/schema</div>
<div class="line"> </div>
<div class="line">cd $WORKING_DIR/tflite-out/tensorflow/tensorflow/lite/schema</div>
<div class="line">$WORKING_DIR/flatbuffers-x86/bin/flatc -c --gen-object-api --reflect-types --reflect-names schema.fbs</div>
</div><!-- fragment --><h1>Build Arm Compute Library</h1>
<p>Clone Arm Compute Library:</p>
<div class="fragment"><div class="line">cd $WORKING_DIR</div>
<div class="line">git clone https://github.com/ARM-software/ComputeLibrary.git</div>
</div><!-- fragment --><p>Checkout Arm Compute Library release tag: </p><div class="fragment"><div class="line">cd ComputeLibrary</div>
<div class="line">git checkout &lt;tag_name&gt;</div>
</div><!-- fragment --><p>For example, if you want to check out the 23.02 release tag: </p><div class="fragment"><div class="line">cd ComputeLibrary</div>
<div class="line">git checkout v23.02</div>
</div><!-- fragment --><p>Arm NN and Arm Compute Library are developed closely together. To use a particular version of Arm NN you will need a compatible version of ACL. Arm NN provides a script that downloads the version of Arm Compute Library that Arm NN was tested with: </p><div class="fragment"><div class="line">git checkout $(../armnn/scripts/get_compute_library.sh -p) </div>
</div><!-- fragment --><p>Build the Arm Compute Library: </p><div class="fragment"><div class="line">scons arch=arm64-v8a os=android toolchain_prefix=llvm- compiler_prefix=aarch64-linux-android$ANDROID_API- \</div>
<div class="line">    neon=1 opencl=1 embed_kernels=1 extra_cxx_flags=&quot;-fPIC&quot; \</div>
<div class="line">    benchmark_tests=0 validation_tests=0 -j16</div>
</div><!-- fragment --><h1>Build Arm NN</h1>
<p>Build Arm NN:</p>
<div class="fragment"><div class="line">mkdir $WORKING_DIR/armnn/build</div>
<div class="line">cd $WORKING_DIR/armnn/build</div>
<div class="line">CXX=aarch64-linux-android$ANDROID_API-clang++ \</div>
<div class="line">CC=aarch64-linux-android$ANDROID_API-clang \</div>
<div class="line">CXX_FLAGS=&quot;-fPIE -fPIC&quot; \</div>
<div class="line">cmake .. \</div>
<div class="line">    -DCMAKE_BUILD_TYPE=Release \</div>
<div class="line">    -DCMAKE_ANDROID_NDK=$NDK_DIR \</div>
<div class="line">    -DNDK_VERSION=r25 \</div>
<div class="line">    -DCMAKE_SYSTEM_NAME=Android \</div>
<div class="line">    -DCMAKE_SYSTEM_VERSION=$ANDROID_API \</div>
<div class="line">    -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \</div>
<div class="line">    -DCMAKE_SYSROOT=$WORKING_DIR/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot \</div>
<div class="line">    -DARMCOMPUTE_ROOT=$WORKING_DIR/ComputeLibrary \</div>
<div class="line">    -DARMCOMPUTE_BUILD_DIR=$WORKING_DIR/ComputeLibrary/build \</div>
<div class="line">    -DARMCOMPUTENEON=1 -DARMCOMPUTECL=1 -DARMNNREF=1 \</div>
<div class="line">    -DFLATBUFFERS_INCLUDE_PATH=$WORKING_DIR/flatbuffers-x86/include \</div>
<div class="line">    -DFLATBUFFERS_ROOT=$WORKING_DIR/flatbuffers-android \</div>
<div class="line">    -DFLATC_DIR=$WORKING_DIR/flatbuffers-x86 \</div>
<div class="line">    -DBUILD_UNIT_TESTS=1 \</div>
<div class="line">    -DBUILD_TESTS=1 \</div>
<div class="line">    -fexception \</div>
</div><!-- fragment --><p>To include the Arm NN TFLite delegate add these arguments to the above list:</p>
<div class="fragment"><div class="line">-DBUILD_ARMNN_TFLITE_DELEGATE=1 \</div>
<div class="line">-DTENSORFLOW_ROOT=$WORKING_DIR/tensorflow \</div>
<div class="line">-DTFLITE_LIB_ROOT=$WORKING_DIR/tflite-out/android \</div>
<div class="line">-DTFLITE_ROOT_DIR=$WORKING_DIR/tensorflow/tensorflow/lite \</div>
</div><!-- fragment --><p>To include the Arm NN TFLite Parser add these arguments to the above list:</p>
<div class="fragment"><div class="line">-DBUILD_TF_LITE_PARSER=1 \</div>
<div class="line">-DTF_LITE_GENERATED_PATH=$WORKING_DIR/tflite-out/tensorflow/tensorflow/lite/schema \</div>
<div class="line">-DTENSORFLOW_ROOT=$WORKING_DIR/tensorflow \</div>
<div class="line">-DTFLITE_LIB_ROOT=$WORKING_DIR/tflite-out/android \</div>
</div><!-- fragment --><p>To include standalone sample dynamic backend tests, add these arguments to enable the tests and the dynamic backend path to the CMake command:</p>
<div class="fragment"><div class="line">    -DSAMPLE_DYNAMIC_BACKEND=1 \</div>
<div class="line">    -DDYNAMIC_BACKEND_PATHS=$SAMPLE_DYNAMIC_BACKEND_PATH</div>
<div class="line"># Where $SAMPLE_DYNAMIC_BACKEND_PATH is the path where libArm_SampleDynamic_backend.so library file is pushed</div>
</div><!-- fragment --><ul>
<li>Run the build <div class="fragment"><div class="line">make -j16</div>
</div><!-- fragment --></li>
</ul>
<h1>Build Standalone Sample Dynamic Backend</h1>
<p>This step is optional. The sample dynamic backend is located in armnn/src/dynamic/sample </p><div class="fragment"><div class="line">mkdir build</div>
<div class="line">cd build</div>
</div><!-- fragment --><ul>
<li>Use CMake to configure the build environment, update the following script and run it from the armnn/src/dynamic/sample/build directory to set up the Arm NN build: <div class="fragment"><div class="line">#!/bin/bash</div>
<div class="line">CXX=aarch64-linux-android$ANDROID_API-clang++ \</div>
<div class="line">CC=aarch64-linux-android$ANDROID_API-clang \</div>
<div class="line">CXX_FLAGS=&quot;-fPIE -fPIC&quot; \</div>
<div class="line">cmake \</div>
<div class="line">    -DCMAKE_C_COMPILER_WORKS=TRUE \</div>
<div class="line">    -DCMAKE_CXX_COMPILER_WORKS=TRUE \</div>
<div class="line">    -DCMAKE_ANDROID_NDK=$NDK_DIR \</div>
<div class="line">    -DCMAKE_SYSTEM_NAME=Android \</div>
<div class="line">    -DCMAKE_SYSTEM_VERSION=$ANDROID_API \</div>
<div class="line">    -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \</div>
<div class="line">    -DCMAKE_SYSROOT=$WORKING_DIR/android-ndk-r25/toolchains/llvm/prebuilt/linux-x86_64/sysroot \</div>
<div class="line">    -DCMAKE_CXX_FLAGS=--std=c++14 \</div>
<div class="line">    -DCMAKE_EXE_LINKER_FLAGS=&quot;-pie -llog&quot; \</div>
<div class="line">    -DCMAKE_MODULE_LINKER_FLAGS=&quot;-llog&quot; \</div>
<div class="line">    -DARMNN_PATH=$WORKING_DIR/armnn/build/libarmnn.so ..</div>
</div><!-- fragment --></li>
<li>Run the build <div class="fragment"><div class="line">make</div>
</div><!-- fragment --></li>
</ul>
<h1>Run the Arm NN unit tests on an Android device</h1>
<ul>
<li>Push the build results to an Android device and make symbolic links for shared libraries: Currently adb version we have used for testing is 1.0.41. <div class="fragment"><div class="line">adb push libarmnn.so /data/local/tmp/</div>
<div class="line">adb push libtimelineDecoder.so /data/local/tmp/</div>
<div class="line">adb push libtimelineDecoderJson.so /data/local/tmp/</div>
<div class="line">adb push GatordMock /data/local/tmp/</div>
<div class="line">adb push libarmnnBasePipeServer.so /data/local/tmp/</div>
<div class="line">adb push libarmnnTestUtils.so /data/local/tmp/</div>
<div class="line">adb push UnitTests /data/local/tmp/</div>
<div class="line">adb push $NDK_DIR/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so /data/local/tmp/</div>
</div><!-- fragment --></li>
<li>Push the files needed for the unit tests (they are a mix of files, directories and symbolic links): <div class="fragment"><div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/testSharedObject</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/testSharedObject/* /data/local/tmp/src/backends/backendsCommon/test/testSharedObject/</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/testDynamicBackend</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/testDynamicBackend/* /data/local/tmp/src/backends/backendsCommon/test/testDynamicBackend/</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath1</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath1/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath1/</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/</div>
<div class="line">adb shell ln -s Arm_CpuAcc_backend.so /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1</div>
<div class="line">adb shell ln -s Arm_CpuAcc_backend.so.1 /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1.2</div>
<div class="line">adb shell ln -s Arm_CpuAcc_backend.so.1.2 /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_CpuAcc_backend.so.1.2.3</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath2/Arm_GpuAcc_backend.so /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/</div>
<div class="line">adb shell ln -s nothing /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath2/Arm_no_backend.so</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath3</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath5</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath5/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath5/</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath6</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath6/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath6/</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath7</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath9</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/backendsCommon/test/backendsTestPath9/* /data/local/tmp/src/backends/backendsCommon/test/backendsTestPath9/</div>
<div class="line"> </div>
<div class="line">adb shell mkdir -p /data/local/tmp/src/backends/dynamic/reference</div>
<div class="line">adb push -p $WORKING_DIR/armnn/build/src/backends/dynamic/reference/Arm_CpuRef_backend.so /data/local/tmp/src/backends/dynamic/reference/</div>
</div><!-- fragment --></li>
</ul>
<p>If the standalone sample dynamic tests are enabled, also push libArm_SampleDynamic_backend.so library file to the folder specified as $SAMPLE_DYNAMIC_BACKEND_PATH when Arm NN is built. This is the example when $SAMPLE_DYNAMIC_BACKEND_PATH is specified as /data/local/tmp/dynamic/sample/:</p>
<div class="fragment"><div class="line">adb shell mkdir -p /data/local/tmp/dynamic/sample/</div>
<div class="line">adb push -p $WORKING_DIR/armnn/src/dynamic/sample/build/libArm_SampleDynamic_backend.so /data/local/tmp/dynamic/sample/</div>
</div><!-- fragment --><p>If the delegate was built, push the delegate unit tests too. </p><div class="fragment"><div class="line">adb push $WORKING_DIR/armnn/build/delegate/DelegateUnitTests /data/local/tmp/</div>
<div class="line">adb push $WORKING_DIR/armnn/build/delegate/libarmnnDelegate.so /data/local/tmp/</div>
</div><!-- fragment --><p>Run Arm NN unit tests: </p><div class="fragment"><div class="line">adb shell &#39;LD_LIBRARY_PATH=/data/local/tmp:/vendor/lib64:/vendor/lib64/egl /data/local/tmp/UnitTests&#39;</div>
</div><!-- fragment --><p>If the delegate was built run Arm Delegate NN unit tests: </p><div class="fragment"><div class="line">adb shell &#39;LD_LIBRARY_PATH=/data/local/tmp:/vendor/lib64:/vendor/lib64/egl /data/local/tmp/DelegateUnitTests&#39;</div>
</div><!-- fragment --><p>If libarmnnUtils.a is present in <code>$WORKING_DIR/armnn/build/</code> and the unit tests run without failure then the build was successful. </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="buildguides.xhtml">Build Guides</a></li>
    <li class="footer">Generated on Thu May 18 2023 10:35:44 for ArmNN by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.17 </li>
  </ul>
</div>
</body>
</html>