Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 1 | <!-- HTML header for doxygen 1.8.9.1--> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| 6 | <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 7 | <meta name="generator" content="Doxygen 1.8.11"/> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 8 | <meta name="robots" content="NOINDEX, NOFOLLOW" /> <!-- Prevent indexing by search engines --> |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 9 | <title>Compute Library: src/core/CL/cl_kernels/convolution_layer.cl Source File</title> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 10 | <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| 11 | <script type="text/javascript" src="jquery.js"></script> |
| 12 | <script type="text/javascript" src="dynsections.js"></script> |
| 13 | <link href="navtree.css" rel="stylesheet" type="text/css"/> |
| 14 | <script type="text/javascript" src="resize.js"></script> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 15 | <script type="text/javascript" src="navtreedata.js"></script> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 16 | <script type="text/javascript" src="navtree.js"></script> |
| 17 | <script type="text/javascript"> |
| 18 | $(document).ready(initResizable); |
| 19 | $(window).load(resizeHeight); |
| 20 | </script> |
| 21 | <link href="search/search.css" rel="stylesheet" type="text/css"/> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 22 | <script type="text/javascript" src="search/searchdata.js"></script> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 23 | <script type="text/javascript" src="search/search.js"></script> |
| 24 | <script type="text/javascript"> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 25 | $(document).ready(function() { init_search(); }); |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 26 | </script> |
| 27 | <script type="text/x-mathjax-config"> |
| 28 | MathJax.Hub.Config({ |
| 29 | extensions: ["tex2jax.js"], |
| 30 | jax: ["input/TeX","output/HTML-CSS"], |
| 31 | }); |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 32 | </script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 33 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| 34 | </head> |
| 35 | <body> |
| 36 | <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| 37 | <div id="titlearea"> |
| 38 | <table cellspacing="0" cellpadding="0"> |
| 39 | <tbody> |
| 40 | <tr style="height: 56px;"> |
| 41 | <td style="padding-left: 0.5em;"> |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 42 | <div id="projectname">Compute Library |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 43 |  <span id="projectnumber">17.12</span> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 44 | </div> |
| 45 | </td> |
| 46 | </tr> |
| 47 | </tbody> |
| 48 | </table> |
| 49 | </div> |
| 50 | <!-- end header part --> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 51 | <!-- Generated by Doxygen 1.8.11 --> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 52 | <script type="text/javascript"> |
| 53 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| 54 | </script> |
| 55 | <div id="navrow1" class="tabs"> |
| 56 | <ul class="tablist"> |
| 57 | <li><a href="index.xhtml"><span>Main Page</span></a></li> |
Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 58 | <li><a href="pages.xhtml"><span>Related Pages</span></a></li> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 59 | <li><a href="namespaces.xhtml"><span>Namespaces</span></a></li> |
| 60 | <li><a href="annotated.xhtml"><span>Data Structures</span></a></li> |
| 61 | <li class="current"><a href="files.xhtml"><span>Files</span></a></li> |
| 62 | <li> |
| 63 | <div id="MSearchBox" class="MSearchBoxInactive"> |
| 64 | <span class="left"> |
| 65 | <img id="MSearchSelect" src="search/mag_sel.png" |
| 66 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 67 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 68 | alt=""/> |
| 69 | <input type="text" id="MSearchField" value="Search" accesskey="S" |
| 70 | onfocus="searchBox.OnSearchFieldFocus(true)" |
| 71 | onblur="searchBox.OnSearchFieldFocus(false)" |
| 72 | onkeyup="searchBox.OnSearchFieldChange(event)"/> |
| 73 | </span><span class="right"> |
| 74 | <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> |
| 75 | </span> |
| 76 | </div> |
| 77 | </li> |
| 78 | </ul> |
| 79 | </div> |
| 80 | <div id="navrow2" class="tabs2"> |
| 81 | <ul class="tablist"> |
| 82 | <li><a href="files.xhtml"><span>File List</span></a></li> |
| 83 | <li><a href="globals.xhtml"><span>Globals</span></a></li> |
| 84 | </ul> |
| 85 | </div> |
| 86 | </div><!-- top --> |
| 87 | <div id="side-nav" class="ui-resizable side-nav-resizable"> |
| 88 | <div id="nav-tree"> |
| 89 | <div id="nav-tree-contents"> |
| 90 | <div id="nav-sync" class="sync"></div> |
| 91 | </div> |
| 92 | </div> |
| 93 | <div id="splitbar" style="-moz-user-select:none;" |
| 94 | class="ui-resizable-handle"> |
| 95 | </div> |
| 96 | </div> |
| 97 | <script type="text/javascript"> |
| 98 | $(document).ready(function(){initNavTree('convolution__layer_8cl_source.xhtml','');}); |
| 99 | </script> |
| 100 | <div id="doc-content"> |
| 101 | <!-- window showing the filter options --> |
| 102 | <div id="MSearchSelectWindow" |
| 103 | onmouseover="return searchBox.OnSearchSelectShow()" |
| 104 | onmouseout="return searchBox.OnSearchSelectHide()" |
| 105 | onkeydown="return searchBox.OnSearchSelectKey(event)"> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 106 | </div> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 107 | |
| 108 | <!-- iframe showing the search results (closed by default) --> |
| 109 | <div id="MSearchResultsWindow"> |
| 110 | <iframe src="javascript:void(0)" frameborder="0" |
| 111 | name="MSearchResults" id="MSearchResults"> |
| 112 | </iframe> |
| 113 | </div> |
| 114 | |
| 115 | <div class="header"> |
| 116 | <div class="headertitle"> |
| 117 | <div class="title">convolution_layer.cl</div> </div> |
| 118 | </div><!--header--> |
| 119 | <div class="contents"> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 120 | <a href="convolution__layer_8cl.xhtml">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Copyright (c) 2017 ARM Limited.</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * SPDX-License-Identifier: MIT</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> *</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * Permission is hereby granted, free of charge, to any person obtaining a copy</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * of this software and associated documentation files (the "Software"), to</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * deal in the Software without restriction, including without limitation the</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> * sell copies of the Software, and to permit persons to whom the Software is</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * furnished to do so, subject to the following conditions:</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> *</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * The above copyright notice and this permission notice shall be included in all</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * copies or substantial portions of the Software.</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> *</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> <span class="comment"> * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span></div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="comment"> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="comment"> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="comment"> * SOFTWARE.</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="comment"> */</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> <span class="preprocessor">#include "<a class="code" href="helpers_8h.xhtml">helpers.h</a>"</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="preprocessor">#if defined(FIXED_POINT_POSITION)</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span> <span class="preprocessor">#include "<a class="code" href="fixed__point_8h.xhtml">fixed_point.h</a>"</span></div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor">#endif // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span> </div><div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="convolution__layer_8cl.xhtml#ab6358b28d1e7bc946950075d94412013"> 57</a></span> __kernel <span class="keywordtype">void</span> <a class="code" href="convolution__layer_8cl.xhtml#ab6358b28d1e7bc946950075d94412013">reshape_to_columns</a>(</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(src),</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  <a class="code" href="helpers_8h.xhtml#a22f42fcf2077d951271df83b55c1a71a">IMAGE_DECLARATION</a>(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>),</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span> #ifdef HAS_BIAS</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <a class="code" href="helpers_8h.xhtml#a40a6eb9f2a7712f08d6bb8ff6c9e6ca7">VECTOR_DECLARATION</a>(bias),</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> #endif <span class="comment">/* HAS_BIAS */</span></div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  uint width, uint height, uint depth, uint total_filters)</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span> {</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  <a class="code" href="struct_tensor3_d.xhtml">Tensor3D</a> src = <a class="code" href="helpers_8h.xhtml#a31c8c760f08fb1a331b16b7c204321dc">CONVERT_TO_TENSOR3D_STRUCT</a>(src);</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  <span class="keywordtype">bool</span> is_last_thread = (get_global_id(0) == (get_global_size(0) - 1) && get_global_id(1) == (get_global_size(1) - 1) && get_global_id(2) == (get_global_size(2) - 1));</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span> </div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>  __global uchar *tmp_src_ptr = src.<a class="code" href="struct_tensor3_d.xhtml#acf52c23cbd7424606c10a606524e3e32">ptr</a>;</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  __global uchar *tmp_dst_ptr = dst_ptr + dst_offset_first_element_in_bytes + get_global_id(0) * dst_stride_y + get_global_id(1) * width * dst_stride_y + get_global_id(</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  2) * width * height * dst_stride_y;</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span> <span class="preprocessor">#ifdef HAS_BIAS</span></div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  __global uchar *tmp_bias_ptr = bias_ptr + bias_offset_first_element_in_bytes;</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span> <span class="preprocessor">#endif </span><span class="comment">/* HAS_BIAS */</span><span class="preprocessor"></span></div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span> </div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordflow">if</span>(is_last_thread)</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  {</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <span class="keywordflow">for</span>(uint i = 0; i < total_filters; ++i)</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  {</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_dst_ptr) = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_src_ptr);</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span> </div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span> <span class="preprocessor">#ifdef HAS_BIAS</span></div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(tmp_dst_ptr + dst_stride_y)) = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(tmp_bias_ptr));</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  tmp_bias_ptr += bias_stride_x;</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span> <span class="preprocessor">#endif </span><span class="comment">/* HAS_BIAS */</span><span class="preprocessor"></span></div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  tmp_src_ptr += depth * src_stride_z;</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  tmp_dst_ptr += dst_stride_x;</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  }</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  }</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  <span class="keywordflow">else</span></div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  {</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <span class="keywordflow">for</span>(uint i = 0; i < total_filters; ++i)</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  {</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_dst_ptr) = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_src_ptr);</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  tmp_src_ptr += depth * src_stride_z;</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  tmp_dst_ptr += dst_stride_x;</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  }</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  }</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span> }</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span> </div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span> <span class="preprocessor">#if defined(CONVOLVED_WIDTH) && defined(STRIDE_X) && defined(STRIDE_Y) && defined(PAD_LEFT) && defined(PAD_TOP) && defined(PAD_RIGHT) && defined(PAD_BOTTOM) && defined(KERNEL_WIDTH) && defined(KERNEL_HEIGHT) && defined(KERNEL_DEPTH) && defined(SRC_WIDTH) && defined(SRC_HEIGHT) && defined(PAD_VALUE)</span></div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span> </div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span> __kernel <span class="keywordtype">void</span> im2col_generic(</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(src),</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <a class="code" href="helpers_8h.xhtml#a22f42fcf2077d951271df83b55c1a71a">IMAGE_DECLARATION</a>(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>),</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  uint src_stride_w,</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  uint dst_stride_w)</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span> {</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xc = get_global_id(0); <span class="comment">// x coordinate in the convolved tensor</span></div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yc = get_global_id(1); <span class="comment">// y coordinate in the convolved tensor</span></div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> ch = get_global_id(2) % KERNEL_DEPTH; <span class="comment">// input feature map</span></div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> batch = get_global_id(2) / KERNEL_DEPTH; <span class="comment">// batch size</span></div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span> </div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="comment">// Calculate input indices</span></div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xc * STRIDE_X - PAD_LEFT;</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yc * STRIDE_Y - PAD_TOP;</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span> </div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="comment">// Calculate output indices</span></div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xo = ch * KERNEL_WIDTH * KERNEL_HEIGHT;</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yo = xc + yc * CONVOLVED_WIDTH; <span class="comment">// Index of the convolution</span></div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span> </div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  __global uchar *input_ptr = src_ptr + src_offset_first_element_in_bytes + ch * src_stride_z + batch * src_stride_w;</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  __global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *output_ptr = ((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(dst_ptr + dst_offset_first_element_in_bytes + yo * dst_stride_y + batch * dst_stride_w)) + xo;</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span> </div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="comment">// Linearize convolution elements</span></div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="keywordflow">for</span>(<span class="keywordtype">int</span> y = yi, y_e = yi + KERNEL_HEIGHT; y < y_e; ++y)</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">for</span>(<span class="keywordtype">int</span> x = xi, x_e = xi + KERNEL_WIDTH; x < x_e; ++x, ++output_ptr)</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="preprocessor">#if PAD_LEFT == 0 && PAD_TOP == 0 && PAD_RIGHT == 0 && PAD_BOTTOM == 0</span></div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  *output_ptr = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + x * src_stride_x + y * src_stride_y));</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span> <span class="preprocessor">#else // PAD_LEFT == 0 && PAD_TOP == 0 && PAD_RIGHT == 0 && PAD_BOTTOM == 0</span></div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  <span class="keywordflow">if</span>(x < 0 || x >= SRC_WIDTH || y < 0 || y >= SRC_HEIGHT)</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  {</div><div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  *output_ptr = PAD_VALUE;</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>  <span class="keywordflow">else</span></div><div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  {</div><div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  *output_ptr = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + x * src_stride_x + y * src_stride_y));</div><div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  }</div><div class="line"><a name="l00162"></a><span class="lineno"> 162</span> <span class="preprocessor">#endif // PAD_LEFT == 0 && PAD_TOP == 0 && PAD_RIGHT == 0 && PAD_BOTTOM == 0</span></div><div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  }</div><div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  }</div><div class="line"><a name="l00165"></a><span class="lineno"> 165</span> </div><div class="line"><a name="l00166"></a><span class="lineno"> 166</span> <span class="preprocessor">#ifdef HAS_BIAS</span></div><div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  <span class="keywordflow">if</span>(ch == (KERNEL_DEPTH - 1))</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  {</div><div class="line"><a name="l00169"></a><span class="lineno"> 169</span> <span class="preprocessor">#ifdef FIXED_POINT_POSITION</span></div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  *output_ptr = (<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>)(1 << FIXED_POINT_POSITION);</div><div class="line"><a name="l00171"></a><span class="lineno"> 171</span> <span class="preprocessor">#else // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  *output_ptr = 1.0f;</div><div class="line"><a name="l00173"></a><span class="lineno"> 173</span> <span class="preprocessor">#endif // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  }</div><div class="line"><a name="l00175"></a><span class="lineno"> 175</span> <span class="preprocessor">#endif // HAS_BIAS</span></div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span> }</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span> </div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span> __kernel <span class="keywordtype">void</span> im2col_kernel3x3_padx0_pady0(</div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(src),</div><div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  <a class="code" href="helpers_8h.xhtml#a22f42fcf2077d951271df83b55c1a71a">IMAGE_DECLARATION</a>(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>),</div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  uint src_stride_w,</div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  uint dst_stride_w)</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span> {</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xc = get_global_id(0); <span class="comment">// x coordinate in the convolved tensor</span></div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yc = get_global_id(1); <span class="comment">// y coordinate in the convolved tensor</span></div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> ch = get_global_id(2) % KERNEL_DEPTH; <span class="comment">// input feature map</span></div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> batch = get_global_id(2) / KERNEL_DEPTH; <span class="comment">// batch size</span></div><div class="line"><a name="l00210"></a><span class="lineno"> 210</span> </div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <span class="comment">// Calculate input indices</span></div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xc * STRIDE_X;</div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yc * STRIDE_Y;</div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span> </div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  <span class="comment">// Calculate output indices</span></div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xo = ch * KERNEL_WIDTH * KERNEL_HEIGHT;</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yo = xc + yc * CONVOLVED_WIDTH; <span class="comment">// Index of the convolution</span></div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span> </div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  <span class="comment">// Get input and output address</span></div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  __global uchar *input_ptr = src_ptr + src_offset_first_element_in_bytes + xi * src_stride_x + yi * src_stride_y + ch * src_stride_z + batch * src_stride_w;</div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span> </div><div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  __global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *output_ptr = (__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(dst_ptr + dst_offset_first_element_in_bytes + yo * dst_stride_y + batch * dst_stride_w) + xo;</div><div class="line"><a name="l00223"></a><span class="lineno"> 223</span> </div><div class="line"><a name="l00224"></a><span class="lineno"> 224</span>  <a class="code" href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a>(<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>, 3)</div><div class="line"><a name="l00225"></a><span class="lineno"> 225</span>  row0 = vload3(0, (__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + 0 * src_stride_y));</div><div class="line"><a name="l00226"></a><span class="lineno"> 226</span>  <a class="code" href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a>(<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>, 3)</div><div class="line"><a name="l00227"></a><span class="lineno"> 227</span>  row1 = vload3(0, (__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + 1 * src_stride_y));</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  <a class="code" href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a>(<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>, 3)</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  row2 = vload3(0, (__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + 2 * src_stride_y));</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span> </div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  vstore8((<a class="code" href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a>(<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>, 8))(row0.s012, row1.s012, row2.s01), 0, output_ptr);</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  *(output_ptr + 8) = row2.s2;</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span> </div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span> #ifdef HAS_BIAS</div><div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  <span class="keywordflow">if</span>(ch == (KERNEL_DEPTH - 1))</div><div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  {</div><div class="line"><a name="l00237"></a><span class="lineno"> 237</span> <span class="preprocessor">#ifdef FIXED_POINT_POSITION</span></div><div class="line"><a name="l00238"></a><span class="lineno"> 238</span>  *(output_ptr + 9) = (<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>)(1 << FIXED_POINT_POSITION);</div><div class="line"><a name="l00239"></a><span class="lineno"> 239</span> <span class="preprocessor">#else // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  *(output_ptr + 9) = 1.0f;</div><div class="line"><a name="l00241"></a><span class="lineno"> 241</span> <span class="preprocessor">#endif // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  }</div><div class="line"><a name="l00243"></a><span class="lineno"> 243</span> <span class="preprocessor">#endif // HAS_BIAS</span></div><div class="line"><a name="l00244"></a><span class="lineno"> 244</span> }</div><div class="line"><a name="l00245"></a><span class="lineno"> 245</span> <span class="preprocessor">#endif //defined(CONVOLVED_WIDTH) && defined(STRIDE_X) && defined(STRIDE_Y) && defined(PAD_LEFT) && defined(PAD_TOP) && defined(PAD_RIGHT) && defined(PAD_BOTTOM) && defined(KERNEL_WIDTH) && defined(KERNEL_HEIGHT) && defined(KERNEL_DEPTH) && defined(SRC_WIDTH) && defined(SRC_HEIGHT)</span></div><div class="line"><a name="l00246"></a><span class="lineno"> 246</span> </div><div class="line"><a name="l00247"></a><span class="lineno"> 247</span> <span class="preprocessor">#if defined(WIDTH_OUTPUT)</span></div><div class="line"><a name="l00248"></a><span class="lineno"> 248</span> </div><div class="line"><a name="l00270"></a><span class="lineno"> 270</span> __kernel <span class="keywordtype">void</span> col2im(</div><div class="line"><a name="l00271"></a><span class="lineno"> 271</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(src),</div><div class="line"><a name="l00272"></a><span class="lineno"> 272</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>),</div><div class="line"><a name="l00273"></a><span class="lineno"> 273</span>  uint dst_stride_w)</div><div class="line"><a name="l00274"></a><span class="lineno"> 274</span> {</div><div class="line"><a name="l00275"></a><span class="lineno"> 275</span>  <a class="code" href="struct_tensor3_d.xhtml">Tensor3D</a> src = <a class="code" href="helpers_8h.xhtml#a31c8c760f08fb1a331b16b7c204321dc">CONVERT_TO_TENSOR3D_STRUCT</a>(src);</div><div class="line"><a name="l00276"></a><span class="lineno"> 276</span>  <a class="code" href="struct_tensor3_d.xhtml">Tensor3D</a> <a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a> = <a class="code" href="helpers_8h.xhtml#a79e8e562daa6599317d2d1cd86ef1bf2">CONVERT_TO_TENSOR3D_STRUCT_NO_STEP</a>(dst);</div><div class="line"><a name="l00277"></a><span class="lineno"> 277</span> </div><div class="line"><a name="l00278"></a><span class="lineno"> 278</span>  <span class="comment">// Compute output offset</span></div><div class="line"><a name="l00279"></a><span class="lineno"> 279</span>  <span class="keywordtype">int</span> idx = get_global_id(0) * dst.<a class="code" href="struct_tensor3_d.xhtml#ad5ff7a2b2bd0eec50fe09c254b127d1c">stride_z</a> + (get_global_id(1) / WIDTH_OUTPUT) * dst_stride_y + (get_global_id(1) % WIDTH_OUTPUT) * dst_stride_x + get_global_id(2) * dst_stride_w;</div><div class="line"><a name="l00280"></a><span class="lineno"> 280</span> </div><div class="line"><a name="l00281"></a><span class="lineno"> 281</span>  <span class="comment">// Store value</span></div><div class="line"><a name="l00282"></a><span class="lineno"> 282</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(dst.<a class="code" href="struct_tensor3_d.xhtml#acf52c23cbd7424606c10a606524e3e32">ptr</a> + idx)) = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(src.<a class="code" href="struct_tensor3_d.xhtml#acf52c23cbd7424606c10a606524e3e32">ptr</a>));</div><div class="line"><a name="l00283"></a><span class="lineno"> 283</span> }</div><div class="line"><a name="l00284"></a><span class="lineno"> 284</span> <span class="preprocessor">#endif // defined(WIDTH_OUTPUT)</span></div><div class="line"><a name="l00285"></a><span class="lineno"> 285</span> </div><div class="line"><a name="l00306"></a><span class="lineno"><a class="line" href="convolution__layer_8cl.xhtml#a6f31f2c8d606e1b57d9bdfacd416024c"> 306</a></span> __kernel <span class="keywordtype">void</span> <a class="code" href="convolution__layer_8cl.xhtml#a6f31f2c8d606e1b57d9bdfacd416024c">im2col_reduced</a>(</div><div class="line"><a name="l00307"></a><span class="lineno"> 307</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(src),</div><div class="line"><a name="l00308"></a><span class="lineno"> 308</span>  <a class="code" href="helpers_8h.xhtml#a40a6eb9f2a7712f08d6bb8ff6c9e6ca7">VECTOR_DECLARATION</a>(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>),</div><div class="line"><a name="l00309"></a><span class="lineno"> 309</span>  uint width, uint height)</div><div class="line"><a name="l00310"></a><span class="lineno"> 310</span> {</div><div class="line"><a name="l00311"></a><span class="lineno"> 311</span>  <a class="code" href="struct_tensor3_d.xhtml">Tensor3D</a> src = <a class="code" href="helpers_8h.xhtml#a31c8c760f08fb1a331b16b7c204321dc">CONVERT_TO_TENSOR3D_STRUCT</a>(src);</div><div class="line"><a name="l00312"></a><span class="lineno"> 312</span> </div><div class="line"><a name="l00313"></a><span class="lineno"> 313</span>  <span class="keyword">const</span> uint image_size = width * height;</div><div class="line"><a name="l00314"></a><span class="lineno"> 314</span> </div><div class="line"><a name="l00315"></a><span class="lineno"> 315</span>  __global uchar *tmp_out_ptr = dst_ptr + dst_offset_first_element_in_bytes + (get_global_id(0) + get_global_id(1) * width + get_global_id(2) * image_size) * dst_stride_x;</div><div class="line"><a name="l00316"></a><span class="lineno"> 316</span> </div><div class="line"><a name="l00317"></a><span class="lineno"> 317</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_out_ptr) = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)src.<a class="code" href="struct_tensor3_d.xhtml#acf52c23cbd7424606c10a606524e3e32">ptr</a>);</div><div class="line"><a name="l00318"></a><span class="lineno"> 318</span> </div><div class="line"><a name="l00319"></a><span class="lineno"> 319</span> <span class="preprocessor">#ifdef HAS_BIAS</span></div><div class="line"><a name="l00320"></a><span class="lineno"> 320</span>  <span class="comment">// If it is the last thread in the 3 dimensional workgroup</span></div><div class="line"><a name="l00321"></a><span class="lineno"> 321</span>  <span class="keywordflow">if</span>(get_global_id(0) == (get_global_size(0) - 1) && get_global_id(1) == (get_global_size(1) - 1) && get_global_id(2) == (get_global_size(2) - 1))</div><div class="line"><a name="l00322"></a><span class="lineno"> 322</span>  {</div><div class="line"><a name="l00323"></a><span class="lineno"> 323</span>  tmp_out_ptr += dst_stride_x;</div><div class="line"><a name="l00324"></a><span class="lineno"> 324</span> <span class="preprocessor">#ifdef FIXED_POINT_POSITION</span></div><div class="line"><a name="l00325"></a><span class="lineno"> 325</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_out_ptr) = (<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>)(1 << FIXED_POINT_POSITION);</div><div class="line"><a name="l00326"></a><span class="lineno"> 326</span> <span class="preprocessor">#else // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00327"></a><span class="lineno"> 327</span>  *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)tmp_out_ptr) = (<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>)1;</div><div class="line"><a name="l00328"></a><span class="lineno"> 328</span> <span class="preprocessor">#endif // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00329"></a><span class="lineno"> 329</span>  }</div><div class="line"><a name="l00330"></a><span class="lineno"> 330</span> <span class="preprocessor">#endif // HAS_BIAS</span></div><div class="line"><a name="l00331"></a><span class="lineno"> 331</span> }</div><div class="line"><a name="l00332"></a><span class="lineno"> 332</span> </div><div class="line"><a name="l00333"></a><span class="lineno"> 333</span> <span class="preprocessor">#if defined(CONVOLVED_WIDTH) && defined(STRIDE_X) && defined(STRIDE_Y) && defined(PAD_LEFT) && defined(PAD_TOP) && defined(PAD_RIGHT) && defined(PAD_BOTTOM) && defined(KERNEL_WIDTH) && defined(KERNEL_HEIGHT) && defined(KERNEL_DEPTH) && defined(SRC_WIDTH) && defined(SRC_HEIGHT) && defined(VECTOR_SIZE) && defined(WIDTH_MOD_VECTOR_SIZE)</span></div><div class="line"><a name="l00334"></a><span class="lineno"> 334</span> </div><div class="line"><a name="l00359"></a><span class="lineno"> 359</span> __kernel <span class="keywordtype">void</span> im2col_generic_padx0_pady0(</div><div class="line"><a name="l00360"></a><span class="lineno"> 360</span>  <a class="code" href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a>(src),</div><div class="line"><a name="l00361"></a><span class="lineno"> 361</span>  <a class="code" href="helpers_8h.xhtml#a22f42fcf2077d951271df83b55c1a71a">IMAGE_DECLARATION</a>(<a class="code" href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">dst</a>),</div><div class="line"><a name="l00362"></a><span class="lineno"> 362</span>  uint src_stride_w,</div><div class="line"><a name="l00363"></a><span class="lineno"> 363</span>  uint dst_stride_w)</div><div class="line"><a name="l00364"></a><span class="lineno"> 364</span> {</div><div class="line"><a name="l00365"></a><span class="lineno"> 365</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xc = get_global_id(0); <span class="comment">// x coordinate in the convolved tensor</span></div><div class="line"><a name="l00366"></a><span class="lineno"> 366</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yc = get_global_id(1); <span class="comment">// y coordinate in the convolved tensor</span></div><div class="line"><a name="l00367"></a><span class="lineno"> 367</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> ch = get_global_id(2) % KERNEL_DEPTH; <span class="comment">// input feature map</span></div><div class="line"><a name="l00368"></a><span class="lineno"> 368</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> batch = get_global_id(2) / KERNEL_DEPTH; <span class="comment">// batch size</span></div><div class="line"><a name="l00369"></a><span class="lineno"> 369</span> </div><div class="line"><a name="l00370"></a><span class="lineno"> 370</span>  <span class="comment">// Calculate input indices</span></div><div class="line"><a name="l00371"></a><span class="lineno"> 371</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xi = xc * STRIDE_X;</div><div class="line"><a name="l00372"></a><span class="lineno"> 372</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yi = yc * STRIDE_Y;</div><div class="line"><a name="l00373"></a><span class="lineno"> 373</span>  <span class="comment">// Calculate output indices</span></div><div class="line"><a name="l00374"></a><span class="lineno"> 374</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> xo = ch * KERNEL_WIDTH * KERNEL_HEIGHT;</div><div class="line"><a name="l00375"></a><span class="lineno"> 375</span>  <span class="keyword">const</span> <span class="keywordtype">int</span> yo = xc + yc * CONVOLVED_WIDTH; <span class="comment">// Index of the convolution</span></div><div class="line"><a name="l00376"></a><span class="lineno"> 376</span>  __global uchar *input_ptr = src_ptr + src_offset_first_element_in_bytes + ch * src_stride_z + batch * src_stride_w;</div><div class="line"><a name="l00377"></a><span class="lineno"> 377</span>  __global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *output_ptr = ((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(dst_ptr + dst_offset_first_element_in_bytes + yo * dst_stride_y + batch * dst_stride_w)) + xo;</div><div class="line"><a name="l00378"></a><span class="lineno"> 378</span>  <span class="comment">// Linearize convolution elements</span></div><div class="line"><a name="l00379"></a><span class="lineno"> 379</span>  <span class="keywordflow">for</span>(<span class="keywordtype">int</span> y = yi, y_e = yi + KERNEL_HEIGHT; y < y_e; ++y)</div><div class="line"><a name="l00380"></a><span class="lineno"> 380</span>  {</div><div class="line"><a name="l00381"></a><span class="lineno"> 381</span>  <span class="keywordtype">int</span> last_x = 0;</div><div class="line"><a name="l00382"></a><span class="lineno"> 382</span>  <span class="keywordflow">for</span>(<span class="keywordtype">int</span> x = xi, x_e = xi + KERNEL_WIDTH; x + <a class="code" href="softmax__layer_8cl.xhtml#a7c78836761fa3b5b124efea237dac70f">VECTOR_SIZE</a> <= x_e; x += <a class="code" href="softmax__layer_8cl.xhtml#a7c78836761fa3b5b124efea237dac70f">VECTOR_SIZE</a>, output_ptr += <a class="code" href="softmax__layer_8cl.xhtml#a7c78836761fa3b5b124efea237dac70f">VECTOR_SIZE</a>)</div><div class="line"><a name="l00383"></a><span class="lineno"> 383</span>  {</div><div class="line"><a name="l00384"></a><span class="lineno"> 384</span>  <a class="code" href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a>(<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>, VECTOR_SIZE)</div><div class="line"><a name="l00385"></a><span class="lineno"> 385</span>  row = <a class="code" href="helpers_8h.xhtml#a287e2fc366c312b468382c95bb90f91f">VLOAD</a>(VECTOR_SIZE)(0, (__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + x * src_stride_x + y * src_stride_y));</div><div class="line"><a name="l00386"></a><span class="lineno"> 386</span>  <a class="code" href="helpers_8h.xhtml#acb282042d1edeeaa3cc979a206f78b54">VSTORE</a>(VECTOR_SIZE)</div><div class="line"><a name="l00387"></a><span class="lineno"> 387</span>  (row, 0, output_ptr);</div><div class="line"><a name="l00388"></a><span class="lineno"> 388</span>  last_x = x;</div><div class="line"><a name="l00389"></a><span class="lineno"> 389</span>  }</div><div class="line"><a name="l00390"></a><span class="lineno"> 390</span>  <span class="comment">// Copy the remainder of the row by doing VLOAD(WIDTH_MOD_VECTOR_SIZE) and VSTORE(WIDTH_MOD_VECTOR_SIZE).</span></div><div class="line"><a name="l00391"></a><span class="lineno"> 391</span>  <span class="comment">// Note that x and output_ptr have already been incremented by VECTOR_SIZE by the loop just before exit.</span></div><div class="line"><a name="l00392"></a><span class="lineno"> 392</span> <span class="preprocessor">#if WIDTH_MOD_VECTOR_SIZE == 1</span></div><div class="line"><a name="l00393"></a><span class="lineno"> 393</span>  *output_ptr = *((__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + (last_x + VECTOR_SIZE) * src_stride_x + y * src_stride_y));</div><div class="line"><a name="l00394"></a><span class="lineno"> 394</span> <span class="preprocessor">#elif WIDTH_MOD_VECTOR_SIZE > 1</span></div><div class="line"><a name="l00395"></a><span class="lineno"> 395</span>  <a class="code" href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a>(<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>, WIDTH_MOD_VECTOR_SIZE)</div><div class="line"><a name="l00396"></a><span class="lineno"> 396</span>  row = <a class="code" href="helpers_8h.xhtml#a287e2fc366c312b468382c95bb90f91f">VLOAD</a>(WIDTH_MOD_VECTOR_SIZE)(0, (__global <a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a> *)(input_ptr + (last_x + VECTOR_SIZE) * src_stride_x + y * src_stride_y));</div><div class="line"><a name="l00397"></a><span class="lineno"> 397</span>  <a class="code" href="helpers_8h.xhtml#acb282042d1edeeaa3cc979a206f78b54">VSTORE</a>(WIDTH_MOD_VECTOR_SIZE)</div><div class="line"><a name="l00398"></a><span class="lineno"> 398</span>  (row, 0, output_ptr);</div><div class="line"><a name="l00399"></a><span class="lineno"> 399</span> <span class="preprocessor">#endif </span><span class="comment">/* WIDTH_MOD_VECTOR_SIZE */</span><span class="preprocessor"></span></div><div class="line"><a name="l00400"></a><span class="lineno"> 400</span>  output_ptr += WIDTH_MOD_VECTOR_SIZE;</div><div class="line"><a name="l00401"></a><span class="lineno"> 401</span>  } <span class="comment">/* End of loop over KERNEL_HEIGHT */</span></div><div class="line"><a name="l00402"></a><span class="lineno"> 402</span> </div><div class="line"><a name="l00403"></a><span class="lineno"> 403</span> <span class="preprocessor">#ifdef HAS_BIAS</span></div><div class="line"><a name="l00404"></a><span class="lineno"> 404</span>  <span class="keywordflow">if</span>(ch == (KERNEL_DEPTH - 1))</div><div class="line"><a name="l00405"></a><span class="lineno"> 405</span>  {</div><div class="line"><a name="l00406"></a><span class="lineno"> 406</span> <span class="preprocessor">#ifdef FIXED_POINT_POSITION</span></div><div class="line"><a name="l00407"></a><span class="lineno"> 407</span>  *output_ptr = (<a class="code" href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a>)(1 << FIXED_POINT_POSITION);</div><div class="line"><a name="l00408"></a><span class="lineno"> 408</span> <span class="preprocessor">#else // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00409"></a><span class="lineno"> 409</span>  *output_ptr = 1.0f;</div><div class="line"><a name="l00410"></a><span class="lineno"> 410</span> <span class="preprocessor">#endif // FIXED_POINT_POSITION</span></div><div class="line"><a name="l00411"></a><span class="lineno"> 411</span>  }</div><div class="line"><a name="l00412"></a><span class="lineno"> 412</span> <span class="preprocessor">#endif // HAS_BIAS</span></div><div class="line"><a name="l00413"></a><span class="lineno"> 413</span> }</div><div class="line"><a name="l00414"></a><span class="lineno"> 414</span> <span class="preprocessor">#endif //defined(CONVOLVED_WIDTH) && defined(STRIDE_X) && defined(STRIDE_Y) && defined(PAD_LEFT) && defined(PAD_TOP) && defined(PAD_RIGHT) && defined(PAD_BOTTOM) && defined(KERNEL_WIDTH) && defined(KERNEL_HEIGHT) && defined(KERNEL_DEPTH) && defined(SRC_WIDTH) && defined(SRC_HEIGHT) && defined(VECTOR_SIZE) && defined(WIDTH_MOD_VECTOR_SIZE)</span></div><div class="ttc" id="helpers_8h_xhtml_a287e2fc366c312b468382c95bb90f91f"><div class="ttname"><a href="helpers_8h.xhtml#a287e2fc366c312b468382c95bb90f91f">VLOAD</a></div><div class="ttdeci">#define VLOAD(size)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00040">helpers.h:40</a></div></div> |
| 121 | <div class="ttc" id="helpers_8h_xhtml_a31c8c760f08fb1a331b16b7c204321dc"><div class="ttname"><a href="helpers_8h.xhtml#a31c8c760f08fb1a331b16b7c204321dc">CONVERT_TO_TENSOR3D_STRUCT</a></div><div class="ttdeci">#define CONVERT_TO_TENSOR3D_STRUCT(name)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00117">helpers.h:117</a></div></div> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 122 | <div class="ttc" id="convolution3x3_8cl_xhtml_afb8c72ce35c4a1f4a2588d6573e54aa1"><div class="ttname"><a href="convolution3x3_8cl.xhtml#afb8c72ce35c4a1f4a2588d6573e54aa1">DATA_TYPE</a></div><div class="ttdeci">#define DATA_TYPE</div><div class="ttdef"><b>Definition:</b> <a href="convolution3x3_8cl_source.xhtml#l00027">convolution3x3.cl:27</a></div></div> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 123 | <div class="ttc" id="struct_tensor3_d_xhtml_ad5ff7a2b2bd0eec50fe09c254b127d1c"><div class="ttname"><a href="struct_tensor3_d.xhtml#ad5ff7a2b2bd0eec50fe09c254b127d1c">Tensor3D::stride_z</a></div><div class="ttdeci">int stride_z</div><div class="ttdoc">Stride of the image in Z dimension (in bytes) </div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00155">helpers.h:155</a></div></div> |
| 124 | <div class="ttc" id="helpers_8h_xhtml_a22f42fcf2077d951271df83b55c1a71a"><div class="ttname"><a href="helpers_8h.xhtml#a22f42fcf2077d951271df83b55c1a71a">IMAGE_DECLARATION</a></div><div class="ttdeci">#define IMAGE_DECLARATION(name)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00066">helpers.h:66</a></div></div> |
| 125 | <div class="ttc" id="struct_tensor3_d_xhtml"><div class="ttname"><a href="struct_tensor3_d.xhtml">Tensor3D</a></div><div class="ttdoc">Structure to hold 3D tensor information. </div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00149">helpers.h:149</a></div></div> |
| 126 | <div class="ttc" id="helpers_8h_xhtml_acb282042d1edeeaa3cc979a206f78b54"><div class="ttname"><a href="helpers_8h.xhtml#acb282042d1edeeaa3cc979a206f78b54">VSTORE</a></div><div class="ttdeci">#define VSTORE(size)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00043">helpers.h:43</a></div></div> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 127 | <div class="ttc" id="helpers_8h_xhtml"><div class="ttname"><a href="helpers_8h.xhtml">helpers.h</a></div></div> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 128 | <div class="ttc" id="softmax__layer_8cl_xhtml_a7c78836761fa3b5b124efea237dac70f"><div class="ttname"><a href="softmax__layer_8cl.xhtml#a7c78836761fa3b5b124efea237dac70f">VECTOR_SIZE</a></div><div class="ttdeci">#define VECTOR_SIZE</div><div class="ttdef"><b>Definition:</b> <a href="softmax__layer_8cl_source.xhtml#l00079">softmax_layer.cl:79</a></div></div> |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 129 | <div class="ttc" id="fixed__point_8h_xhtml"><div class="ttname"><a href="fixed__point_8h.xhtml">fixed_point.h</a></div></div> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 130 | <div class="ttc" id="helpers_8h_xhtml_a40a6eb9f2a7712f08d6bb8ff6c9e6ca7"><div class="ttname"><a href="helpers_8h.xhtml#a40a6eb9f2a7712f08d6bb8ff6c9e6ca7">VECTOR_DECLARATION</a></div><div class="ttdeci">#define VECTOR_DECLARATION(name)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00060">helpers.h:60</a></div></div> |
| 131 | <div class="ttc" id="namespacearm__compute_1_1test_1_1validation_xhtml_adbf67dcee294e673cf796f1ed8aeb6a4"><div class="ttname"><a href="namespacearm__compute_1_1test_1_1validation.xhtml#adbf67dcee294e673cf796f1ed8aeb6a4">arm_compute::test::validation::dst</a></div><div class="ttdeci">Tensor dst</div><div class="ttdef"><b>Definition:</b> <a href="validation_2_n_e_o_n_2_g_e_m_m_8cpp_source.xhtml#l00118">GEMM.cpp:118</a></div></div> |
| 132 | <div class="ttc" id="helpers_8h_xhtml_a6b83038822d1ae7ab619b684ed3b7fc0"><div class="ttname"><a href="helpers_8h.xhtml#a6b83038822d1ae7ab619b684ed3b7fc0">TENSOR3D_DECLARATION</a></div><div class="ttdeci">#define TENSOR3D_DECLARATION(name)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00074">helpers.h:74</a></div></div> |
| 133 | <div class="ttc" id="convolution__layer_8cl_xhtml_a6f31f2c8d606e1b57d9bdfacd416024c"><div class="ttname"><a href="convolution__layer_8cl.xhtml#a6f31f2c8d606e1b57d9bdfacd416024c">im2col_reduced</a></div><div class="ttdeci">__kernel void im2col_reduced(__global uchar *src_ptr, uint src_stride_x, uint src_step_x, uint src_stride_y, uint src_step_y, uint src_stride_z, uint src_step_z, uint src_offset_first_element_in_bytes, __global uchar *dst_ptr, uint dst_stride_x, uint dst_step_x, uint dst_offset_first_element_in_bytes, uint width, uint height)</div><div class="ttdoc">This kernel reshapes the tensor&#39;s low three dimensions to single row for GEMM operation. </div><div class="ttdef"><b>Definition:</b> <a href="convolution__layer_8cl_source.xhtml#l00306">convolution_layer.cl:306</a></div></div> |
Kaizen | 8938bd3 | 2017-09-28 14:38:23 +0100 | [diff] [blame] | 134 | <div class="ttc" id="fixed__point_8h_xhtml_a36f754c05b6fddf6df0d8d0a74f8159f"><div class="ttname"><a href="fixed__point_8h.xhtml#a36f754c05b6fddf6df0d8d0a74f8159f">VEC_DATA_TYPE</a></div><div class="ttdeci">#define VEC_DATA_TYPE(type, size)</div><div class="ttdef"><b>Definition:</b> <a href="fixed__point_8h_source.xhtml#l00093">fixed_point.h:93</a></div></div> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 135 | <div class="ttc" id="helpers_8h_xhtml_a79e8e562daa6599317d2d1cd86ef1bf2"><div class="ttname"><a href="helpers_8h.xhtml#a79e8e562daa6599317d2d1cd86ef1bf2">CONVERT_TO_TENSOR3D_STRUCT_NO_STEP</a></div><div class="ttdeci">#define CONVERT_TO_TENSOR3D_STRUCT_NO_STEP(name)</div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00121">helpers.h:121</a></div></div> |
| 136 | <div class="ttc" id="struct_tensor3_d_xhtml_acf52c23cbd7424606c10a606524e3e32"><div class="ttname"><a href="struct_tensor3_d.xhtml#acf52c23cbd7424606c10a606524e3e32">Tensor3D::ptr</a></div><div class="ttdeci">__global uchar * ptr</div><div class="ttdoc">Pointer to the starting postion of the buffer. </div><div class="ttdef"><b>Definition:</b> <a href="helpers_8h_source.xhtml#l00151">helpers.h:151</a></div></div> |
| 137 | <div class="ttc" id="convolution__layer_8cl_xhtml_ab6358b28d1e7bc946950075d94412013"><div class="ttname"><a href="convolution__layer_8cl.xhtml#ab6358b28d1e7bc946950075d94412013">reshape_to_columns</a></div><div class="ttdeci">__kernel void reshape_to_columns(__global uchar *src_ptr, uint src_stride_x, uint src_step_x, uint src_stride_y, uint src_step_y, uint src_stride_z, uint src_step_z, uint src_offset_first_element_in_bytes, __global uchar *dst_ptr, uint dst_stride_x, uint dst_step_x, uint dst_stride_y, uint dst_step_y, uint dst_offset_first_element_in_bytes, __global uchar *bias_ptr, uint bias_stride_x, uint bias_step_x, uint bias_offset_first_element_in_bytes, uint width, uint height, uint depth, uint total_filters)</div><div class="ttdoc">This kernel reshapes the tensor&#39;s low three dimensions to single column. </div><div class="ttdef"><b>Definition:</b> <a href="convolution__layer_8cl_source.xhtml#l00057">convolution_layer.cl:57</a></div></div> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 138 | </div><!-- fragment --></div><!-- contents --> |
| 139 | </div><!-- doc-content --> |
| 140 | <!-- start footer part --> |
| 141 | <div id="nav-path" class="navpath"><!-- id is needed for treeview function! --> |
| 142 | <ul> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 143 | <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.xhtml">src</a></li><li class="navelem"><a class="el" href="dir_aebb8dcc11953d78e620bbef0b9e2183.xhtml">core</a></li><li class="navelem"><a class="el" href="dir_8c278f79c760e5c5fbd911f9870614c1.xhtml">CL</a></li><li class="navelem"><a class="el" href="dir_25885286e9dad4fa105b7b25a8031bbf.xhtml">cl_kernels</a></li><li class="navelem"><a class="el" href="convolution__layer_8cl.xhtml">convolution_layer.cl</a></li> |
| 144 | <li class="footer">Generated on Thu Dec 14 2017 23:48:31 for Compute Library by |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 145 | <a href="http://www.doxygen.org/index.html"> |
Anthony Barbier | 8140e1e | 2017-12-14 23:48:46 +0000 | [diff] [blame^] | 146 | <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li> |
Anthony Barbier | 871448e | 2017-03-24 14:54:29 +0000 | [diff] [blame] | 147 | </ul> |
| 148 | </div> |
| 149 | </body> |
| 150 | </html> |