| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> |
| <meta http-equiv="X-UA-Compatible" content="IE=9"/> |
| <meta name="generator" content="Doxygen 1.8.17"/> |
| <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| <title>mxnet: /work/mxnet/3rdparty/mshadow/mshadow/extension/reduce_with_axis.h Source File</title> |
| <link href="tabs.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="jquery.js"></script> |
| <script type="text/javascript" src="dynsections.js"></script> |
| <link href="search/search.css" rel="stylesheet" type="text/css"/> |
| <script type="text/javascript" src="search/searchdata.js"></script> |
| <script type="text/javascript" src="search/search.js"></script> |
| <link href="doxygen.css" rel="stylesheet" type="text/css" /> |
| </head> |
| <body> |
| <div id="top"><!-- do not remove this div, it is closed by doxygen! --> |
| <div id="titlearea"> |
| <table cellspacing="0" cellpadding="0"> |
| <tbody> |
| <tr style="height: 56px;"> |
| <td id="projectalign" style="padding-left: 0.5em;"> |
| <div id="projectname">mxnet |
| </div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <!-- end header part --> |
| <!-- Generated by Doxygen 1.8.17 --> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| var searchBox = new SearchBox("searchBox", "search",false,'Search'); |
| /* @license-end */ |
| </script> |
| <script type="text/javascript" src="menudata.js"></script> |
| <script type="text/javascript" src="menu.js"></script> |
| <script type="text/javascript"> |
| /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| $(function() { |
| initMenu('',true,false,'search.php','Search'); |
| $(document).ready(function() { init_search(); }); |
| }); |
| /* @license-end */</script> |
| <div id="main-nav"></div> |
| <!-- window showing the filter options --> |
| <div id="MSearchSelectWindow" |
| onmouseover="return searchBox.OnSearchSelectShow()" |
| onmouseout="return searchBox.OnSearchSelectHide()" |
| onkeydown="return searchBox.OnSearchSelectKey(event)"> |
| </div> |
| |
| <!-- iframe showing the search results (closed by default) --> |
| <div id="MSearchResultsWindow"> |
| <iframe src="javascript:void(0)" frameborder="0" |
| name="MSearchResults" id="MSearchResults"> |
| </iframe> |
| </div> |
| |
| <div id="nav-path" class="navpath"> |
| <ul> |
| <li class="navelem"><a class="el" href="dir_8cab8f464681f7cc51cee77e79a434cd.html">3rdparty</a></li><li class="navelem"><a class="el" href="dir_3e48ced36faa4eaa1b41f6d960bf0edb.html">mshadow</a></li><li class="navelem"><a class="el" href="dir_00b035bb2ad81894e6ad291054ea5f82.html">mshadow</a></li><li class="navelem"><a class="el" href="dir_9bd2a322a448ef0abedd860cb1ca3721.html">extension</a></li> </ul> |
| </div> |
| </div><!-- top --> |
| <div class="header"> |
| <div class="headertitle"> |
| <div class="title">reduce_with_axis.h</div> </div> |
| </div><!--header--> |
| <div class="contents"> |
| <a href="reduce__with__axis_8h.html">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"> * Licensed to the Apache Software Foundation (ASF) under one</span></div> |
| <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> * or more contributor license agreements. See the NOTICE file</span></div> |
| <div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * distributed with this work for additional information</span></div> |
| <div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * regarding copyright ownership. The ASF licenses this file</span></div> |
| <div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * to you under the Apache License, Version 2.0 (the</span></div> |
| <div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> * "License"); you may not use this file except in compliance</span></div> |
| <div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * with the License. You may obtain a copy of the License at</span></div> |
| <div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> *</span></div> |
| <div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span></div> |
| <div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> *</span></div> |
| <div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * Unless required by applicable law or agreed to in writing,</span></div> |
| <div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * software distributed under the License is distributed on an</span></div> |
| <div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span></div> |
| <div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> * KIND, either express or implied. See the License for the</span></div> |
| <div class="line"><a name="l00016"></a><span class="lineno"> 16</span> <span class="comment"> * specific language governing permissions and limitations</span></div> |
| <div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="comment"> * under the License.</span></div> |
| <div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="comment"> */</span></div> |
| <div class="line"><a name="l00019"></a><span class="lineno"> 19</span>  </div> |
| <div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="preprocessor">#ifndef MSHADOW_EXTENSION_REDUCE_WITH_AXIS_H_</span></div> |
| <div class="line"><a name="l00026"></a><span class="lineno"> 26</span> <span class="preprocessor">#define MSHADOW_EXTENSION_REDUCE_WITH_AXIS_H_</span></div> |
| <div class="line"><a name="l00027"></a><span class="lineno"> 27</span>  </div> |
| <div class="line"><a name="l00028"></a><span class="lineno"> 28</span> <span class="preprocessor">#include "../extension.h"</span></div> |
| <div class="line"><a name="l00029"></a><span class="lineno"> 29</span>  </div> |
| <div class="line"><a name="l00030"></a><span class="lineno"> 30</span> <span class="keyword">namespace </span><a class="code" href="namespacemshadow.html">mshadow</a> {</div> |
| <div class="line"><a name="l00031"></a><span class="lineno"> 31</span> <span class="keyword">namespace </span>expr {</div> |
| <div class="line"><a name="l00032"></a><span class="lineno"> 32</span>  </div> |
| <div class="line"><a name="l00038"></a><span class="lineno"> 38</span> <span class="keyword">template</span><<span class="keyword">typename</span> Reducer, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType, <span class="keywordtype">int</span> dimsrc, <span class="keywordtype">bool</span> mask, <span class="keywordtype">int</span> dimdst></div> |
| <div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html"> 39</a></span> <span class="keyword">struct </span><a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp</a>:</div> |
| <div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="keyword">public</span> <a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html">MakeTensorExp</a><ReduceWithAxisExp<Reducer, SrcExp, DType, dimsrc, mask, dimdst>,</div> |
| <div class="line"><a name="l00041"></a><span class="lineno"> 41</span>  SrcExp, dimdst, DType> {</div> |
| <div class="line"><a name="l00043"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93"> 43</a></span>  <span class="keyword">const</span> SrcExp &<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>;</div> |
| <div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf"> 45</a></span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf">last_dst_dim_</a>;</div> |
| <div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78"> 47</a></span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>;</div> |
| <div class="line"><a name="l00049"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d"> 49</a></span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">size_</a>;</div> |
| <div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e"> 51</a></span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>;</div> |
| <div class="line"><a name="l00053"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a53c850b9485801699f8dca411007983d"> 53</a></span>  <span class="keyword">explicit</span> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a53c850b9485801699f8dca411007983d">ReduceWithAxisExp</a>(<span class="keyword">const</span> SrcExp &src, <span class="keywordtype">int</span> axis)</div> |
| <div class="line"><a name="l00054"></a><span class="lineno"> 54</span>  : <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>(src) {</div> |
| <div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <span class="keywordtype">bool</span> keepdim = (dimsrc == dimdst);</div> |
| <div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  CHECK(dimsrc > axis) << <span class="stringliteral">"reduce axis out of bound"</span>;</div> |
| <div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <a class="code" href="structmshadow_1_1Shape.html">Shape<dimsrc></a> src_shape = <a class="code" href="structmshadow_1_1expr_1_1ShapeCheck.html#af44e6a3b97cf3b245bc1b7ad4cacb306">ShapeCheck<dimsrc, SrcExp>::Check</a>(<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>);</div> |
| <div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < axis; ++i) {</div> |
| <div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  this-><a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">shape_</a>[i] = src_shape[i];</div> |
| <div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  }</div> |
| <div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  this->size_ = src_shape[axis];</div> |
| <div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  this->trailing_ = 1;</div> |
| <div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  <span class="keywordflow">if</span> (!keepdim) {</div> |
| <div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = axis + 1; i < dimsrc; ++i) {</div> |
| <div class="line"><a name="l00065"></a><span class="lineno"> 65</span>  this->trailing_ *= src_shape[i];</div> |
| <div class="line"><a name="l00066"></a><span class="lineno"> 66</span>  this-><a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">shape_</a>[i - 1] = src_shape[i];</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>  } <span class="keywordflow">else</span> {</div> |
| <div class="line"><a name="l00069"></a><span class="lineno"> 69</span>  this-><a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">shape_</a>[axis] = 1;</div> |
| <div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> i = axis + 1; i < dimsrc; ++i) {</div> |
| <div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  this->trailing_ *= src_shape[i];</div> |
| <div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  this-><a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">shape_</a>[i] = src_shape[i];</div> |
| <div class="line"><a name="l00073"></a><span class="lineno"> 73</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>  </div> |
| <div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  this->last_ = src_shape[dimsrc - 1];</div> |
| <div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  this->last_dst_dim_ = this-><a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">shape_</a>[dimdst - 1];</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> }; <span class="comment">// struct ReduceWithAxisExp</span></div> |
| <div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  </div> |
| <div class="line"><a name="l00089"></a><span class="lineno"> 89</span> <span class="keyword">template</span><<span class="keyword">typename</span> Reducer, <span class="keywordtype">bool</span> mask, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType, <span class="keywordtype">int</span> etype></div> |
| <div class="line"><a name="l00090"></a><span class="lineno"> 90</span> <span class="keyword">inline</span> ReduceWithAxisExp<Reducer, SrcExp, DType, ExpInfo<SrcExp>::kDim, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div> |
| <div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html#a0b0afc287b577f89dc3eb119c2fef778">ExpInfo<SrcExp>::kDim</a> - 1></div> |
| <div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="namespacemshadow_1_1expr.html#afaa1547d2e9eb30305681e92745de131"> 92</a></span> <a class="code" href="namespacemshadow_1_1expr.html#afaa1547d2e9eb30305681e92745de131">reduce_with_axis</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1Exp.html">Exp<SrcExp, DType, etype></a> &src, <span class="keywordtype">int</span> axis) {</div> |
| <div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  <span class="keywordflow">return</span> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp<Reducer, SrcExp, DType, ExpInfo<SrcExp>::kDim</a>, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div> |
| <div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo<SrcExp>::kDim</a>- 1>(src.<a class="code" href="structmshadow_1_1expr_1_1Exp.html#adb7e4afd0baed78d66cff87de0a6621f">self</a>(), axis);</div> |
| <div class="line"><a name="l00095"></a><span class="lineno"> 95</span> }</div> |
| <div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  </div> |
| <div class="line"><a name="l00105"></a><span class="lineno"> 105</span> <span class="keyword">template</span><<span class="keyword">typename</span> Reducer, <span class="keywordtype">bool</span> mask, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType, <span class="keywordtype">int</span> etype></div> |
| <div class="line"><a name="l00106"></a><span class="lineno"> 106</span> <span class="keyword">inline</span> ReduceWithAxisExp<Reducer, SrcExp, DType, ExpInfo<SrcExp>::kDim, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div> |
| <div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html#a0b0afc287b577f89dc3eb119c2fef778">ExpInfo<SrcExp>::kDim</a>></div> |
| <div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="namespacemshadow_1_1expr.html#ad91ec561000b979700a507b23e4412e9"> 108</a></span>  <a class="code" href="namespacemshadow_1_1expr.html#ad91ec561000b979700a507b23e4412e9">reduce_keepdim</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1Exp.html">Exp<SrcExp, DType, etype></a> &src, <span class="keywordtype">int</span> axis) {</div> |
| <div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  <span class="keywordflow">return</span> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp<Reducer, SrcExp, DType, ExpInfo<SrcExp>::kDim</a>, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div> |
| <div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo<SrcExp>::kDim</a>>(src.<a class="code" href="structmshadow_1_1expr_1_1Exp.html#adb7e4afd0baed78d66cff87de0a6621f">self</a>(), axis);</div> |
| <div class="line"><a name="l00111"></a><span class="lineno"> 111</span> }</div> |
| <div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  </div> |
| <div class="line"><a name="l00113"></a><span class="lineno"> 113</span> <span class="comment">//----------------------</span></div> |
| <div class="line"><a name="l00114"></a><span class="lineno"> 114</span> <span class="comment">// Execution plan</span></div> |
| <div class="line"><a name="l00115"></a><span class="lineno"> 115</span> <span class="comment">//----------------------</span></div> |
| <div class="line"><a name="l00116"></a><span class="lineno"> 116</span> <span class="keyword">template</span><<span class="keyword">typename</span> Reducer, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType, <span class="keywordtype">int</span> dimsrc, <span class="keywordtype">bool</span> mask, <span class="keywordtype">int</span> dimdst></div> |
| <div class="line"><a name="l00117"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html"> 117</a></span> <span class="keyword">struct </span><a class="code" href="classmshadow_1_1expr_1_1Plan.html">Plan</a><<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp</a><Reducer, SrcExp, DType, dimsrc, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>, dimdst>, DType> {</div> |
| <div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  <span class="keyword">public</span>:</div> |
| <div class="line"><a name="l00119"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html#af925d673e63c34d6d9bcb5f72cbdbc38"> 119</a></span>  <span class="keyword">explicit</span> <a class="code" href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html#af925d673e63c34d6d9bcb5f72cbdbc38">Plan</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp<Reducer, SrcExp, DType, dimsrc, mask, dimdst></a> &e)</div> |
| <div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  : src_(<a class="code" href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">MakePlan</a>(e.src_)), last_dst_dim_(e.last_dst_dim_), trailing_(e.trailing_),</div> |
| <div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  size_(e.size_), last_(e.last_) {}</div> |
| <div class="line"><a name="l00122"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html#a326ca93adaaa5ad8490249df9e1c8dad"> 122</a></span>  <a class="code" href="3rdparty_2mshadow_2mshadow_2base_8h.html#af205b8ab4d8733133d590df7d2639d69">MSHADOW_XINLINE</a> DType <a class="code" href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html#a326ca93adaaa5ad8490249df9e1c8dad">Eval</a>(<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> i, <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> j)<span class="keyword"> const </span>{</div> |
| <div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> x = (i*last_dst_dim_ + j)/trailing_;</div> |
| <div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> y = (i*last_dst_dim_ + j)%trailing_;</div> |
| <div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  </div> |
| <div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keywordflow">if</span> (<a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>) {</div> |
| <div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> idx = 0;</div> |
| <div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  DType res; Reducer::SetInitValue(res);</div> |
| <div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> k = 0; k < size_; ++k) {</div> |
| <div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> z = (x*size_+k)*trailing_+y;</div> |
| <div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  DType tmp = res;</div> |
| <div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  Reducer::Reduce(res, src_.Eval(z/last_, z%last_));</div> |
| <div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="keywordflow">if</span> (tmp != res && !<a class="code" href="namespacemshadow_1_1isnan__typed.html#a31da61266fae8c9ca52df015d132b759">isnan_typed::IsNan</a>(tmp)) {</div> |
| <div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  idx = k;</div> |
| <div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  }</div> |
| <div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  }</div> |
| <div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keywordflow">return</span> <span class="keyword">static_cast<</span>DType<span class="keyword">></span>(<span class="keyword">static_cast<</span><span class="keywordtype">int</span><span class="keyword">></span>(idx));</div> |
| <div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  } <span class="keywordflow">else</span> {</div> |
| <div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  DType res; Reducer::SetInitValue(res);</div> |
| <div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> k = 0; k < size_; ++k) {</div> |
| <div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> z = (x*size_+k)*trailing_+y;</div> |
| <div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  Reducer::Reduce(res, src_.Eval(z/last_, z%last_));</div> |
| <div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  }</div> |
| <div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="keywordflow">return</span> res;</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>  }</div> |
| <div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  </div> |
| <div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="keyword">private</span>:</div> |
| <div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <a class="code" href="classmshadow_1_1expr_1_1Plan.html">Plan<SrcExp, DType></a> src_;</div> |
| <div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="keyword">const</span> <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> last_dst_dim_, trailing_, size_, last_;</div> |
| <div class="line"><a name="l00151"></a><span class="lineno"> 151</span> };</div> |
| <div class="line"><a name="l00152"></a><span class="lineno"> 152</span> } <span class="comment">// namespace expr</span></div> |
| <div class="line"><a name="l00153"></a><span class="lineno"> 153</span> } <span class="comment">// namespace mshadow</span></div> |
| <div class="line"><a name="l00154"></a><span class="lineno"> 154</span> <span class="preprocessor">#endif // MSHADOW_EXTENSION_REDUCE_WITH_AXIS_H_</span></div> |
| </div><!-- fragment --></div><!-- contents --> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html_aabd3f461b4b86f6be16870a05a181b93"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">mshadow::expr::ReduceWithAxisExp::src_</a></div><div class="ttdeci">const SrcExp & src_</div><div class="ttdoc">source oprand</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:43</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1Exp_html_adb7e4afd0baed78d66cff87de0a6621f"><div class="ttname"><a href="structmshadow_1_1expr_1_1Exp.html#adb7e4afd0baed78d66cff87de0a6621f">mshadow::expr::Exp::self</a></div><div class="ttdeci">const SubType & self(void) const</div><div class="ttdef"><b>Definition:</b> expression.h:82</div></div> |
| <div class="ttc" id="anamespacemshadow_1_1expr_html_ad91ec561000b979700a507b23e4412e9"><div class="ttname"><a href="namespacemshadow_1_1expr.html#ad91ec561000b979700a507b23e4412e9">mshadow::expr::reduce_keepdim</a></div><div class="ttdeci">ReduceWithAxisExp< Reducer, SrcExp, DType, ExpInfo< SrcExp >::kDim, mask, ExpInfo< SrcExp >::kDim > reduce_keepdim(const Exp< SrcExp, DType, etype > &src, int axis)</div><div class="ttdoc">reduce out the dimension of src labeled by axis, keepdim turned on.</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:108</div></div> |
| <div class="ttc" id="anamespacemshadow_1_1expr_html_afaa1547d2e9eb30305681e92745de131"><div class="ttname"><a href="namespacemshadow_1_1expr.html#afaa1547d2e9eb30305681e92745de131">mshadow::expr::reduce_with_axis</a></div><div class="ttdeci">ReduceWithAxisExp< Reducer, SrcExp, DType, ExpInfo< SrcExp >::kDim, mask, ExpInfo< SrcExp >::kDim - 1 > reduce_with_axis(const Exp< SrcExp, DType, etype > &src, int axis)</div><div class="ttdoc">reduce out the dimension of src labeled by axis.</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:92</div></div> |
| <div class="ttc" id="a3rdparty_2mshadow_2mshadow_2base_8h_html_af205b8ab4d8733133d590df7d2639d69"><div class="ttname"><a href="3rdparty_2mshadow_2mshadow_2base_8h.html#af205b8ab4d8733133d590df7d2639d69">MSHADOW_XINLINE</a></div><div class="ttdeci">#define MSHADOW_XINLINE</div><div class="ttdef"><b>Definition:</b> base.h:228</div></div> |
| <div class="ttc" id="anamespacemshadow_1_1isnan__typed_html_a31da61266fae8c9ca52df015d132b759"><div class="ttname"><a href="namespacemshadow_1_1isnan__typed.html#a31da61266fae8c9ca52df015d132b759">mshadow::isnan_typed::IsNan</a></div><div class="ttdeci">MSHADOW_XINLINE bool IsNan(volatile DType val)</div><div class="ttdef"><b>Definition:</b> base.h:753</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html_a56012b2265fad6c5c9cc73ec1eab297e"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">mshadow::expr::ReduceWithAxisExp::last_</a></div><div class="ttdeci">index_t last_</div><div class="ttdoc">size of last src dimension</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:51</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ShapeCheck_html_af44e6a3b97cf3b245bc1b7ad4cacb306"><div class="ttname"><a href="structmshadow_1_1expr_1_1ShapeCheck.html#af44e6a3b97cf3b245bc1b7ad4cacb306">mshadow::expr::ShapeCheck::Check</a></div><div class="ttdeci">static Shape< dim > Check(const E &t)</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ExpInfo_html"><div class="ttname"><a href="structmshadow_1_1expr_1_1ExpInfo.html">mshadow::expr::ExpInfo</a></div><div class="ttdoc">static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:262</div></div> |
| <div class="ttc" id="anamespacemshadow_1_1expr_html_aefd008a0bf012dc8fb99d9bbcca7a078"><div class="ttname"><a href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">mshadow::expr::MakePlan</a></div><div class="ttdeci">Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:239</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">mshadow::expr::ReduceWithAxisExp</a></div><div class="ttdoc">reduce out the dimension of src labeled by axis.</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:39</div></div> |
| <div class="ttc" id="anamespacemshadow_1_1expr_html_a0b4a783ea715eba66efea27dc443d9dc"><div class="ttname"><a href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mshadow::expr::mask</a></div><div class="ttdeci">MaskExp< IndexExp, SrcExp, DType > mask(const Exp< IndexExp, DType, e1 > &index, const Exp< SrcExp, DType, e2 > &src)</div><div class="ttdef"><b>Definition:</b> mask.h:57</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1MakeTensorExp_html_a2a2f9b6b828035ea38bfb8620db42a82"><div class="ttname"><a href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">mshadow::expr::MakeTensorExp< ReduceWithAxisExp< Reducer, SrcExp, DType, dimsrc, mask, dimdst >, SrcExp, dimdst, DType >::shape_</a></div><div class="ttdeci">Shape< dim > shape_</div><div class="ttdoc">the shape of this expression</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:47</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html_a104d931b91e6764bc228469f4882d7bf"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf">mshadow::expr::ReduceWithAxisExp::last_dst_dim_</a></div><div class="ttdeci">index_t last_dst_dim_</div><div class="ttdoc">size of last destination dimension</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:45</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee_html_a326ca93adaaa5ad8490249df9e1c8dad"><div class="ttname"><a href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html#a326ca93adaaa5ad8490249df9e1c8dad">mshadow::expr::Plan< ReduceWithAxisExp< Reducer, SrcExp, DType, dimsrc, mask, dimdst >, DType >::Eval</a></div><div class="ttdeci">MSHADOW_XINLINE DType Eval(index_t i, index_t j) const</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:122</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html_a53c850b9485801699f8dca411007983d"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a53c850b9485801699f8dca411007983d">mshadow::expr::ReduceWithAxisExp::ReduceWithAxisExp</a></div><div class="ttdeci">ReduceWithAxisExp(const SrcExp &src, int axis)</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:53</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html_afdb862d85bca4d05d00b198ee1c5852d"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">mshadow::expr::ReduceWithAxisExp::size_</a></div><div class="ttdeci">index_t size_</div><div class="ttdoc">size of axis dimension</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:49</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ExpInfo_html_a0b0afc287b577f89dc3eb119c2fef778"><div class="ttname"><a href="structmshadow_1_1expr_1_1ExpInfo.html#a0b0afc287b577f89dc3eb119c2fef778">mshadow::expr::ExpInfo::kDim</a></div><div class="ttdeci">static const int kDim</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:263</div></div> |
| <div class="ttc" id="anamespacemshadow_html_adcbc2e1131386fccb1474b0bdf045926"><div class="ttname"><a href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">mshadow::index_t</a></div><div class="ttdeci">int32_t index_t</div><div class="ttdoc">type that will be used for index</div><div class="ttdef"><b>Definition:</b> base.h:328</div></div> |
| <div class="ttc" id="aclassmshadow_1_1expr_1_1Plan_html"><div class="ttname"><a href="classmshadow_1_1expr_1_1Plan.html">mshadow::expr::Plan</a></div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:58</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1Exp_html"><div class="ttname"><a href="structmshadow_1_1expr_1_1Exp.html">mshadow::expr::Exp</a></div><div class="ttdoc">defines how expression exp can be evaluated and stored into dst</div><div class="ttdef"><b>Definition:</b> expression.h:79</div></div> |
| <div class="ttc" id="anamespacemshadow_html"><div class="ttname"><a href="namespacemshadow.html">mshadow</a></div><div class="ttdoc">overloaded + operator between half_t and bf16_t</div><div class="ttdef"><b>Definition:</b> base.h:319</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1MakeTensorExp_html"><div class="ttname"><a href="structmshadow_1_1expr_1_1MakeTensorExp.html">mshadow::expr::MakeTensorExp</a></div><div class="ttdoc">a general class that allows extension that makes tensors of some shape</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:43</div></div> |
| <div class="ttc" id="astructmshadow_1_1Shape_html"><div class="ttname"><a href="structmshadow_1_1Shape.html">mshadow::Shape< dimsrc ></a></div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee_html_af925d673e63c34d6d9bcb5f72cbdbc38"><div class="ttname"><a href="structmshadow_1_1expr_1_1Plan_3_01ReduceWithAxisExp_3_01Reducer_00_01SrcExp_00_01DType_00_01dims9b56431b5cd50e4d9299f4af1b4d5aee.html#af925d673e63c34d6d9bcb5f72cbdbc38">mshadow::expr::Plan< ReduceWithAxisExp< Reducer, SrcExp, DType, dimsrc, mask, dimdst >, DType >::Plan</a></div><div class="ttdeci">Plan(const ReduceWithAxisExp< Reducer, SrcExp, DType, dimsrc, mask, dimdst > &e)</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:119</div></div> |
| <div class="ttc" id="astructmshadow_1_1expr_1_1ReduceWithAxisExp_html_a77b0899180045917f4e5632870467c78"><div class="ttname"><a href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">mshadow::expr::ReduceWithAxisExp::trailing_</a></div><div class="ttdeci">index_t trailing_</div><div class="ttdoc">size of trailing dimensions</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:47</div></div> |
| <!-- start footer part --> |
| <hr class="footer"/><address class="footer"><small> |
| Generated on Thu Jan 5 2023 03:47:39 for mxnet by  <a href="http://www.doxygen.org/index.html"> |
| <img class="footer" src="doxygen.png" alt="doxygen"/> |
| </a> 1.8.17 |
| </small></address> |
| </body> |
| </html> |