blob: bb2c48d5b064e1c59f9189e8167c1b7c72eda035 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://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.13"/>
<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.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</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>&#160;<span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span>&#160;<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>&#160;<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>&#160;<span class="comment"> * distributed with this work for additional information</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span>&#160;<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>&#160;<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>&#160;<span class="comment"> * &quot;License&quot;); you may not use this file except in compliance</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<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>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<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>&#160;<span class="comment"> *</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<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>&#160;<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>&#160;<span class="comment"> * &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span>&#160;<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>&#160;<span class="comment"> * specific language governing permissions and limitations</span></div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span>&#160;<span class="comment"> * under the License.</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span>&#160;<span class="comment"> */</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span>&#160;<span class="preprocessor">#ifndef MSHADOW_EXTENSION_REDUCE_WITH_AXIS_H_</span></div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span>&#160;<span class="preprocessor">#define MSHADOW_EXTENSION_REDUCE_WITH_AXIS_H_</span></div><div class="line"><a name="l00027"></a><span class="lineno"> 27</span>&#160;</div><div class="line"><a name="l00028"></a><span class="lineno"> 28</span>&#160;<span class="preprocessor">#include &quot;../extension.h&quot;</span></div><div class="line"><a name="l00029"></a><span class="lineno"> 29</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno"> 30</span>&#160;<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>&#160;<span class="keyword">namespace </span>expr {</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160;<span class="keyword">template</span>&lt;<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&gt;</div><div class="line"><a name="l00039"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html"> 39</a></span>&#160;<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>&#160; <span class="keyword">public</span> <a class="code" href="structmshadow_1_1expr_1_1MakeTensorExp.html">MakeTensorExp</a>&lt;ReduceWithAxisExp&lt;Reducer, SrcExp, DType, dimsrc, mask, dimdst&gt;,</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span>&#160; SrcExp, dimdst, DType&gt; {</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>&#160; <span class="keyword">const</span> SrcExp &amp;<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>&#160; <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>&#160; <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>&#160; <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>&#160; <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>&#160; <span class="keyword">explicit</span> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a53c850b9485801699f8dca411007983d">ReduceWithAxisExp</a>(<span class="keyword">const</span> SrcExp &amp;src, <span class="keywordtype">int</span> axis)</div><div class="line"><a name="l00054"></a><span class="lineno"> 54</span>&#160; : src_(src) {</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <span class="keywordtype">bool</span> keepdim = (dimsrc == dimdst);</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>&#160; CHECK(dimsrc &gt; axis) &lt;&lt; <span class="stringliteral">&quot;reduce axis out of bound&quot;</span>;</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; <a class="code" href="structmshadow_1_1Shape.html">Shape&lt;dimsrc&gt;</a> src_shape = <a class="code" href="structmshadow_1_1expr_1_1ShapeCheck.html#af44e6a3b97cf3b245bc1b7ad4cacb306">ShapeCheck&lt;dimsrc, SrcExp&gt;::Check</a>(src_);</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; axis; ++i) {</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; this-&gt;<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>&#160; }</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>&#160; this-&gt;size_ = src_shape[axis];</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; this-&gt;trailing_ = 1;</div><div class="line"><a name="l00063"></a><span class="lineno"> 63</span>&#160; <span class="keywordflow">if</span> (!keepdim) {</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = axis + 1; i &lt; dimsrc; ++i) {</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; this-&gt;trailing_ *= src_shape[i];</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; this-&gt;<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>&#160; }</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; this-&gt;<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>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> i = axis + 1; i &lt; dimsrc; ++i) {</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; this-&gt;trailing_ *= src_shape[i];</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; this-&gt;<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>&#160; }</div><div class="line"><a name="l00074"></a><span class="lineno"> 74</span>&#160; }</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; this-&gt;last_ = src_shape[dimsrc - 1];</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; this-&gt;last_dst_dim_ = this-&gt;<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>&#160; }</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;}; <span class="comment">// struct ReduceWithAxisExp</span></div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160;</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160;<span class="keyword">template</span>&lt;<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&gt;</div><div class="line"><a name="l00090"></a><span class="lineno"> 90</span>&#160;<span class="keyword">inline</span> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp&lt;Reducer, SrcExp, DType, ExpInfo&lt;SrcExp&gt;::kDim</a>, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo&lt;SrcExp&gt;::kDim</a> - 1&gt;</div><div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="namespacemshadow_1_1expr.html#afaa1547d2e9eb30305681e92745de131"> 92</a></span>&#160;<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&lt;SrcExp, DType, etype&gt;</a> &amp;src, <span class="keywordtype">int</span> axis) {</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="keywordflow">return</span> ReduceWithAxisExp&lt;Reducer, SrcExp, DType, ExpInfo&lt;SrcExp&gt;::kDim, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo&lt;SrcExp&gt;::kDim</a>- 1&gt;(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>&#160;}</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160;</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>&#160;<span class="keyword">template</span>&lt;<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&gt;</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160;<span class="keyword">inline</span> ReduceWithAxisExp&lt;Reducer, SrcExp, DType, ExpInfo&lt;SrcExp&gt;::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>&#160; <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo&lt;SrcExp&gt;::kDim</a>&gt;</div><div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="namespacemshadow_1_1expr.html#ad91ec561000b979700a507b23e4412e9"> 108</a></span>&#160; <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&lt;SrcExp, DType, etype&gt;</a> &amp;src, <span class="keywordtype">int</span> axis) {</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160; <span class="keywordflow">return</span> ReduceWithAxisExp&lt;Reducer, SrcExp, DType, ExpInfo&lt;SrcExp&gt;::kDim, <a class="code" href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mask</a>,</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160; <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo&lt;SrcExp&gt;::kDim</a>&gt;(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>&#160;}</div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>&#160;</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>&#160;<span class="comment">//----------------------</span></div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>&#160;<span class="comment">// Execution plan</span></div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span>&#160;<span class="comment">//----------------------</span></div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span>&#160;<span class="keyword">template</span>&lt;<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&gt;</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>&#160;<span class="keyword">struct </span><a class="code" href="classmshadow_1_1expr_1_1Plan.html">Plan</a>&lt;<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html">ReduceWithAxisExp</a>&lt;Reducer, SrcExp, DType, dimsrc, mask, dimdst&gt;, DType&gt; {</div><div class="line"><a name="l00118"></a><span class="lineno"> 118</span>&#160; <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>&#160; <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&lt;Reducer, SrcExp, DType, dimsrc, mask, dimdst&gt;</a> &amp;e)</div><div class="line"><a name="l00120"></a><span class="lineno"> 120</span>&#160; : <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>(<a class="code" href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">MakePlan</a>(e.<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>)), <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf">last_dst_dim_</a>(e.<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf">last_dst_dim_</a>), <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>(e.<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>),</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>&#160; <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">size_</a>(e.<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">size_</a>), <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>(e.<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>) {}</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>&#160; <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>&#160; <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> x = (i*<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf">last_dst_dim_</a> + j)/<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>;</div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>&#160; <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> y = (i*<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a104d931b91e6764bc228469f4882d7bf">last_dst_dim_</a> + j)%<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>;</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span>&#160;</div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>&#160; <span class="keywordflow">if</span> (mask) {</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>&#160; <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>&#160; DType res; Reducer::SetInitValue(res);</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> k = 0; k &lt; <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">size_</a>; ++k) {</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>&#160; <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> z = (x*size_+k)*<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>+y;</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>&#160; DType tmp = res;</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span>&#160; Reducer::Reduce(res, <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>.Eval(z/<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>, z%<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>));</div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>&#160; <span class="keywordflow">if</span> (tmp != res &amp;&amp; !<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>&#160; idx = k;</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>&#160; }</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>&#160; }</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>&#160; <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>DType<span class="keyword">&gt;</span>(<span class="keyword">static_cast&lt;</span><span class="keywordtype">int</span><span class="keyword">&gt;</span>(idx));</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>&#160; } <span class="keywordflow">else</span> {</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>&#160; DType res; Reducer::SetInitValue(res);</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> k = 0; k &lt; <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">size_</a>; ++k) {</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>&#160; <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> z = (x*size_+k)*<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>+y;</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>&#160; Reducer::Reduce(res, <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>.Eval(z/<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>, z%<a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>));</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>&#160; }</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>&#160; <span class="keywordflow">return</span> res;</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>&#160; }</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>&#160; }</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>&#160;</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>&#160; <span class="keyword">private</span>:</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>&#160; <a class="code" href="classmshadow_1_1expr_1_1Plan.html">Plan&lt;SrcExp, DType&gt;</a> <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#aabd3f461b4b86f6be16870a05a181b93">src_</a>;</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>&#160; <span class="keyword">const</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>, <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a77b0899180045917f4e5632870467c78">trailing_</a>, <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#afdb862d85bca4d05d00b198ee1c5852d">size_</a>, <a class="code" href="structmshadow_1_1expr_1_1ReduceWithAxisExp.html#a56012b2265fad6c5c9cc73ec1eab297e">last_</a>;</div><div class="line"><a name="l00151"></a><span class="lineno"> 151</span>&#160;};</div><div class="line"><a name="l00152"></a><span class="lineno"> 152</span>&#160;} <span class="comment">// namespace expr</span></div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>&#160;} <span class="comment">// namespace mshadow</span></div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>&#160;<span class="preprocessor">#endif // MSHADOW_EXTENSION_REDUCE_WITH_AXIS_H_</span></div><div class="ttc" id="structmshadow_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="structmshadow_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 &amp; self(void) const</div><div class="ttdef"><b>Definition:</b> expression.h:82</div></div>
<div class="ttc" id="classmshadow_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="structmshadow_1_1Shape_html"><div class="ttname"><a href="structmshadow_1_1Shape.html">mshadow::Shape&lt; dimsrc &gt;</a></div></div>
<div class="ttc" id="structmshadow_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&lt; dim &gt; Check(const E &amp;t)</div></div>
<div class="ttc" id="3rdparty_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:230</div></div>
<div class="ttc" id="structmshadow_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&lt;E&gt;::kDim == ...</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:262</div></div>
<div class="ttc" id="namespacemshadow_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:682</div></div>
<div class="ttc" id="namespacemshadow_1_1expr_html_a0b4a783ea715eba66efea27dc443d9dc"><div class="ttname"><a href="namespacemshadow_1_1expr.html#a0b4a783ea715eba66efea27dc443d9dc">mshadow::expr::mask</a></div><div class="ttdeci">MaskExp&lt; IndexExp, SrcExp, DType &gt; mask(const Exp&lt; IndexExp, DType, e1 &gt; &amp;index, const Exp&lt; SrcExp, DType, e2 &gt; &amp;src)</div><div class="ttdef"><b>Definition:</b> mask.h:57</div></div>
<div class="ttc" id="structmshadow_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 &amp; 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="namespacemshadow_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:343</div></div>
<div class="ttc" id="structmshadow_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="structmshadow_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&lt; ReduceWithAxisExp&lt; Reducer, SrcExp, DType, dimsrc, mask, dimdst &gt;, DType &gt;::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="namespacemshadow_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&lt; Reducer, SrcExp, DType, ExpInfo&lt; SrcExp &gt;::kDim, mask, ExpInfo&lt; SrcExp &gt;::kDim - 1 &gt; reduce_with_axis(const Exp&lt; SrcExp, DType, etype &gt; &amp;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="structmshadow_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 &amp;src, int axis)</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:53</div></div>
<div class="ttc" id="structmshadow_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="structmshadow_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="namespacemshadow_1_1expr_html_aefd008a0bf012dc8fb99d9bbcca7a078"><div class="ttname"><a href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">mshadow::expr::MakePlan</a></div><div class="ttdeci">Plan&lt; BinaryMapExp&lt; OP, TA, TB, DType, etype &gt;, DType &gt; MakePlan(const BinaryMapExp&lt; OP, TA, TB, DType, etype &gt; &amp;e)</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:239</div></div>
<div class="ttc" id="namespacemshadow_1_1expr_html_ad91ec561000b979700a507b23e4412e9"><div class="ttname"><a href="namespacemshadow_1_1expr.html#ad91ec561000b979700a507b23e4412e9">mshadow::expr::reduce_keepdim</a></div><div class="ttdeci">ReduceWithAxisExp&lt; Reducer, SrcExp, DType, ExpInfo&lt; SrcExp &gt;::kDim, mask, ExpInfo&lt; SrcExp &gt;::kDim &gt; reduce_keepdim(const Exp&lt; SrcExp, DType, etype &gt; &amp;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="structmshadow_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="namespacemshadow_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:334</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1MakeTensorExp_html_a2a2f9b6b828035ea38bfb8620db42a82"><div class="ttname"><a href="structmshadow_1_1expr_1_1MakeTensorExp.html#a2a2f9b6b828035ea38bfb8620db42a82">mshadow::expr::MakeTensorExp&lt; ReduceWithAxisExp&lt; Reducer, SrcExp, DType, dimsrc, mask, dimdst &gt;, SrcExp, dimdst, DType &gt;::shape_</a></div><div class="ttdeci">Shape&lt; dim &gt; 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="structmshadow_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&lt; ReduceWithAxisExp&lt; Reducer, SrcExp, DType, dimsrc, mask, dimdst &gt;, DType &gt;::Plan</a></div><div class="ttdeci">Plan(const ReduceWithAxisExp&lt; Reducer, SrcExp, DType, dimsrc, mask, dimdst &gt; &amp;e)</div><div class="ttdef"><b>Definition:</b> reduce_with_axis.h:119</div></div>
<div class="ttc" id="structmshadow_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>
<div class="ttc" id="structmshadow_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><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Jan 5 2023 00:58:42 for mxnet by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>