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: QuantizedMultiplierSmallerThanOne Struct 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('structarmnn_1_1_quantized_multiplier_smaller_than_one.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="structarmnn_1_1_quantized_multiplier_smaller_than_one-members.html">List of all members</a> </div> |
| 86 | <div class="headertitle"> |
| 87 | <div class="title">QuantizedMultiplierSmallerThanOne Struct Reference</div> </div> |
| 88 | </div><!--header--> |
| 89 | <div class="contents"> |
| 90 | |
| 91 | <p><code>#include <<a class="el" href="_conv_impl_8hpp_source.html">ConvImpl.hpp</a>></code></p> |
| 92 | <table class="memberdecls"> |
| 93 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> |
| 94 | Public Member Functions</h2></td></tr> |
| 95 | <tr class="memitem:a1ec4f749fbbdacbe2cc7e8895d5b65ed"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="structarmnn_1_1_quantized_multiplier_smaller_than_one.html#a1ec4f749fbbdacbe2cc7e8895d5b65ed">QuantizedMultiplierSmallerThanOne</a> (float multiplier)</td></tr> |
| 96 | <tr class="separator:a1ec4f749fbbdacbe2cc7e8895d5b65ed"><td class="memSeparator" colspan="2"> </td></tr> |
| 97 | <tr class="memitem:ac04834893e568dfea4642ecb575faed8"><td class="memItemLeft" align="right" valign="top">int32_t </td><td class="memItemRight" valign="bottom"><a class="el" href="structarmnn_1_1_quantized_multiplier_smaller_than_one.html#ac04834893e568dfea4642ecb575faed8">operator*</a> (int32_t rhs) const</td></tr> |
| 98 | <tr class="memdesc:ac04834893e568dfea4642ecb575faed8"><td class="mdescLeft"> </td><td class="mdescRight">The implementation of this function is adapted from Android NN's MultiplyByQuantizedMultiplierSmallerThanOne(). <a href="#ac04834893e568dfea4642ecb575faed8">More...</a><br /></td></tr> |
| 99 | <tr class="separator:ac04834893e568dfea4642ecb575faed8"><td class="memSeparator" colspan="2"> </td></tr> |
| 100 | </table> |
| 101 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| 102 | <div class="textblock"><p>Performs multiplication of an integer with a multiplier which is less than one, using quantized integer arithmetic which is consistent with AndroidNN's CPU executor. </p> |
| 103 | |
| 104 | <p class="definition">Definition at line <a class="el" href="_conv_impl_8hpp_source.html#l00029">29</a> of file <a class="el" href="_conv_impl_8hpp_source.html">ConvImpl.hpp</a>.</p> |
| 105 | </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> |
| 106 | <a id="a1ec4f749fbbdacbe2cc7e8895d5b65ed"></a> |
| 107 | <h2 class="memtitle"><span class="permalink"><a href="#a1ec4f749fbbdacbe2cc7e8895d5b65ed">◆ </a></span>QuantizedMultiplierSmallerThanOne()</h2> |
| 108 | |
| 109 | <div class="memitem"> |
| 110 | <div class="memproto"> |
| 111 | <table class="memname"> |
| 112 | <tr> |
| 113 | <td class="memname"><a class="el" href="structarmnn_1_1_quantized_multiplier_smaller_than_one.html">QuantizedMultiplierSmallerThanOne</a> </td> |
| 114 | <td>(</td> |
| 115 | <td class="paramtype">float </td> |
| 116 | <td class="paramname"><em>multiplier</em></td><td>)</td> |
| 117 | <td></td> |
| 118 | </tr> |
| 119 | </table> |
| 120 | </div><div class="memdoc"> |
| 121 | <p>Constructs a <a class="el" href="structarmnn_1_1_quantized_multiplier_smaller_than_one.html">QuantizedMultiplierSmallerThanOne</a> which will multiply by the given multiplier. This stores the appropriate integer quantities (derived from the given multiplier) for later use. The implementation of this function is adapted from Android NN's QuantizeMultiplierSmallerThanOne(). </p> |
| 122 | |
| 123 | <p class="definition">Definition at line <a class="el" href="_conv_impl_8cpp_source.html#l00016">16</a> of file <a class="el" href="_conv_impl_8cpp_source.html">ConvImpl.cpp</a>.</p> |
| 124 | <div class="fragment"><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> {</div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>  BOOST_ASSERT(multiplier >= 0.0f && multiplier < 1.0f);</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  <span class="keywordflow">if</span> (multiplier == 0.0f)</div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>  {</div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>  m_Multiplier = 0;</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>  m_RightShift = 0;</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  }</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  {</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>  <span class="keyword">const</span> <span class="keywordtype">double</span> q = std::frexp(multiplier, &m_RightShift);</div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  m_RightShift = -m_RightShift;</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  int64_t qFixed = <span class="keyword">static_cast<</span>int64_t<span class="keyword">></span>(std::round(q * (1ll << 31)));</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  BOOST_ASSERT(qFixed <= (1ll << 31));</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  <span class="keywordflow">if</span> (qFixed == (1ll << 31))</div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  {</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  qFixed /= 2;</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  --m_RightShift;</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  }</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  BOOST_ASSERT(m_RightShift >= 0);</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  BOOST_ASSERT(qFixed <= std::numeric_limits<int32_t>::max());</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  m_Multiplier = <span class="keyword">static_cast<</span>int32_t<span class="keyword">></span>(qFixed);</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  }</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> }</div></div><!-- fragment --> |
| 125 | </div> |
| 126 | </div> |
| 127 | <h2 class="groupheader">Member Function Documentation</h2> |
| 128 | <a id="ac04834893e568dfea4642ecb575faed8"></a> |
| 129 | <h2 class="memtitle"><span class="permalink"><a href="#ac04834893e568dfea4642ecb575faed8">◆ </a></span>operator*()</h2> |
| 130 | |
| 131 | <div class="memitem"> |
| 132 | <div class="memproto"> |
| 133 | <table class="memname"> |
| 134 | <tr> |
| 135 | <td class="memname">int32_t operator* </td> |
| 136 | <td>(</td> |
| 137 | <td class="paramtype">int32_t </td> |
| 138 | <td class="paramname"><em>rhs</em></td><td>)</td> |
| 139 | <td> const</td> |
| 140 | </tr> |
| 141 | </table> |
| 142 | </div><div class="memdoc"> |
| 143 | |
| 144 | <p>The implementation of this function is adapted from Android NN's MultiplyByQuantizedMultiplierSmallerThanOne(). </p> |
| 145 | |
| 146 | <p class="definition">Definition at line <a class="el" href="_conv_impl_8cpp_source.html#l00041">41</a> of file <a class="el" href="_conv_impl_8cpp_source.html">ConvImpl.cpp</a>.</p> |
| 147 | <div class="fragment"><div class="line"><a name="l00042"></a><span class="lineno"> 42</span> {</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  int32_t x = SaturatingRoundingDoublingHighMul(rhs, m_Multiplier);</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <span class="keywordflow">return</span> RoundingDivideByPOT(x, m_RightShift);</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> }</div></div><!-- fragment --> |
| 148 | </div> |
| 149 | </div> |
| 150 | <hr/>The documentation for this struct was generated from the following files:<ul> |
| 151 | <li>src/backends/reference/workloads/<a class="el" href="_conv_impl_8hpp_source.html">ConvImpl.hpp</a></li> |
| 152 | <li>src/backends/reference/workloads/<a class="el" href="_conv_impl_8cpp_source.html">ConvImpl.cpp</a></li> |
| 153 | </ul> |
| 154 | </div><!-- contents --> |
| 155 | </div><!-- doc-content --> |
| 156 | <!-- start footer part --> |
| 157 | <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 158 | <ul> |
| 159 | <li class="navelem"><a class="el" href="namespacearmnn.html">armnn</a></li><li class="navelem"><a class="el" href="structarmnn_1_1_quantized_multiplier_smaller_than_one.html">QuantizedMultiplierSmallerThanOne</a></li> |
| 160 | <li class="footer">Generated on Fri Mar 13 2020 16:07:04 for ArmNN by |
| 161 | <a href="http://www.doxygen.org/index.html"> |
| 162 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li> |
| 163 | </ul> |
| 164 | </div> |
| 165 | </body> |
| 166 | </html> |