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: src/armnn/test/FloatingPointConverterTest.cpp File 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('_floating_point_converter_test_8cpp.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="#func-members">Functions</a> </div> |
| 85 | <div class="headertitle"> |
| 86 | <div class="title">FloatingPointConverterTest.cpp File Reference</div> </div> |
| 87 | </div><!--header--> |
| 88 | <div class="contents"> |
| 89 | <div class="textblock"><code>#include <<a class="el" href="_floating_point_converter_8hpp_source.html">armnnUtils/FloatingPointConverter.hpp</a>></code><br /> |
| 90 | <code>#include <<a class="el" href="_half_8hpp_source.html">Half.hpp</a>></code><br /> |
| 91 | <code>#include <boost/test/unit_test.hpp></code><br /> |
| 92 | </div> |
| 93 | <p><a href="_floating_point_converter_test_8cpp_source.html">Go to the source code of this file.</a></p> |
| 94 | <table class="memberdecls"> |
| 95 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> |
| 96 | Functions</h2></td></tr> |
| 97 | <tr class="memitem:a80857754f783d5daf4a6c7697196721a"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="_floating_point_converter_test_8cpp.html#a80857754f783d5daf4a6c7697196721a">BOOST_AUTO_TEST_CASE</a> (TestConvertFp32ToFp16)</td></tr> |
| 98 | <tr class="separator:a80857754f783d5daf4a6c7697196721a"><td class="memSeparator" colspan="2"> </td></tr> |
| 99 | <tr class="memitem:a534ea3f8521157f7920f99ebab136c78"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="_floating_point_converter_test_8cpp.html#a534ea3f8521157f7920f99ebab136c78">BOOST_AUTO_TEST_CASE</a> (TestConvertFp16ToFp32)</td></tr> |
| 100 | <tr class="separator:a534ea3f8521157f7920f99ebab136c78"><td class="memSeparator" colspan="2"> </td></tr> |
| 101 | </table> |
| 102 | <h2 class="groupheader">Function Documentation</h2> |
| 103 | <a id="a80857754f783d5daf4a6c7697196721a"></a> |
| 104 | <h2 class="memtitle"><span class="permalink"><a href="#a80857754f783d5daf4a6c7697196721a">◆ </a></span>BOOST_AUTO_TEST_CASE() <span class="overload">[1/2]</span></h2> |
| 105 | |
| 106 | <div class="memitem"> |
| 107 | <div class="memproto"> |
| 108 | <table class="memname"> |
| 109 | <tr> |
| 110 | <td class="memname">BOOST_AUTO_TEST_CASE </td> |
| 111 | <td>(</td> |
| 112 | <td class="paramtype">TestConvertFp32ToFp16 </td> |
| 113 | <td class="paramname"></td><td>)</td> |
| 114 | <td></td> |
| 115 | </tr> |
| 116 | </table> |
| 117 | </div><div class="memdoc"> |
| 118 | |
| 119 | <p class="definition">Definition at line <a class="el" href="_floating_point_converter_test_8cpp_source.html#l00014">14</a> of file <a class="el" href="_floating_point_converter_test_8cpp_source.html">FloatingPointConverterTest.cpp</a>.</p> |
| 120 | |
| 121 | <p class="reference">References <a class="el" href="_floating_point_converter_8cpp_source.html#l00015">FloatingPointConverter::ConvertFloat32To16()</a>.</p> |
| 122 | <div class="fragment"><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> {</div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span>  <span class="keyword">using namespace </span>half_float::literal;</div><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>  <span class="keywordtype">float</span> floatArray[] = { 1.0f, 2.0f, 0.5f, 3.1f, 2.4f,</div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  5.666f, 6.444f, 7.1f, 432.121f, 12.22f };</div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span>  <span class="keywordtype">size_t</span> numFloats = <span class="keyword">sizeof</span>(floatArray) / <span class="keyword">sizeof</span>(floatArray[0]);</div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>  std::vector<armnn::Half> convertedBuffer(numFloats, 0.0_h);</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> </div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>  <a class="code" href="classarmnn_utils_1_1_floating_point_converter.html#af0fdbfb53596052d571cb73899f9da2b">armnnUtils::FloatingPointConverter::ConvertFloat32To16</a>(floatArray, numFloats, convertedBuffer.data());</div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < numFloats; i++)</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>  {</div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  <a class="code" href="namespacearmnn.html#a0f38fa92b2468d5378258a2b074c1a31">armnn::Half</a> expected(floatArray[i]);</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>  <a class="code" href="namespacearmnn.html#a0f38fa92b2468d5378258a2b074c1a31">armnn::Half</a> actual = convertedBuffer[i];</div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  BOOST_CHECK_EQUAL(expected, actual);</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span> </div><div class="line"><a name="l00031"></a><span class="lineno"> 31</span>  <span class="keywordtype">float</span> convertedHalf = actual;</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  BOOST_CHECK_CLOSE(floatArray[i], convertedHalf, 0.07);</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  }</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span> }</div><div class="ttc" id="namespacearmnn_html_a0f38fa92b2468d5378258a2b074c1a31"><div class="ttname"><a href="namespacearmnn.html#a0f38fa92b2468d5378258a2b074c1a31">armnn::Half</a></div><div class="ttdeci">half_float::half Half</div><div class="ttdef"><b>Definition:</b> <a href="_half_8hpp_source.html#l00016">Half.hpp:16</a></div></div> |
| 123 | <div class="ttc" id="classarmnn_utils_1_1_floating_point_converter_html_af0fdbfb53596052d571cb73899f9da2b"><div class="ttname"><a href="classarmnn_utils_1_1_floating_point_converter.html#af0fdbfb53596052d571cb73899f9da2b">armnnUtils::FloatingPointConverter::ConvertFloat32To16</a></div><div class="ttdeci">static void ConvertFloat32To16(const float *srcFloat32Buffer, size_t numElements, void *dstFloat16Buffer)</div><div class="ttdef"><b>Definition:</b> <a href="_floating_point_converter_8cpp_source.html#l00015">FloatingPointConverter.cpp:15</a></div></div> |
| 124 | </div><!-- fragment --> |
| 125 | </div> |
| 126 | </div> |
| 127 | <a id="a534ea3f8521157f7920f99ebab136c78"></a> |
| 128 | <h2 class="memtitle"><span class="permalink"><a href="#a534ea3f8521157f7920f99ebab136c78">◆ </a></span>BOOST_AUTO_TEST_CASE() <span class="overload">[2/2]</span></h2> |
| 129 | |
| 130 | <div class="memitem"> |
| 131 | <div class="memproto"> |
| 132 | <table class="memname"> |
| 133 | <tr> |
| 134 | <td class="memname">BOOST_AUTO_TEST_CASE </td> |
| 135 | <td>(</td> |
| 136 | <td class="paramtype">TestConvertFp16ToFp32 </td> |
| 137 | <td class="paramname"></td><td>)</td> |
| 138 | <td></td> |
| 139 | </tr> |
| 140 | </table> |
| 141 | </div><div class="memdoc"> |
| 142 | |
| 143 | <p class="definition">Definition at line <a class="el" href="_floating_point_converter_test_8cpp_source.html#l00036">36</a> of file <a class="el" href="_floating_point_converter_test_8cpp_source.html">FloatingPointConverterTest.cpp</a>.</p> |
| 144 | |
| 145 | <p class="reference">References <a class="el" href="_profiler_tests_8cpp.html#af7f71af5c6c124222dd1c42c5df892f4">BOOST_AUTO_TEST_SUITE_END()</a>, and <a class="el" href="_floating_point_converter_8cpp_source.html#l00030">FloatingPointConverter::ConvertFloat16To32()</a>.</p> |
| 146 | <div class="fragment"><div class="line"><a name="l00037"></a><span class="lineno"> 37</span> {</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <span class="keyword">using namespace </span>half_float::literal;</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span> </div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <a class="code" href="namespacearmnn.html#a0f38fa92b2468d5378258a2b074c1a31">armnn::Half</a> halfArray[] = { 1.0_h, 2.0_h, 0.5_h, 3.1_h, 2.4_h,</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  5.666_h, 6.444_h, 7.1_h, 432.121_h, 12.22_h };</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keywordtype">size_t</span> numFloats = <span class="keyword">sizeof</span>(halfArray) / <span class="keyword">sizeof</span>(halfArray[0]);</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  std::vector<float> convertedBuffer(numFloats, 0.0f);</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span> </div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <a class="code" href="classarmnn_utils_1_1_floating_point_converter.html#ac1f1568f02163a68906a0030e0ba9871">armnnUtils::FloatingPointConverter::ConvertFloat16To32</a>(halfArray, numFloats, convertedBuffer.data());</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span> </div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  <span class="keywordflow">for</span> (<span class="keywordtype">size_t</span> i = 0; i < numFloats; i++)</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  {</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keywordtype">float</span> expected(halfArray[i]);</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  <span class="keywordtype">float</span> actual = convertedBuffer[i];</div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  BOOST_CHECK_EQUAL(expected, actual);</div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  }</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span> }</div><div class="ttc" id="namespacearmnn_html_a0f38fa92b2468d5378258a2b074c1a31"><div class="ttname"><a href="namespacearmnn.html#a0f38fa92b2468d5378258a2b074c1a31">armnn::Half</a></div><div class="ttdeci">half_float::half Half</div><div class="ttdef"><b>Definition:</b> <a href="_half_8hpp_source.html#l00016">Half.hpp:16</a></div></div> |
| 147 | <div class="ttc" id="classarmnn_utils_1_1_floating_point_converter_html_ac1f1568f02163a68906a0030e0ba9871"><div class="ttname"><a href="classarmnn_utils_1_1_floating_point_converter.html#ac1f1568f02163a68906a0030e0ba9871">armnnUtils::FloatingPointConverter::ConvertFloat16To32</a></div><div class="ttdeci">static void ConvertFloat16To32(const void *srcFloat16Buffer, size_t numElements, float *dstFloat32Buffer)</div><div class="ttdef"><b>Definition:</b> <a href="_floating_point_converter_8cpp_source.html#l00030">FloatingPointConverter.cpp:30</a></div></div> |
| 148 | </div><!-- fragment --> |
| 149 | </div> |
| 150 | </div> |
| 151 | </div><!-- contents --> |
| 152 | </div><!-- doc-content --> |
| 153 | <!-- start footer part --> |
| 154 | <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 155 | <ul> |
| 156 | <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_e0a84d05c80a2ef4231141dcbbeac5c8.html">armnn</a></li><li class="navelem"><a class="el" href="dir_9d86fd1fbecbedf5bdb69c7e7235fe5f.html">test</a></li><li class="navelem"><a class="el" href="_floating_point_converter_test_8cpp.html">FloatingPointConverterTest.cpp</a></li> |
| 157 | <li class="footer">Generated on Fri Mar 13 2020 16:06:59 for ArmNN by |
| 158 | <a href="http://www.doxygen.org/index.html"> |
| 159 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li> |
| 160 | </ul> |
| 161 | </div> |
| 162 | </body> |
| 163 | </html> |