Ryan OShea | de36e4a | 2020-03-13 16:26:19 +0000 | [diff] [blame] | 1 | <!-- Copyright (c) 2020 ARM Limited. --> |
| 2 | <!-- --> |
| 3 | <!-- SPDX-License-Identifier: MIT --> |
| 4 | <!-- --> |
| 5 | <!-- HTML header for doxygen 1.8.13--> |
| 6 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 7 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 8 | <head> |
| 9 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 10 | <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| 11 | <meta name="generator" content="Doxygen 1.8.13"/> |
| 12 | <meta name="robots" content="NOINDEX, NOFOLLOW" /> |
| 13 | <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 14 | <title>ArmNN: OptimizeConsecutiveReshapesImpl Class Reference</title> |
| 15 | <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 16 | <script type="text/javascript" src="jquery.js"></script> |
| 17 | <script type="text/javascript" src="dynsections.js"></script> |
| 18 | <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| 19 | <script type="text/javascript" src="resize.js"></script> |
| 20 | <script type="text/javascript" src="navtreedata.js"></script> |
| 21 | <script type="text/javascript" src="navtree.js"></script> |
| 22 | <script type="text/javascript"> |
| 23 | $(document).ready(initResizable); |
| 24 | </script> |
| 25 | <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| 26 | <script type="text/javascript" src="search/searchdata.js"></script> |
| 27 | <script type="text/javascript" src="search/search.js"></script> |
| 28 | <script type="text/x-mathjax-config"> |
| 29 | MathJax.Hub.Config({ |
| 30 | extensions: ["tex2jax.js"], |
| 31 | jax: ["input/TeX","output/HTML-CSS"], |
| 32 | }); |
| 33 | </script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> |
| 34 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 35 | <link href="stylesheet.css" rel="stylesheet" type="text/css"/> |
| 36 | </head> |
| 37 | <body> |
| 38 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 39 | <div id="titlearea"> |
| 40 | <table cellspacing="0" cellpadding="0"> |
| 41 | <tbody> |
| 42 | <tr style="height: 56px;"> |
| 43 | <img alt="ArmNN" src="Arm_NN_horizontal_blue.png" style="max-width: 10rem; margin-top: .5rem; margin-left 10px"/> |
| 44 | <td style="padding-left: 0.5em;"> |
| 45 | <div id="projectname"> |
| 46 |  <span id="projectnumber">20.02</span> |
| 47 | </div> |
| 48 | </td> |
| 49 | </tr> |
| 50 | </tbody> |
| 51 | </table> |
| 52 | </div> |
| 53 | <!-- end header part --> |
| 54 | <!-- Generated by Doxygen 1.8.13 --> |
| 55 | <script type="text/javascript"> |
| 56 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| 57 | </script> |
| 58 | <script type="text/javascript" src="menudata.js"></script> |
| 59 | <script type="text/javascript" src="menu.js"></script> |
| 60 | <script type="text/javascript"> |
| 61 | $(function() { |
| 62 | initMenu('',true,false,'search.php','Search'); |
| 63 | $(document).ready(function() { init_search(); }); |
| 64 | }); |
| 65 | </script> |
| 66 | <div id="main-nav"></div> |
| 67 | </div><!-- top --> |
| 68 | <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| 69 | <div id="nav-tree"> |
| 70 | <div id="nav-tree-contents"> |
| 71 | <div id="nav-sync" class="sync"></div> |
| 72 | </div> |
| 73 | </div> |
| 74 | <div id="splitbar" style="-moz-user-select:none;" |
| 75 | class="ui-resizable-handle"> |
| 76 | </div> |
| 77 | </div> |
| 78 | <script type="text/javascript"> |
| 79 | $(document).ready(function(){initNavTree('classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml','');}); |
| 80 | </script> |
| 81 | <div id="doc-content"> |
| 82 | <!-- window showing the filter options --> |
| 83 | <div id="MSearchSelectWindow" |
| 84 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 85 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 86 | onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| 87 | </div> |
| 88 | |
| 89 | <!-- iframe showing the search results (closed by default) --> |
| 90 | <div id="MSearchResultsWindow"> |
| 91 | <iframe src="javascript:void(0)" frameborder="0" |
| 92 | name="MSearchResults" id="MSearchResults"> |
| 93 | </iframe> |
| 94 | </div> |
| 95 | |
| 96 | <div class="header"> |
| 97 | <div class="summary"> |
| 98 | <a href="#pub-methods">Public Member Functions</a> | |
| 99 | <a href="#pro-methods">Protected Member Functions</a> | |
| 100 | <a href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl-members.xhtml">List of all members</a> </div> |
| 101 | <div class="headertitle"> |
| 102 | <div class="title">OptimizeConsecutiveReshapesImpl Class Reference</div> </div> |
| 103 | </div><!--header--> |
| 104 | <div class="contents"> |
| 105 | |
| 106 | <p><code>#include <<a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml">OptimizeConsecutiveReshapes.hpp</a>></code></p> |
| 107 | <table class="memberdecls"> |
| 108 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a> |
| 109 | Public Member Functions</h2></td></tr> |
| 110 | <tr class="memitem:a5a8476ffc04ce7460bb09ad50d1d23de"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml#a5a8476ffc04ce7460bb09ad50d1d23de">Run</a> (<a class="el" href="classarmnn_1_1_graph.xhtml">Graph</a> &graph, <a class="el" href="classarmnn_1_1_input_slot.xhtml">InputSlot</a> &connection) const</td></tr> |
| 111 | <tr class="memdesc:a5a8476ffc04ce7460bb09ad50d1d23de"><td class="mdescLeft"> </td><td class="mdescRight">Run for every connection between a base <a class="el" href="classarmnn_1_1_reshape_layer.xhtml" title="This layer represents a reshape operation. ">ReshapeLayer</a> and a child <a class="el" href="classarmnn_1_1_reshape_layer.xhtml" title="This layer represents a reshape operation. ">ReshapeLayer</a>. <a href="#a5a8476ffc04ce7460bb09ad50d1d23de">More...</a><br /></td></tr> |
| 112 | <tr class="separator:a5a8476ffc04ce7460bb09ad50d1d23de"><td class="memSeparator" colspan="2"> </td></tr> |
| 113 | </table><table class="memberdecls"> |
| 114 | <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a> |
| 115 | Protected Member Functions</h2></td></tr> |
| 116 | <tr class="memitem:ae344e9caa07713681429bd8eea772ebf"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml#ae344e9caa07713681429bd8eea772ebf">OptimizeConsecutiveReshapesImpl</a> ()=default</td></tr> |
| 117 | <tr class="separator:ae344e9caa07713681429bd8eea772ebf"><td class="memSeparator" colspan="2"> </td></tr> |
| 118 | <tr class="memitem:accd18a7450d91508ab6e12379507e01d"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml#accd18a7450d91508ab6e12379507e01d">~OptimizeConsecutiveReshapesImpl</a> ()=default</td></tr> |
| 119 | <tr class="separator:accd18a7450d91508ab6e12379507e01d"><td class="memSeparator" colspan="2"> </td></tr> |
| 120 | </table> |
| 121 | <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> |
| 122 | <div class="textblock"> |
| 123 | <p class="definition">Definition at line <a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml#l00014">14</a> of file <a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml">OptimizeConsecutiveReshapes.hpp</a>.</p> |
| 124 | </div><h2 class="groupheader">Constructor & Destructor Documentation</h2> |
| 125 | <a id="ae344e9caa07713681429bd8eea772ebf"></a> |
| 126 | <h2 class="memtitle"><span class="permalink"><a href="#ae344e9caa07713681429bd8eea772ebf">◆ </a></span>OptimizeConsecutiveReshapesImpl()</h2> |
| 127 | |
| 128 | <div class="memitem"> |
| 129 | <div class="memproto"> |
| 130 | <table class="mlabels"> |
| 131 | <tr> |
| 132 | <td class="mlabels-left"> |
| 133 | <table class="memname"> |
| 134 | <tr> |
| 135 | <td class="memname"><a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml">OptimizeConsecutiveReshapesImpl</a> </td> |
| 136 | <td>(</td> |
| 137 | <td class="paramname"></td><td>)</td> |
| 138 | <td></td> |
| 139 | </tr> |
| 140 | </table> |
| 141 | </td> |
| 142 | <td class="mlabels-right"> |
| 143 | <span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">default</span></span> </td> |
| 144 | </tr> |
| 145 | </table> |
| 146 | </div><div class="memdoc"> |
| 147 | |
| 148 | <p class="reference">Referenced by <a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml#l00019">OptimizeConsecutiveReshapesImpl::Run()</a>.</p> |
| 149 | |
| 150 | </div> |
| 151 | </div> |
| 152 | <a id="accd18a7450d91508ab6e12379507e01d"></a> |
| 153 | <h2 class="memtitle"><span class="permalink"><a href="#accd18a7450d91508ab6e12379507e01d">◆ </a></span>~OptimizeConsecutiveReshapesImpl()</h2> |
| 154 | |
| 155 | <div class="memitem"> |
| 156 | <div class="memproto"> |
| 157 | <table class="mlabels"> |
| 158 | <tr> |
| 159 | <td class="mlabels-left"> |
| 160 | <table class="memname"> |
| 161 | <tr> |
| 162 | <td class="memname">~<a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml">OptimizeConsecutiveReshapesImpl</a> </td> |
| 163 | <td>(</td> |
| 164 | <td class="paramname"></td><td>)</td> |
| 165 | <td></td> |
| 166 | </tr> |
| 167 | </table> |
| 168 | </td> |
| 169 | <td class="mlabels-right"> |
| 170 | <span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">default</span></span> </td> |
| 171 | </tr> |
| 172 | </table> |
| 173 | </div><div class="memdoc"> |
| 174 | |
| 175 | <p class="reference">Referenced by <a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml#l00019">OptimizeConsecutiveReshapesImpl::Run()</a>.</p> |
| 176 | |
| 177 | </div> |
| 178 | </div> |
| 179 | <h2 class="groupheader">Member Function Documentation</h2> |
| 180 | <a id="a5a8476ffc04ce7460bb09ad50d1d23de"></a> |
| 181 | <h2 class="memtitle"><span class="permalink"><a href="#a5a8476ffc04ce7460bb09ad50d1d23de">◆ </a></span>Run()</h2> |
| 182 | |
| 183 | <div class="memitem"> |
| 184 | <div class="memproto"> |
| 185 | <table class="mlabels"> |
| 186 | <tr> |
| 187 | <td class="mlabels-left"> |
| 188 | <table class="memname"> |
| 189 | <tr> |
| 190 | <td class="memname">void Run </td> |
| 191 | <td>(</td> |
| 192 | <td class="paramtype"><a class="el" href="classarmnn_1_1_graph.xhtml">Graph</a> & </td> |
| 193 | <td class="paramname"><em>graph</em>, </td> |
| 194 | </tr> |
| 195 | <tr> |
| 196 | <td class="paramkey"></td> |
| 197 | <td></td> |
| 198 | <td class="paramtype"><a class="el" href="classarmnn_1_1_input_slot.xhtml">InputSlot</a> & </td> |
| 199 | <td class="paramname"><em>connection</em> </td> |
| 200 | </tr> |
| 201 | <tr> |
| 202 | <td></td> |
| 203 | <td>)</td> |
| 204 | <td></td><td> const</td> |
| 205 | </tr> |
| 206 | </table> |
| 207 | </td> |
| 208 | <td class="mlabels-right"> |
| 209 | <span class="mlabels"><span class="mlabel">inline</span></span> </td> |
| 210 | </tr> |
| 211 | </table> |
| 212 | </div><div class="memdoc"> |
| 213 | |
| 214 | <p>Run for every connection between a base <a class="el" href="classarmnn_1_1_reshape_layer.xhtml" title="This layer represents a reshape operation. ">ReshapeLayer</a> and a child <a class="el" href="classarmnn_1_1_reshape_layer.xhtml" title="This layer represents a reshape operation. ">ReshapeLayer</a>. </p> |
| 215 | <p>Inserts an equivalent <a class="el" href="classarmnn_1_1_reshape_layer.xhtml" title="This layer represents a reshape operation. ">ReshapeLayer</a> that bypasses both for that connection. </p> |
| 216 | |
| 217 | <p class="definition">Definition at line <a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml#l00019">19</a> of file <a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml">OptimizeConsecutiveReshapes.hpp</a>.</p> |
| 218 | |
| 219 | <p class="reference">References <a class="el" href="_layer_8hpp_source.xhtml#l00055">InputSlot::GetConnectedOutputSlot()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00310">Layer::GetInputSlot()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00305">Layer::GetName()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00138">OutputSlot::GetNumConnections()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00221">Layer::GetOutputHandler()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00312">Layer::GetOutputSlot()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00052">InputSlot::GetOwningLayer()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00115">OutputSlot::GetOwningLayer()</a>, <a class="el" href="_tensor_8hpp_source.xhtml#l00088">TensorInfo::GetShape()</a>, <a class="el" href="_output_handler_8hpp_source.xhtml#l00044">OutputHandler::GetTensorInfo()</a>, <a class="el" href="_layer_8hpp_source.xhtml#l00259">Layer::GetType()</a>, <a class="el" href="_graph_8hpp_source.xhtml#l00409">Graph::InsertNewLayer()</a>, <a class="el" href="_layer_8cpp_source.xhtml#l00112">OutputSlot::MoveAllConnections()</a>, <a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml#ae344e9caa07713681429bd8eea772ebf">OptimizeConsecutiveReshapesImpl::OptimizeConsecutiveReshapesImpl()</a>, <a class="el" href="namespacearmnn.xhtml#a56943a0946e5f15e5e58054b8e7a04a4aa7c59ccedc6a3bd90c17f3b990afefad">armnn::Reshape</a>, <a class="el" href="_output_handler_8cpp_source.xhtml#l00017">OutputHandler::SetTensorInfo()</a>, and <a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml#accd18a7450d91508ab6e12379507e01d">OptimizeConsecutiveReshapesImpl::~OptimizeConsecutiveReshapesImpl()</a>.</p> |
| 220 | <div class="fragment"><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>  Layer& base = connection.GetConnectedOutputSlot()->GetOwningLayer();</div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span>  Layer& child = connection.GetOwningLayer();</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>  BOOST_ASSERT(base.GetType() == <a class="code" href="namespacearmnn.xhtml#a56943a0946e5f15e5e58054b8e7a04a4aa7c59ccedc6a3bd90c17f3b990afefad">LayerType::Reshape</a>);</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>  BOOST_ASSERT(child.GetType() == <a class="code" href="namespacearmnn.xhtml#a56943a0946e5f15e5e58054b8e7a04a4aa7c59ccedc6a3bd90c17f3b990afefad">LayerType::Reshape</a>);</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>  OutputSlot* parentOut = base.GetInputSlot(0).GetConnectedOutputSlot();</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> </div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  <span class="keyword">const</span> TensorInfo& inInfo = parentOut->GetTensorInfo();</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>  <span class="keyword">const</span> TensorInfo& outInfo = child.GetOutputHandler().GetTensorInfo();</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>  <span class="comment">// This Optimization is only appropriate when the base ReshapeLayer is connected to the child ReshapeLayer</span></div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>  <span class="comment">// and no other Layer.</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  <span class="keywordflow">if</span> (base.GetOutputSlot(0).GetNumConnections() > 1)</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>  {</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keywordflow">return</span>;</div><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> </div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  <span class="keywordflow">if</span> (inInfo.GetShape() != outInfo.GetShape())</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  {</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  <span class="comment">// Inserts equivalent reshape before base layer.</span></div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  <span class="keyword">const</span> std::string name = std::string(<span class="stringliteral">"merged-"</span>) + base.GetName() + std::string(<span class="stringliteral">"-with-"</span>) + child.GetName();</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  <span class="keyword">const</span> ReshapeDescriptor descriptor{outInfo.GetShape()};</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>  <span class="keyword">auto</span>& newReshape = *graph.InsertNewLayer<ReshapeLayer>(base.GetInputSlot(0), descriptor, name.c_str());</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span> </div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  <span class="comment">// Sets tensor info for new layer.</span></div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  newReshape.GetOutputHandler().SetTensorInfo(outInfo);</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  <span class="comment">// Parent is now the new layer.</span></div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  parentOut = &newReshape.GetOutputSlot();</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  }</div><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="comment">// Moves connections in child output to parent layer.</span></div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  <span class="comment">// Child layer will be removed as it's left unconnected.</span></div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  <span class="comment">// Base layer will be removed if left unconnected.</span></div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  child.GetOutputSlot().MoveAllConnections(*parentOut);</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  }</div><div class="ttc" id="namespacearmnn_xhtml_a56943a0946e5f15e5e58054b8e7a04a4aa7c59ccedc6a3bd90c17f3b990afefad"><div class="ttname"><a href="namespacearmnn.xhtml#a56943a0946e5f15e5e58054b8e7a04a4aa7c59ccedc6a3bd90c17f3b990afefad">armnn::LayerType::Reshape</a></div></div> |
| 221 | </div><!-- fragment --> |
| 222 | </div> |
| 223 | </div> |
| 224 | <hr/>The documentation for this class was generated from the following file:<ul> |
| 225 | <li>src/armnn/optimizations/<a class="el" href="_optimize_consecutive_reshapes_8hpp_source.xhtml">OptimizeConsecutiveReshapes.hpp</a></li> |
| 226 | </ul> |
| 227 | </div><!-- contents --> |
| 228 | </div><!-- doc-content --> |
| 229 | <!-- start footer part --> |
| 230 | <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 231 | <ul> |
| 232 | <li class="navelem"><a class="el" href="namespacearmnn.xhtml">armnn</a></li><li class="navelem"><a class="el" href="namespacearmnn_1_1optimizations.xhtml">optimizations</a></li><li class="navelem"><a class="el" href="classarmnn_1_1optimizations_1_1_optimize_consecutive_reshapes_impl.xhtml">OptimizeConsecutiveReshapesImpl</a></li> |
| 233 | <li class="footer">Generated on Fri Mar 13 2020 16:09:20 for ArmNN by |
| 234 | <a href="http://www.doxygen.org/index.html"> |
| 235 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li> |
| 236 | </ul> |
| 237 | </div> |
| 238 | </body> |
| 239 | </html> |