aboutsummaryrefslogtreecommitdiff
path: root/23.02/md_src_dynamic__r_e_a_d_m_e.xhtml
blob: e272aaa8ed1411b5df86b869f3f242f6c1e125c4 (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
<!-- 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: Dynamically loadable Backend</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.02</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_src_dynamic__r_e_a_d_m_e.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">Dynamically loadable Backend </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Arm NN allows adding new dynamic backends. Dynamic Backends can be compiled as standalone against Arm NN and can be loaded by Arm NN dynamically at runtime.</p>
<p>To be properly loaded and used, the backend instances must comply to the standard interface for dynamic backends and to the versioning rules that enforce ABI compatibility. The details of how to add dynamic backends can be found in ../backends/README.md "src/backends/README.md".</p>
<h2>Standalone dynamic backend build</h2>
<p>The easiest way to build a standalone sample dynamic backend is to build using environment configured compiler and specify the Arm NN path to the CMake command:</p>
<div class="fragment"><div class="line">cd ${DYNAMIC_BACKEND_DIR}</div>
<div class="line">mkdir build</div>
<div class="line">cd build</div>
<div class="line">cmake -DARMNN_PATH=${ARMNN_PATH}/libarmnn.so ..</div>
</div><!-- fragment --><p>Then run the build</p>
<div class="fragment"><div class="line">make</div>
</div><!-- fragment --><p>The library will be created in ${DYNAMIC_BACKEND_DIR}/build.</p>
<h1>Dynamic backend loading paths</h1>
<p>During the creation of the Runtime, Arm NN will scan a given set of paths searching for suitable dynamic backend objects to load. A list of (absolute) paths can be specified at compile-time by setting a define named <code>DYNAMIC_BACKEND_PATHS</code> in the form of a colon-separated list of strings.</p>
<div class="fragment"><div class="line">-DDYNAMIC_BACKEND_PATHS=&quot;PATH_1:PATH_2...:PATH_N&quot;</div>
</div><!-- fragment --><p>Example for setting the path to the sample standalone dynamic backend built from the previous step:</p>
<div class="fragment"><div class="line">-DDYNAMIC_BACKEND_PATHS=${DYNAMIC_BACKEND_DIR}/build</div>
</div><!-- fragment --><p>The paths will be processed in the same order as they are indicated in the macro.</p>
<h1>Standalone dynamic backend example</h1>
<p>The source code includes an example that is used to generate a simple dynamic backend and is provided at</p>
<p><a href="./sample/SampleDynamicBackend.hpp">SampleDynamicBackend.hpp</a> <a href="./sample/SampleDynamicBackend.cpp">SampleDynamicBackend.cpp</a></p>
<p>The details of how to create backends can be found in ../backends/README.md "src/backends/README.md".</p>
<p>The makefile used for building the standalone reference dynamic backend is also provided: <a href="./sample/CMakeLists.txt">CMakeLists.txt</a></p>
<h2>End-To-End steps to build and test the sample dynamic backend</h2>
<p>To build and test the sample dynamic backend mentioned above, first Arm NN must be built with the sample dynamic unit tests turned on (<b>-DSAMPLE_DYNAMIC_BACKEND</b>) and the path must be provided to the Arm NN build the location of where the sample dynamic backend will be located at (<b>-DDYNAMIC_BACKEND_PATHS</b>) at runtime. This path should reflect the location on the target device, if this is different that the machine on which Arm NN was built.</p>
<p>Arm NN can be built using the ../../build-tool/README.md "Build Tool" with the following additional comma-separated <b>&ndash;armnn-cmake-args</b> in the <b>BUILD_ARGS</b>: </p><div class="fragment"><div class="line">--armnn-cmake-args=&#39;-DSAMPLE_DYNAMIC_BACKEND=1,-DDYNAMIC_BACKEND_PATHS=/tmp/armnn/sample_dynamic_backend&#39;</div>
</div><!-- fragment --><p>Then the sample dynamic backend can be built standalone using the following commands: </p><div class="fragment"><div class="line">cd armnn/src/dynamic/sample</div>
<div class="line">mkdir build</div>
<div class="line">cd build</div>
<div class="line">cmake -DARMNN_PATH=${ARMNN_BUILD_PATH}/libarmnn.so ..</div>
<div class="line">make</div>
</div><!-- fragment --><p>A shared library file named <b>libArm_SampleDynamic_backend.so</b> will now be located in the build directory. Copy this to the location defined by -DDYNAMIC_BACKEND_PATHS at compile time: </p><div class="fragment"><div class="line">cp libArm_SampleDynamic_backend.so /tmp/armnn/sample_dynamic_backend</div>
</div><!-- fragment --><p>Then run the Arm NN unit tests which will be located inside the build directory created by the Arm NN build-tool: </p><div class="fragment"><div class="line">./UnitTests</div>
</div><!-- fragment --><p>To be confident that the standalone dynamic backend tests are running, run the unit tests with the following filter: </p><div class="fragment"><div class="line">./UnitTests -tc=CreateSampleDynamicBackend,SampleDynamicBackendEndToEnd</div>
<div class="line">[doctest] doctest version is &quot;2.4.6&quot;</div>
<div class="line">[doctest] run with &quot;--help&quot; for options</div>
<div class="line">===============================================================================</div>
<div class="line">[doctest] test cases:  2 |  2 passed | 0 failed | 2796 skipped</div>
<div class="line">[doctest] assertions: 11 | 11 passed | 0 failed |</div>
<div class="line">[doctest] Status: SUCCESS!</div>
</div><!-- fragment --> </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="contribguides.xhtml">Contribution Guides</a></li>
    <li class="footer">Generated on Wed Mar 22 2023 15:53:03 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>