Ryan OShea | de36e4a | 2020-03-13 16:26:19 +0000 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 5 | <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 6 | <meta name="generator" content="Doxygen 1.8.13"/> |
| 7 | <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | <title>ArmNN: NetworkQuantizer Class Reference</title> |
| 9 | <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 10 | <script type="text/javascript" src="jquery.js"></script> |
| 11 | <script type="text/javascript" src="dynsections.js"></script> |
| 12 | <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| 13 | <script type="text/javascript" src="resize.js"></script> |
| 14 | <script type="text/javascript" src="navtreedata.js"></script> |
| 15 | <script type="text/javascript" src="navtree.js"></script> |
| 16 | <script type="text/javascript"> |
| 17 | $(document).ready(initResizable); |
| 18 | </script> |
| 19 | <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 20 | <script type="text/javascript" src="search/searchdata.js"></script> |
| 21 | <script type="text/javascript" src="search/search.js"></script> |
| 22 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 23 | </head> |
| 24 | <body> |
| 25 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 26 | <div id="titlearea"> |
| 27 | <table cellspacing="0" cellpadding="0"> |
| 28 | <tbody> |
| 29 | <tr style="height: 56px;"> |
| 30 | <td id="projectalign" style="padding-left: 0.5em;"> |
| 31 | <div id="projectname">ArmNN |
| 32 |  <span id="projectnumber">NotReleased</span> |
| 33 | </div> |
| 34 | </td> |
| 35 | </tr> |
| 36 | </tbody> |
| 37 | </table> |
| 38 | </div> |
| 39 | <!-- end header part --> |
| 40 | <!-- Generated by Doxygen 1.8.13 --> |
| 41 | <script type="text/javascript"> |
| 42 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| 43 | </script> |
| 44 | <script type="text/javascript" src="menudata.js"></script> |
| 45 | <script type="text/javascript" src="menu.js"></script> |
| 46 | <script type="text/javascript"> |
| 47 | $(function() { |
| 48 | initMenu('',true,false,'search.php','Search'); |
| 49 | $(document).ready(function() { init_search(); }); |
| 50 | }); |
| 51 | </script> |
| 52 | <div id="main-nav"></div> |
| 53 | </div><!-- top --> |
| 54 | <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| 55 | <div id="nav-tree"> |
| 56 | <div id="nav-tree-contents"> |
| 57 | <div id="nav-sync" class="sync"></div> |
| 58 | </div> |
| 59 | </div> |
| 60 | <div id="splitbar" style="-moz-user-select:none;" |
| 61 | class="ui-resizable-handle"> |
| 62 | </div> |
| 63 | </div> |
| 64 | <script type="text/javascript"> |
| 65 | $(document).ready(function(){initNavTree('classarmnn_1_1_network_quantizer.html','');}); |
| 66 | </script> |
| 67 | <div id="doc-content"> |
| 68 | <!-- window showing the filter options --> |
| 69 | <div id="MSearchSelectWindow" |
| 70 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 71 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 72 | onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 73 | </div> |
| 74 | |
| 75 | <!-- iframe showing the search results (closed by default) --> |
| 76 | <div id="MSearchResultsWindow"> |
| 77 | <iframe src="javascript:void(0)" frameborder="0" |
| 78 | name="MSearchResults" id="MSearchResults"> |
| 79 | </iframe> |
| 80 | </div> |
| 81 | |
| 82 | <div class="header"> |
| 83 | <div class="summary"> |
| 84 | <a href="#pub-methods">Public Member Functions</a> | |
| 85 | <a href="classarmnn_1_1_network_quantizer-members.html">List of all members</a> </div> |
| 86 | <div class="headertitle"> |
| 87 | <div class="title">NetworkQuantizer Class Reference</div> </div> |
| 88 | </div><!--header--> |
| 89 | <div class="contents"> |
| 90 | |
| 91 | <p><code>#include <<a class="el" href="_network_quantizer_8hpp_source.html">NetworkQuantizer.hpp</a>></code></p> |
| 92 | <div class="dynheader"> |
| 93 | Inheritance diagram for NetworkQuantizer:</div> |
| 94 | <div class="dyncontent"> |
| 95 | <div class="center"> |
| 96 | <img src="classarmnn_1_1_network_quantizer.png" usemap="#NetworkQuantizer_map" alt=""/> |
| 97 | <map id="NetworkQuantizer_map" name="NetworkQuantizer_map"> |
| 98 | <area href="classarmnn_1_1_i_network_quantizer.html" title="Quantizer class Quantizes a float32 InputNetwork. " alt="INetworkQuantizer" shape="rect" coords="0,0,116,24"/> |
| 99 | </map> |
| 100 | </div></div> |
| 101 | <table class="memberdecls"> |
| 102 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> |
| 103 | Public Member Functions</h2></td></tr> |
| 104 | <tr class="memitem:ad1d6bb17a39fec4850c40eadf5f537a4"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_network_quantizer.html#ad1d6bb17a39fec4850c40eadf5f537a4">NetworkQuantizer</a> (<a class="el" href="classarmnn_1_1_i_network.html">INetwork</a> *inputNetwork, const <a class="el" href="structarmnn_1_1_quantizer_options.html">QuantizerOptions</a> &<a class="el" href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a>)</td></tr> |
| 105 | <tr class="separator:ad1d6bb17a39fec4850c40eadf5f537a4"><td class="memSeparator" colspan="2"> </td></tr> |
| 106 | <tr class="memitem:a0de9803a30020e30ec8c9c0ba8592dc6"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_network_quantizer.html#a0de9803a30020e30ec8c9c0ba8592dc6">OverrideInputRange</a> (<a class="el" href="namespacearmnn.html#ab8cf8f9fb6792e654c2d8d8382f6f01b">LayerBindingId</a> layerId, float min, float max) override</td></tr> |
| 107 | <tr class="memdesc:a0de9803a30020e30ec8c9c0ba8592dc6"><td class="mdescLeft"> </td><td class="mdescRight">Overrides the default quantization values for the input layer with the given id. <a href="#a0de9803a30020e30ec8c9c0ba8592dc6">More...</a><br /></td></tr> |
| 108 | <tr class="separator:a0de9803a30020e30ec8c9c0ba8592dc6"><td class="memSeparator" colspan="2"> </td></tr> |
| 109 | <tr class="memitem:acff529f0d8ffed99123e3a729942be12"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_network_quantizer.html#acff529f0d8ffed99123e3a729942be12">Refine</a> (const <a class="el" href="namespacearmnn.html#aa01bce88f89975a5a031db4cc8861527">InputTensors</a> &inputTensors) override</td></tr> |
| 110 | <tr class="memdesc:acff529f0d8ffed99123e3a729942be12"><td class="mdescLeft"> </td><td class="mdescRight">Refine input network with a set of refinement data for specified LayerBindingId. <a href="#acff529f0d8ffed99123e3a729942be12">More...</a><br /></td></tr> |
| 111 | <tr class="separator:acff529f0d8ffed99123e3a729942be12"><td class="memSeparator" colspan="2"> </td></tr> |
| 112 | <tr class="memitem:a3618dd686c52c451000bea3e20931ac8"><td class="memItemLeft" align="right" valign="top">std::pair< float, float > </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_network_quantizer.html#a3618dd686c52c451000bea3e20931ac8">GetMinMaxRange</a> (<a class="el" href="namespacearmnn.html#afad4088a9a058114ee5f87246f87bf49">LayerGuid</a> guid, unsigned int idx)</td></tr> |
| 113 | <tr class="separator:a3618dd686c52c451000bea3e20931ac8"><td class="memSeparator" colspan="2"> </td></tr> |
| 114 | <tr class="memitem:a8768a9dd173e985bfc0c72338662d631"><td class="memItemLeft" align="right" valign="top"><a class="el" href="namespacearmnn.html#ace74f6f9feb95a964a49d79458232703">INetworkPtr</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_network_quantizer.html#a8768a9dd173e985bfc0c72338662d631">ExportNetwork</a> () override</td></tr> |
| 115 | <tr class="memdesc:a8768a9dd173e985bfc0c72338662d631"><td class="mdescLeft"> </td><td class="mdescRight">Extract final quantized network. <a href="#a8768a9dd173e985bfc0c72338662d631">More...</a><br /></td></tr> |
| 116 | <tr class="separator:a8768a9dd173e985bfc0c72338662d631"><td class="memSeparator" colspan="2"> </td></tr> |
| 117 | </table><table class="memberdecls"> |
| 118 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a> |
| 119 | Additional Inherited Members</h2></td></tr> |
| 120 | <tr class="inherit_header pub_static_methods_classarmnn_1_1_i_network_quantizer"><td colspan="2" onclick="javascript:toggleInherit('pub_static_methods_classarmnn_1_1_i_network_quantizer')"><img src="closed.png" alt="-"/> Static Public Member Functions inherited from <a class="el" href="classarmnn_1_1_i_network_quantizer.html">INetworkQuantizer</a></td></tr> |
| 121 | <tr class="memitem:ab8c40aedacd27ec921e53f3a022e6a63 inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="classarmnn_1_1_i_network_quantizer.html">INetworkQuantizer</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_i_network_quantizer.html#ab8c40aedacd27ec921e53f3a022e6a63">CreateRaw</a> (<a class="el" href="classarmnn_1_1_i_network.html">INetwork</a> *inputNetwork, const <a class="el" href="structarmnn_1_1_quantizer_options.html">QuantizerOptions</a> &<a class="el" href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a>=<a class="el" href="structarmnn_1_1_quantizer_options.html">QuantizerOptions</a>())</td></tr> |
| 122 | <tr class="memdesc:ab8c40aedacd27ec921e53f3a022e6a63 inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="mdescLeft"> </td><td class="mdescRight">Create Quantizer object and return raw pointer. <a href="classarmnn_1_1_i_network_quantizer.html#ab8c40aedacd27ec921e53f3a022e6a63">More...</a><br /></td></tr> |
| 123 | <tr class="separator:ab8c40aedacd27ec921e53f3a022e6a63 inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="memSeparator" colspan="2"> </td></tr> |
| 124 | <tr class="memitem:a3a4d01d9351c02a703740290f226441f inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="memItemLeft" align="right" valign="top">static <a class="el" href="namespacearmnn.html#a41119e261eec9343888d2ceab1e4999a">INetworkQuantizerPtr</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_i_network_quantizer.html#a3a4d01d9351c02a703740290f226441f">Create</a> (<a class="el" href="classarmnn_1_1_i_network.html">INetwork</a> *inputNetwork, const <a class="el" href="structarmnn_1_1_quantizer_options.html">QuantizerOptions</a> &<a class="el" href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a>=<a class="el" href="structarmnn_1_1_quantizer_options.html">QuantizerOptions</a>())</td></tr> |
| 125 | <tr class="memdesc:a3a4d01d9351c02a703740290f226441f inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="mdescLeft"> </td><td class="mdescRight">Create Quantizer object wrapped in unique_ptr. <a href="classarmnn_1_1_i_network_quantizer.html#a3a4d01d9351c02a703740290f226441f">More...</a><br /></td></tr> |
| 126 | <tr class="separator:a3a4d01d9351c02a703740290f226441f inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="memSeparator" colspan="2"> </td></tr> |
| 127 | <tr class="memitem:ad1ad5b83dc4d8bed64c29adf21c8958a inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="memItemLeft" align="right" valign="top">static void </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_i_network_quantizer.html#ad1ad5b83dc4d8bed64c29adf21c8958a">Destroy</a> (<a class="el" href="classarmnn_1_1_i_network_quantizer.html">INetworkQuantizer</a> *quantizer)</td></tr> |
| 128 | <tr class="memdesc:ad1ad5b83dc4d8bed64c29adf21c8958a inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="mdescLeft"> </td><td class="mdescRight">Destroy Quantizer object. <a href="classarmnn_1_1_i_network_quantizer.html#ad1ad5b83dc4d8bed64c29adf21c8958a">More...</a><br /></td></tr> |
| 129 | <tr class="separator:ad1ad5b83dc4d8bed64c29adf21c8958a inherit pub_static_methods_classarmnn_1_1_i_network_quantizer"><td class="memSeparator" colspan="2"> </td></tr> |
| 130 | <tr class="inherit_header pro_methods_classarmnn_1_1_i_network_quantizer"><td colspan="2" onclick="javascript:toggleInherit('pro_methods_classarmnn_1_1_i_network_quantizer')"><img src="closed.png" alt="-"/> Protected Member Functions inherited from <a class="el" href="classarmnn_1_1_i_network_quantizer.html">INetworkQuantizer</a></td></tr> |
| 131 | <tr class="memitem:a6b376fc4dcd2e2b3f5c1125a9c460a12 inherit pro_methods_classarmnn_1_1_i_network_quantizer"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1_i_network_quantizer.html#a6b376fc4dcd2e2b3f5c1125a9c460a12">~INetworkQuantizer</a> ()</td></tr> |
| 132 | <tr class="separator:a6b376fc4dcd2e2b3f5c1125a9c460a12 inherit pro_methods_classarmnn_1_1_i_network_quantizer"><td class="memSeparator" colspan="2"> </td></tr> |
| 133 | </table> |
| 134 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| 135 | <div class="textblock"> |
| 136 | <p class="definition">Definition at line <a class="el" href="_network_quantizer_8hpp_source.html#l00020">20</a> of file <a class="el" href="_network_quantizer_8hpp_source.html">NetworkQuantizer.hpp</a>.</p> |
| 137 | </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> |
| 138 | <a id="ad1d6bb17a39fec4850c40eadf5f537a4"></a> |
| 139 | <h2 class="memtitle"><span class="permalink"><a href="#ad1d6bb17a39fec4850c40eadf5f537a4">◆ </a></span>NetworkQuantizer()</h2> |
| 140 | |
| 141 | <div class="memitem"> |
| 142 | <div class="memproto"> |
| 143 | <table class="mlabels"> |
| 144 | <tr> |
| 145 | <td class="mlabels-left"> |
| 146 | <table class="memname"> |
| 147 | <tr> |
| 148 | <td class="memname"><a class="el" href="classarmnn_1_1_network_quantizer.html">NetworkQuantizer</a> </td> |
| 149 | <td>(</td> |
| 150 | <td class="paramtype"><a class="el" href="classarmnn_1_1_i_network.html">INetwork</a> * </td> |
| 151 | <td class="paramname"><em>inputNetwork</em>, </td> |
| 152 | </tr> |
| 153 | <tr> |
| 154 | <td class="paramkey"></td> |
| 155 | <td></td> |
| 156 | <td class="paramtype">const <a class="el" href="structarmnn_1_1_quantizer_options.html">QuantizerOptions</a> & </td> |
| 157 | <td class="paramname"><em>options</em> </td> |
| 158 | </tr> |
| 159 | <tr> |
| 160 | <td></td> |
| 161 | <td>)</td> |
| 162 | <td></td><td></td> |
| 163 | </tr> |
| 164 | </table> |
| 165 | </td> |
| 166 | <td class="mlabels-right"> |
| 167 | <span class="mlabels"><span class="mlabel">inline</span></span> </td> |
| 168 | </tr> |
| 169 | </table> |
| 170 | </div><div class="memdoc"> |
| 171 | |
| 172 | <p class="definition">Definition at line <a class="el" href="_network_quantizer_8hpp_source.html#l00023">23</a> of file <a class="el" href="_network_quantizer_8hpp_source.html">NetworkQuantizer.hpp</a>.</p> |
| 173 | |
| 174 | <p class="reference">References <a class="el" href="_network_quantizer_8cpp_source.html#l00050">NetworkQuantizer::OverrideInputRange()</a>, and <a class="el" href="_network_quantizer_8cpp_source.html#l00060">NetworkQuantizer::Refine()</a>.</p> |
| 175 | <div class="fragment"><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>  : m_InputNetwork(inputNetwork),</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  m_NetworkId(0),</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>  m_Runtime(<span class="keyword">nullptr</span>, &<a class="code" href="classarmnn_1_1_i_runtime.html#a978f3d0d34a944b40240bd130d61e3b6">IRuntime::Destroy</a>),</div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  m_RefineCount(0),</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  m_Options(<a class="code" href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a>) {}</div><div class="ttc" id="classarmnn_1_1_i_runtime_html_a978f3d0d34a944b40240bd130d61e3b6"><div class="ttname"><a href="classarmnn_1_1_i_runtime.html#a978f3d0d34a944b40240bd130d61e3b6">armnn::IRuntime::Destroy</a></div><div class="ttdeci">static void Destroy(IRuntime *runtime)</div><div class="ttdef"><b>Definition:</b> <a href="_runtime_8cpp_source.html#l00037">Runtime.cpp:37</a></div></div> |
| 176 | <div class="ttc" id="_file_only_profiling_decorator_tests_8cpp_html_a6560146509197f3e197d8d36f76c1347"><div class="ttname"><a href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a></div><div class="ttdeci">armnn::Runtime::CreationOptions::ExternalProfilingOptions options</div><div class="ttdef"><b>Definition:</b> <a href="_file_only_profiling_decorator_tests_8cpp_source.html#l00045">FileOnlyProfilingDecoratorTests.cpp:45</a></div></div> |
| 177 | </div><!-- fragment --> |
| 178 | </div> |
| 179 | </div> |
| 180 | <h2 class="groupheader">Member Function Documentation</h2> |
| 181 | <a id="a8768a9dd173e985bfc0c72338662d631"></a> |
| 182 | <h2 class="memtitle"><span class="permalink"><a href="#a8768a9dd173e985bfc0c72338662d631">◆ </a></span>ExportNetwork()</h2> |
| 183 | |
| 184 | <div class="memitem"> |
| 185 | <div class="memproto"> |
| 186 | <table class="mlabels"> |
| 187 | <tr> |
| 188 | <td class="mlabels-left"> |
| 189 | <table class="memname"> |
| 190 | <tr> |
| 191 | <td class="memname"><a class="el" href="namespacearmnn.html#ace74f6f9feb95a964a49d79458232703">INetworkPtr</a> ExportNetwork </td> |
| 192 | <td>(</td> |
| 193 | <td class="paramname"></td><td>)</td> |
| 194 | <td></td> |
| 195 | </tr> |
| 196 | </table> |
| 197 | </td> |
| 198 | <td class="mlabels-right"> |
| 199 | <span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span> </td> |
| 200 | </tr> |
| 201 | </table> |
| 202 | </div><div class="memdoc"> |
| 203 | |
| 204 | <p>Extract final quantized network. </p> |
| 205 | |
| 206 | <p>Implements <a class="el" href="classarmnn_1_1_i_network_quantizer.html#a2c24535b51018853e67bad277f4cbbeb">INetworkQuantizer</a>.</p> |
| 207 | |
| 208 | <p class="definition">Definition at line <a class="el" href="_network_quantizer_8cpp_source.html#l00136">136</a> of file <a class="el" href="_network_quantizer_8cpp_source.html">NetworkQuantizer.cpp</a>.</p> |
| 209 | |
| 210 | <p class="reference">References <a class="el" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a9d02ea768c081d4bdb2b7cab0b3f510d">armnn::QAsymmS8</a>, <a class="el" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a0a3f57c876f5a230244c38e1453a8a6e">armnn::QAsymmU8</a>, <a class="el" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a053c769dcf82d66ef326c86980c02ba7">armnn::QSymmS16</a>, <a class="el" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a9945327825b115e93a3b89f4302e76db">armnn::QSymmS8</a>, <a class="el" href="_graph_8hpp_source.html#l00173">Graph::TopologicalSort()</a>, and <a class="el" href="_network_quantizer_utils_8hpp_source.html#l00050">armnn::VisitLayers()</a>.</p> |
| 211 | |
| 212 | <p class="reference">Referenced by <a class="el" href="_network_quantizer_8hpp_source.html#l00034">NetworkQuantizer::GetMinMaxRange()</a>.</p> |
| 213 | <div class="fragment"><div class="line"><a name="l00137"></a><span class="lineno"> 137</span> {</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keyword">const</span> Graph& graph = boost::polymorphic_downcast<const Network*>(m_InputNetwork)->GetGraph().TopologicalSort();</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span> </div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="comment">// Step 1) Walk the graph and populate default min/max values for</span></div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="comment">// intermediate tensors, only if Runtime does not exist (created</span></div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="comment">// if Refine has been called)</span></div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordflow">if</span> (!m_Runtime)</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  {</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#ad083f83ce01c5a1e16da1236442e2169">SetDynamicMode</a>(<span class="keyword">false</span>);</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  StaticRangeVisitor rangeVisitor(m_Ranges);</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <a class="code" href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">VisitLayers</a>(graph, rangeVisitor);</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  }</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  {</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <span class="comment">// Set min/max range of non-calibrated layers to parent layer's range</span></div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  m_DynamicQuantizationVisitor.value().VisitNonCalibratedLayers();</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="comment">// now tear down the runtime and the dynamic visitor.</span></div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  m_Runtime.reset(<span class="keyword">nullptr</span>);</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  m_DynamicQuantizationVisitor = EmptyOptional();</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  m_RefineCount = 0;</div><div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  }</div><div class="line"><a name="l00158"></a><span class="lineno"> 158</span> </div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  <span class="comment">// Step 2) Convert input InputNetwork to Quantized InputNetwork</span></div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  std::unique_ptr<IQuantizationScheme> quantizationScheme;</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  <span class="keywordflow">switch</span> (m_Options.<a class="code" href="structarmnn_1_1_quantizer_options.html#a64fb6dc5a9d3fe72b8f63364a10774a7">m_ActivationFormat</a>)</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  {</div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  <span class="keywordflow">case</span> <a class="code" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a0a3f57c876f5a230244c38e1453a8a6e">DataType::QAsymmU8</a>:</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  quantizationScheme = std::make_unique<QAsymmU8QuantizationScheme>();</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  <span class="keywordflow">case</span> <a class="code" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a9d02ea768c081d4bdb2b7cab0b3f510d">DataType::QAsymmS8</a>:</div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  quantizationScheme = std::make_unique<QAsymmS8QuantizationScheme>();</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  <span class="keywordflow">case</span> <a class="code" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a9945327825b115e93a3b89f4302e76db">DataType::QSymmS8</a>:</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  quantizationScheme = std::make_unique<QSymmS8QuantizationScheme>();</div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  <span class="keywordflow">case</span> <a class="code" href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a053c769dcf82d66ef326c86980c02ba7">DataType::QSymmS16</a>:</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  quantizationScheme = std::make_unique<QSymm16QuantizationScheme>();</div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  <span class="keywordflow">break</span>;</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  <span class="keywordflow">default</span>:</div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="keywordflow">throw</span> InvalidArgumentException(<span class="stringliteral">"Unsupported quantization target"</span>);</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  }</div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span> </div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  QuantizerVisitor quantizerVisitor(m_Ranges, quantizationScheme.get(), m_Options.<a class="code" href="structarmnn_1_1_quantizer_options.html#a5bc42c844726d5fe782741617a893f43">m_PreserveType</a>);</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  <a class="code" href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">VisitLayers</a>(graph, quantizerVisitor);</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span> </div><div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  <span class="comment">// clear the ranges</span></div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#a372de693ad40b3f42839c8ec6ac845f4">Reset</a>();</div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span> </div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  <span class="keywordflow">return</span> quantizerVisitor.RetrieveFinalNetwork();</div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span> }</div><div class="ttc" id="namespacearmnn_html_ad8ed01ff3ff33333d8e19db4d2818bb6a9945327825b115e93a3b89f4302e76db"><div class="ttname"><a href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a9945327825b115e93a3b89f4302e76db">armnn::DataType::QSymmS8</a></div></div> |
| 214 | <div class="ttc" id="namespacearmnn_html_ad8ed01ff3ff33333d8e19db4d2818bb6a0a3f57c876f5a230244c38e1453a8a6e"><div class="ttname"><a href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a0a3f57c876f5a230244c38e1453a8a6e">armnn::DataType::QAsymmU8</a></div></div> |
| 215 | <div class="ttc" id="namespacearmnn_html_a9835ef753dda5b5a2fe827680e41fda7"><div class="ttname"><a href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">armnn::VisitLayers</a></div><div class="ttdeci">void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)</div><div class="ttdef"><b>Definition:</b> <a href="_network_quantizer_utils_8hpp_source.html#l00050">NetworkQuantizerUtils.hpp:50</a></div></div> |
| 216 | <div class="ttc" id="namespacearmnn_html_ad8ed01ff3ff33333d8e19db4d2818bb6a9d02ea768c081d4bdb2b7cab0b3f510d"><div class="ttname"><a href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a9d02ea768c081d4bdb2b7cab0b3f510d">armnn::DataType::QAsymmS8</a></div></div> |
| 217 | <div class="ttc" id="namespacearmnn_html_ad8ed01ff3ff33333d8e19db4d2818bb6a053c769dcf82d66ef326c86980c02ba7"><div class="ttname"><a href="namespacearmnn.html#ad8ed01ff3ff33333d8e19db4d2818bb6a053c769dcf82d66ef326c86980c02ba7">armnn::DataType::QSymmS16</a></div></div> |
| 218 | <div class="ttc" id="structarmnn_1_1_quantizer_options_html_a64fb6dc5a9d3fe72b8f63364a10774a7"><div class="ttname"><a href="structarmnn_1_1_quantizer_options.html#a64fb6dc5a9d3fe72b8f63364a10774a7">armnn::QuantizerOptions::m_ActivationFormat</a></div><div class="ttdeci">DataType m_ActivationFormat</div><div class="ttdef"><b>Definition:</b> <a href="_i_network_quantizer_8hpp_source.html#l00025">INetworkQuantizer.hpp:25</a></div></div> |
| 219 | <div class="ttc" id="structarmnn_1_1_quantizer_options_html_a5bc42c844726d5fe782741617a893f43"><div class="ttname"><a href="structarmnn_1_1_quantizer_options.html#a5bc42c844726d5fe782741617a893f43">armnn::QuantizerOptions::m_PreserveType</a></div><div class="ttdeci">bool m_PreserveType</div><div class="ttdef"><b>Definition:</b> <a href="_i_network_quantizer_8hpp_source.html#l00026">INetworkQuantizer.hpp:26</a></div></div> |
| 220 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_ad083f83ce01c5a1e16da1236442e2169"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#ad083f83ce01c5a1e16da1236442e2169">armnn::RangeTracker::SetDynamicMode</a></div><div class="ttdeci">void SetDynamicMode(bool flag)</div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8hpp_source.html#l00045">RangeTracker.hpp:45</a></div></div> |
| 221 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_a372de693ad40b3f42839c8ec6ac845f4"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#a372de693ad40b3f42839c8ec6ac845f4">armnn::RangeTracker::Reset</a></div><div class="ttdeci">void Reset()</div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8cpp_source.html#l00074">RangeTracker.cpp:74</a></div></div> |
| 222 | </div><!-- fragment --> |
| 223 | </div> |
| 224 | </div> |
| 225 | <a id="a3618dd686c52c451000bea3e20931ac8"></a> |
| 226 | <h2 class="memtitle"><span class="permalink"><a href="#a3618dd686c52c451000bea3e20931ac8">◆ </a></span>GetMinMaxRange()</h2> |
| 227 | |
| 228 | <div class="memitem"> |
| 229 | <div class="memproto"> |
| 230 | <table class="mlabels"> |
| 231 | <tr> |
| 232 | <td class="mlabels-left"> |
| 233 | <table class="memname"> |
| 234 | <tr> |
| 235 | <td class="memname">std::pair<float, float> GetMinMaxRange </td> |
| 236 | <td>(</td> |
| 237 | <td class="paramtype"><a class="el" href="namespacearmnn.html#afad4088a9a058114ee5f87246f87bf49">LayerGuid</a> </td> |
| 238 | <td class="paramname"><em>guid</em>, </td> |
| 239 | </tr> |
| 240 | <tr> |
| 241 | <td class="paramkey"></td> |
| 242 | <td></td> |
| 243 | <td class="paramtype">unsigned int </td> |
| 244 | <td class="paramname"><em>idx</em> </td> |
| 245 | </tr> |
| 246 | <tr> |
| 247 | <td></td> |
| 248 | <td>)</td> |
| 249 | <td></td><td></td> |
| 250 | </tr> |
| 251 | </table> |
| 252 | </td> |
| 253 | <td class="mlabels-right"> |
| 254 | <span class="mlabels"><span class="mlabel">inline</span></span> </td> |
| 255 | </tr> |
| 256 | </table> |
| 257 | </div><div class="memdoc"> |
| 258 | |
| 259 | <p class="definition">Definition at line <a class="el" href="_network_quantizer_8hpp_source.html#l00034">34</a> of file <a class="el" href="_network_quantizer_8hpp_source.html">NetworkQuantizer.hpp</a>.</p> |
| 260 | |
| 261 | <p class="reference">References <a class="el" href="_network_quantizer_8cpp_source.html#l00136">NetworkQuantizer::ExportNetwork()</a>, and <a class="el" href="_range_tracker_8cpp_source.html#l00029">RangeTracker::GetRange()</a>.</p> |
| 262 | <div class="fragment"><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> { <span class="keywordflow">return</span> m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#a507bae23f59e94b4161886ebe663cdf4">GetRange</a>(guid, idx); }</div><div class="ttc" id="classarmnn_1_1_range_tracker_html_a507bae23f59e94b4161886ebe663cdf4"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#a507bae23f59e94b4161886ebe663cdf4">armnn::RangeTracker::GetRange</a></div><div class="ttdeci">MinMaxRange GetRange(LayerGuid guid, unsigned int idx) const</div><div class="ttdoc">Retrieve the Range for a particular output slot on a particular layer. </div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8cpp_source.html#l00029">RangeTracker.cpp:29</a></div></div> |
| 263 | </div><!-- fragment --> |
| 264 | </div> |
| 265 | </div> |
| 266 | <a id="a0de9803a30020e30ec8c9c0ba8592dc6"></a> |
| 267 | <h2 class="memtitle"><span class="permalink"><a href="#a0de9803a30020e30ec8c9c0ba8592dc6">◆ </a></span>OverrideInputRange()</h2> |
| 268 | |
| 269 | <div class="memitem"> |
| 270 | <div class="memproto"> |
| 271 | <table class="mlabels"> |
| 272 | <tr> |
| 273 | <td class="mlabels-left"> |
| 274 | <table class="memname"> |
| 275 | <tr> |
| 276 | <td class="memname">void OverrideInputRange </td> |
| 277 | <td>(</td> |
| 278 | <td class="paramtype"><a class="el" href="namespacearmnn.html#ab8cf8f9fb6792e654c2d8d8382f6f01b">LayerBindingId</a> </td> |
| 279 | <td class="paramname"><em>layerId</em>, </td> |
| 280 | </tr> |
| 281 | <tr> |
| 282 | <td class="paramkey"></td> |
| 283 | <td></td> |
| 284 | <td class="paramtype">float </td> |
| 285 | <td class="paramname"><em>min</em>, </td> |
| 286 | </tr> |
| 287 | <tr> |
| 288 | <td class="paramkey"></td> |
| 289 | <td></td> |
| 290 | <td class="paramtype">float </td> |
| 291 | <td class="paramname"><em>max</em> </td> |
| 292 | </tr> |
| 293 | <tr> |
| 294 | <td></td> |
| 295 | <td>)</td> |
| 296 | <td></td><td></td> |
| 297 | </tr> |
| 298 | </table> |
| 299 | </td> |
| 300 | <td class="mlabels-right"> |
| 301 | <span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span> </td> |
| 302 | </tr> |
| 303 | </table> |
| 304 | </div><div class="memdoc"> |
| 305 | |
| 306 | <p>Overrides the default quantization values for the input layer with the given id. </p> |
| 307 | |
| 308 | <p>Implements <a class="el" href="classarmnn_1_1_i_network_quantizer.html#a0ec2c346796d52e923cca0477497a6d0">INetworkQuantizer</a>.</p> |
| 309 | |
| 310 | <p class="definition">Definition at line <a class="el" href="_network_quantizer_8cpp_source.html#l00050">50</a> of file <a class="el" href="_network_quantizer_8cpp_source.html">NetworkQuantizer.cpp</a>.</p> |
| 311 | |
| 312 | <p class="reference">References <a class="el" href="_graph_8hpp_source.html#l00181">Graph::GetInputLayers()</a>, and <a class="el" href="_network_quantizer_utils_8hpp_source.html#l00050">armnn::VisitLayers()</a>.</p> |
| 313 | |
| 314 | <p class="reference">Referenced by <a class="el" href="_network_quantizer_8hpp_source.html#l00023">NetworkQuantizer::NetworkQuantizer()</a>.</p> |
| 315 | <div class="fragment"><div class="line"><a name="l00051"></a><span class="lineno"> 51</span> {</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  <span class="keyword">const</span> Graph& graph = boost::polymorphic_downcast<const Network*>(m_InputNetwork)->GetGraph();</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="keyword">auto</span> inputLayers = graph.GetInputLayers();</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span> </div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="comment">// Walk the input layers of the graph and override the quantization parameters of the one with the given id</span></div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  OverrideInputRangeVisitor overrideInputRangeVisitor(m_Ranges, layerId, <a class="code" href="classarmnn_1_1_range_tracker.html#a997e96288bdb106c922202e3f33d5d7b">RangeTracker::MinMaxRange</a>{min, max});</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <a class="code" href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">VisitLayers</a>(inputLayers, overrideInputRangeVisitor);</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> }</div><div class="ttc" id="namespacearmnn_html_a9835ef753dda5b5a2fe827680e41fda7"><div class="ttname"><a href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">armnn::VisitLayers</a></div><div class="ttdeci">void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)</div><div class="ttdef"><b>Definition:</b> <a href="_network_quantizer_utils_8hpp_source.html#l00050">NetworkQuantizerUtils.hpp:50</a></div></div> |
| 316 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_a997e96288bdb106c922202e3f33d5d7b"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#a997e96288bdb106c922202e3f33d5d7b">armnn::RangeTracker::MinMaxRange</a></div><div class="ttdeci">std::pair< float, float > MinMaxRange</div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8hpp_source.html#l00020">RangeTracker.hpp:20</a></div></div> |
| 317 | </div><!-- fragment --> |
| 318 | </div> |
| 319 | </div> |
| 320 | <a id="acff529f0d8ffed99123e3a729942be12"></a> |
| 321 | <h2 class="memtitle"><span class="permalink"><a href="#acff529f0d8ffed99123e3a729942be12">◆ </a></span>Refine()</h2> |
| 322 | |
| 323 | <div class="memitem"> |
| 324 | <div class="memproto"> |
| 325 | <table class="mlabels"> |
| 326 | <tr> |
| 327 | <td class="mlabels-left"> |
| 328 | <table class="memname"> |
| 329 | <tr> |
| 330 | <td class="memname">void Refine </td> |
| 331 | <td>(</td> |
| 332 | <td class="paramtype">const <a class="el" href="namespacearmnn.html#aa01bce88f89975a5a031db4cc8861527">InputTensors</a> & </td> |
| 333 | <td class="paramname"><em>inputTensors</em></td><td>)</td> |
| 334 | <td></td> |
| 335 | </tr> |
| 336 | </table> |
| 337 | </td> |
| 338 | <td class="mlabels-right"> |
| 339 | <span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span> </td> |
| 340 | </tr> |
| 341 | </table> |
| 342 | </div><div class="memdoc"> |
| 343 | |
| 344 | <p>Refine input network with a set of refinement data for specified LayerBindingId. </p> |
| 345 | |
| 346 | <p>Implements <a class="el" href="classarmnn_1_1_i_network_quantizer.html#ae7708b89714c5a85d62e07f674ab9da4">INetworkQuantizer</a>.</p> |
| 347 | |
| 348 | <p class="definition">Definition at line <a class="el" href="_network_quantizer_8cpp_source.html#l00060">60</a> of file <a class="el" href="_network_quantizer_8cpp_source.html">NetworkQuantizer.cpp</a>.</p> |
| 349 | |
| 350 | <p class="reference">References <a class="el" href="_runtime_8cpp_source.html#l00032">IRuntime::Create()</a>, <a class="el" href="_tensor_utils_8cpp_source.html#l00058">armnnUtils::FindMinMax()</a>, <a class="el" href="_network_8cpp_source.html#l00807">armnn::Optimize()</a>, <a class="el" href="_file_only_profiling_decorator_tests_8cpp_source.html#l00045">options</a>, <a class="el" href="_graph_8hpp_source.html#l00173">Graph::TopologicalSort()</a>, and <a class="el" href="_network_quantizer_utils_8hpp_source.html#l00050">armnn::VisitLayers()</a>.</p> |
| 351 | |
| 352 | <p class="reference">Referenced by <a class="el" href="_network_quantizer_8hpp_source.html#l00023">NetworkQuantizer::NetworkQuantizer()</a>.</p> |
| 353 | <div class="fragment"><div class="line"><a name="l00061"></a><span class="lineno"> 61</span> {</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  <span class="comment">// The first time Refine is called the m_Runtime and the DynamicQuantizationVisitor</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="comment">// will not have been created. Need to get the environment set up, Runtime loaded,</span></div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <span class="comment">// DynamicQuantizationVisitor created and run over the network to initialise itself</span></div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  <span class="comment">// and the RangeTracker the Debug callback registered and an initial inference</span></div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="comment">// done to set up the first min/max values</span></div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <span class="keywordflow">if</span> (!m_Runtime)</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  {</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  m_RefineCount = 0;</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#ad083f83ce01c5a1e16da1236442e2169">SetDynamicMode</a>(<span class="keyword">true</span>);</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  <span class="keyword">const</span> Graph& cGraph = boost::polymorphic_downcast<const Network*>(m_InputNetwork)->GetGraph().TopologicalSort();</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span> </div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <span class="comment">// need to insert Debug layers in the DynamicQuantizationVisitor</span></div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  Graph& graph = <span class="keyword">const_cast<</span>Graph&<span class="keyword">></span>(cGraph);</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span> </div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <span class="comment">// Initialize RangeTracker to the default values for each layer.</span></div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <span class="comment">// The default values are overwritten by the min/max that is</span></div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  <span class="comment">// recorded during the first dataset min/max calibration. This</span></div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="comment">// initialisation is only required for the first call of Refine().</span></div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  m_DynamicQuantizationVisitor = DynamicQuantizationVisitor(m_Ranges, graph);</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  <a class="code" href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">VisitLayers</a>(cGraph, m_DynamicQuantizationVisitor.value());</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span> </div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  IRuntime::CreationOptions <a class="code" href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a>;</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  m_Runtime = <a class="code" href="classarmnn_1_1_i_runtime.html#ad44ecd3700748dc30dc4bbe34ba5bde7">IRuntime::Create</a>(options);</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span> </div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  <span class="comment">// Optimize network - debug already enabled for layers that require quantization</span></div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  OptimizerOptions optimizerOptions(<span class="keyword">false</span>, <span class="keyword">false</span>);</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  std::vector<BackendId> backends = {<span class="stringliteral">"CpuRef"</span>};</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  <a class="code" href="namespacearmnn.html#a674efcf6cbdb9e831d653ff0e821fb38">IOptimizedNetworkPtr</a> optimizedNet = <a class="code" href="namespacearmnn.html#a82e98ef05fd67036d1195ba17174d685">Optimize</a>(*m_InputNetwork,</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  backends,</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  m_Runtime->GetDeviceSpec(),</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  optimizerOptions);</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span> </div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  m_Runtime->LoadNetwork(m_NetworkId, std::move(optimizedNet));</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span> </div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <span class="comment">// Debug callback function to refine min/max in RangeTracker</span></div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  <span class="keyword">auto</span> rangeTrackerCallback = [&](<a class="code" href="namespacearmnn.html#afad4088a9a058114ee5f87246f87bf49">LayerGuid</a> guid, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> slotIndex, ITensorHandle *tensorHandle) {</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  <span class="comment">// Get min/max pair from tensor data</span></div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  std::pair<float, float> minMax = <a class="code" href="namespacearmnn_utils.html#a1c9097ab13afc54b48c503c6487aaee1">armnnUtils::FindMinMax</a>(tensorHandle);</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span> </div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  <span class="comment">// For first calibration dataset, set min/max range in RangeTracker to</span></div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  <span class="comment">// min/max ranges gathered during inference</span></div><div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordflow">if</span> (m_RefineCount == 0)</div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  {</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#a4618337ffe8a3a2b5a6abf475454acdd">ResetMinMax</a>(guid, slotIndex, minMax.first, minMax.second);</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  }</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  {</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="comment">// For every other calibration dataset, only set min/max range if the</span></div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="comment">// values gathered are less than / greater than originally recorded.</span></div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#aa55e27d7cc1569b82476e6b30cbd6c25">RefineMin</a>(guid, slotIndex, minMax.first);</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  m_Ranges.<a class="code" href="classarmnn_1_1_range_tracker.html#ae5a4c3257000f8a0b7392a0104775894">RefineMax</a>(guid, slotIndex, minMax.second);</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  }</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  };</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span> </div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  m_Runtime->RegisterDebugCallback(m_NetworkId, rangeTrackerCallback);</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  }</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span> </div><div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <span class="comment">// Create output tensor for EnqueueWorkload</span></div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  std::vector<armnn::BindingPointInfo> outputBindings;</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keyword">auto</span> outputLayers = m_DynamicQuantizationVisitor.value().GetOutputLayers();</div><div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  std::vector<TContainer> outputVectors;</div><div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <span class="keywordflow">for</span> (<span class="keyword">auto</span> outputLayerBindingId : outputLayers)</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  {</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <span class="keyword">auto</span> outputTensorInfo = m_Runtime->GetOutputTensorInfo(m_NetworkId, outputLayerBindingId);</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  outputBindings.push_back(std::make_pair(outputLayerBindingId, outputTensorInfo));</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  outputVectors.push_back(std::vector<float>(outputTensorInfo.GetNumElements(), 0));</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  }</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <a class="code" href="namespacearmnn.html#a8f091a512915d1cb29a4ebf13dfc53ea">OutputTensors</a> outputTensors = armnnUtils::MakeOutputTensors<TContainer>(outputBindings, outputVectors);</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span> </div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="comment">// Execute EnqueueWorkload with calibration image</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  m_Runtime->EnqueueWorkload(m_NetworkId, inputTensors, outputTensors);</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  ++m_RefineCount;</div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span> }</div><div class="ttc" id="namespacearmnn_utils_html_a1c9097ab13afc54b48c503c6487aaee1"><div class="ttname"><a href="namespacearmnn_utils.html#a1c9097ab13afc54b48c503c6487aaee1">armnnUtils::FindMinMax</a></div><div class="ttdeci">std::pair< float, float > FindMinMax(armnn::ITensorHandle *tensorHandle)</div><div class="ttdef"><b>Definition:</b> <a href="_tensor_utils_8cpp_source.html#l00058">TensorUtils.cpp:58</a></div></div> |
| 354 | <div class="ttc" id="namespacearmnn_html_a8f091a512915d1cb29a4ebf13dfc53ea"><div class="ttname"><a href="namespacearmnn.html#a8f091a512915d1cb29a4ebf13dfc53ea">armnn::OutputTensors</a></div><div class="ttdeci">std::vector< std::pair< LayerBindingId, class Tensor > > OutputTensors</div><div class="ttdef"><b>Definition:</b> <a href="_tensor_8hpp_source.html#l00226">Tensor.hpp:226</a></div></div> |
| 355 | <div class="ttc" id="namespacearmnn_html_a9835ef753dda5b5a2fe827680e41fda7"><div class="ttname"><a href="namespacearmnn.html#a9835ef753dda5b5a2fe827680e41fda7">armnn::VisitLayers</a></div><div class="ttdeci">void VisitLayers(const LayerContainer &layerContainer, ILayerVisitor &visitor)</div><div class="ttdef"><b>Definition:</b> <a href="_network_quantizer_utils_8hpp_source.html#l00050">NetworkQuantizerUtils.hpp:50</a></div></div> |
| 356 | <div class="ttc" id="namespacearmnn_html_a82e98ef05fd67036d1195ba17174d685"><div class="ttname"><a href="namespacearmnn.html#a82e98ef05fd67036d1195ba17174d685">armnn::Optimize</a></div><div class="ttdeci">IOptimizedNetworkPtr Optimize(const INetwork &network, const std::vector< BackendId > &backendPreferences, const IDeviceSpec &deviceSpec, const OptimizerOptions &options=OptimizerOptions(), Optional< std::vector< std::string > &> messages=EmptyOptional())</div><div class="ttdef"><b>Definition:</b> <a href="_network_8cpp_source.html#l00807">Network.cpp:807</a></div></div> |
| 357 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_ae5a4c3257000f8a0b7392a0104775894"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#ae5a4c3257000f8a0b7392a0104775894">armnn::RangeTracker::RefineMax</a></div><div class="ttdeci">void RefineMax(LayerGuid guid, unsigned int slotIndex, float newMax)</div><div class="ttdoc">Update max in RangeTracker with new_max if it is greater than current value. </div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8cpp_source.html#l00055">RangeTracker.cpp:55</a></div></div> |
| 358 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_aa55e27d7cc1569b82476e6b30cbd6c25"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#aa55e27d7cc1569b82476e6b30cbd6c25">armnn::RangeTracker::RefineMin</a></div><div class="ttdeci">void RefineMin(LayerGuid guid, unsigned int slotIndex, float newMin)</div><div class="ttdoc">Update min in RangeTracker with new_min if it is lower than current value. </div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8cpp_source.html#l00046">RangeTracker.cpp:46</a></div></div> |
| 359 | <div class="ttc" id="classarmnn_1_1_i_runtime_html_ad44ecd3700748dc30dc4bbe34ba5bde7"><div class="ttname"><a href="classarmnn_1_1_i_runtime.html#ad44ecd3700748dc30dc4bbe34ba5bde7">armnn::IRuntime::Create</a></div><div class="ttdeci">static IRuntimePtr Create(const CreationOptions &options)</div><div class="ttdef"><b>Definition:</b> <a href="_runtime_8cpp_source.html#l00032">Runtime.cpp:32</a></div></div> |
| 360 | <div class="ttc" id="namespacearmnn_html_a674efcf6cbdb9e831d653ff0e821fb38"><div class="ttname"><a href="namespacearmnn.html#a674efcf6cbdb9e831d653ff0e821fb38">armnn::IOptimizedNetworkPtr</a></div><div class="ttdeci">std::unique_ptr< IOptimizedNetwork, void(*)(IOptimizedNetwork *network)> IOptimizedNetworkPtr</div><div class="ttdef"><b>Definition:</b> <a href="_i_network_8hpp_source.html#l00544">INetwork.hpp:544</a></div></div> |
| 361 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_a4618337ffe8a3a2b5a6abf475454acdd"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#a4618337ffe8a3a2b5a6abf475454acdd">armnn::RangeTracker::ResetMinMax</a></div><div class="ttdeci">void ResetMinMax(LayerGuid guid, unsigned int idx, float newMin, float newMax)</div><div class="ttdoc">Overwrite min and max in RangeTracker with newMin and newMax. </div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8cpp_source.html#l00064">RangeTracker.cpp:64</a></div></div> |
| 362 | <div class="ttc" id="_file_only_profiling_decorator_tests_8cpp_html_a6560146509197f3e197d8d36f76c1347"><div class="ttname"><a href="_file_only_profiling_decorator_tests_8cpp.html#a6560146509197f3e197d8d36f76c1347">options</a></div><div class="ttdeci">armnn::Runtime::CreationOptions::ExternalProfilingOptions options</div><div class="ttdef"><b>Definition:</b> <a href="_file_only_profiling_decorator_tests_8cpp_source.html#l00045">FileOnlyProfilingDecoratorTests.cpp:45</a></div></div> |
| 363 | <div class="ttc" id="namespacearmnn_html_afad4088a9a058114ee5f87246f87bf49"><div class="ttname"><a href="namespacearmnn.html#afad4088a9a058114ee5f87246f87bf49">armnn::LayerGuid</a></div><div class="ttdeci">profiling::ProfilingGuid LayerGuid</div><div class="ttdoc">Define LayerGuid type. </div><div class="ttdef"><b>Definition:</b> <a href="_types_8hpp_source.html#l00233">Types.hpp:233</a></div></div> |
| 364 | <div class="ttc" id="classarmnn_1_1_range_tracker_html_ad083f83ce01c5a1e16da1236442e2169"><div class="ttname"><a href="classarmnn_1_1_range_tracker.html#ad083f83ce01c5a1e16da1236442e2169">armnn::RangeTracker::SetDynamicMode</a></div><div class="ttdeci">void SetDynamicMode(bool flag)</div><div class="ttdef"><b>Definition:</b> <a href="_range_tracker_8hpp_source.html#l00045">RangeTracker.hpp:45</a></div></div> |
| 365 | </div><!-- fragment --> |
| 366 | </div> |
| 367 | </div> |
| 368 | <hr/>The documentation for this class was generated from the following files:<ul> |
| 369 | <li>src/armnn/<a class="el" href="_network_quantizer_8hpp_source.html">NetworkQuantizer.hpp</a></li> |
| 370 | <li>src/armnn/<a class="el" href="_network_quantizer_8cpp_source.html">NetworkQuantizer.cpp</a></li> |
| 371 | </ul> |
| 372 | </div><!-- contents --> |
| 373 | </div><!-- doc-content --> |
| 374 | <!-- start footer part --> |
| 375 | <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 376 | <ul> |
| 377 | <li class="navelem"><a class="el" href="namespacearmnn.html">armnn</a></li><li class="navelem"><a class="el" href="classarmnn_1_1_network_quantizer.html">NetworkQuantizer</a></li> |
| 378 | <li class="footer">Generated on Fri Mar 13 2020 16:07:04 for ArmNN by |
| 379 | <a href="http://www.doxygen.org/index.html"> |
| 380 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li> |
| 381 | </ul> |
| 382 | </div> |
| 383 | </body> |
| 384 | </html> |