blob: 5f48d8febb65944a0c7f139d7c290d952e99888c [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.11"/>
<title>mxnet: /work/mxnet/3rdparty/mshadow/mshadow/extension/take_grad.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>
<script type="text/javascript">
$(document).ready(function() { init_search(); });
</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.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="modules.html"><span>Modules</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File&#160;List</span></a></li>
<li><a href="globals.html"><span>File&#160;Members</span></a></li>
</ul>
</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">take_grad.h</div> </div>
</div><!--header-->
<div class="contents">
<a href="take__grad_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;</div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span>&#160;<span class="preprocessor">#ifndef MSHADOW_EXTENSION_TAKE_GRAD_H_</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span>&#160;<span class="preprocessor">#define MSHADOW_EXTENSION_TAKE_GRAD_H_</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span>&#160;</div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span>&#160;<span class="preprocessor">#include &quot;../extension.h&quot;</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacemshadow.html">mshadow</a> {</div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span>&#160;<span class="keyword">namespace </span>expr {</div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span>&#160;</div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> IndexExp, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType&gt;</div><div class="line"><a name="l00022"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1TakeGradExp.html"> 22</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp</a> : <span class="keyword">public</span> <a class="code" href="structmshadow_1_1expr_1_1Exp.html">Exp</a>&lt;TakeGradExp&lt;IndexExp, SrcExp, DType&gt;,</div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span>&#160; DType, type::kChainer&gt; {</div><div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14"> 25</a></span>&#160; <span class="keyword">const</span> IndexExp &amp;<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">index_</a>;</div><div class="line"><a name="l00027"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1"> 27</a></span>&#160; <span class="keyword">const</span> SrcExp &amp;<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">src_</a>;</div><div class="line"><a name="l00029"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1TakeGradExp.html#a73ea635cf5c185db47fb2260171bc7a9"> 29</a></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_1TakeGradExp.html#a73ea635cf5c185db47fb2260171bc7a9">input_dim_</a>;</div><div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1TakeGradExp.html#a30739e6bde0530de7a4d10c5d22890b3"> 31</a></span>&#160; <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a30739e6bde0530de7a4d10c5d22890b3">TakeGradExp</a>(<span class="keyword">const</span> IndexExp &amp;index, <span class="keyword">const</span> SrcExp &amp;src, <span class="keyword">const</span> <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> input_dim)</div><div class="line"><a name="l00032"></a><span class="lineno"> 32</span>&#160; : index_(index), src_(src), input_dim_(input_dim) {}</div><div class="line"><a name="l00033"></a><span class="lineno"> 33</span>&#160;}; <span class="comment">// struct TakeGradExp</span></div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno"> 35</span>&#160;</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> IndexExp,</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>&#160; <span class="keyword">typename</span> SrcExp,</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>&#160; <span class="keyword">typename</span> DType,</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>&#160; <span class="keywordtype">int</span> e1, <span class="keywordtype">int</span> e2&gt;</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>&#160;<span class="keyword">inline</span> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a></div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="namespacemshadow_1_1expr.html#ae2176ac0df38fd5655ef049c1ca6467e"> 41</a></span>&#160;<a class="code" href="namespacemshadow_1_1expr.html#ae2176ac0df38fd5655ef049c1ca6467e">take_grad</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1Exp.html">Exp&lt;IndexExp, DType, e1&gt;</a> &amp;index,</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>&#160; <span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1Exp.html">Exp&lt;SrcExp, DType, e2&gt;</a> &amp;src,</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span>&#160; <span class="keyword">const</span> <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> input_dim) {</div><div class="line"><a name="l00044"></a><span class="lineno"> 44</span>&#160; <span class="keywordflow">return</span> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a>(index.<a class="code" href="structmshadow_1_1expr_1_1Exp.html#a99e5454eca73df87ecf8b66d3b3470f5">self</a>(),</div><div class="line"><a name="l00045"></a><span class="lineno"> 45</span>&#160; src.<a class="code" href="structmshadow_1_1expr_1_1Exp.html#a99e5454eca73df87ecf8b66d3b3470f5">self</a>(),</div><div class="line"><a name="l00046"></a><span class="lineno"> 46</span>&#160; input_dim);</div><div class="line"><a name="l00047"></a><span class="lineno"> 47</span>&#160;}</div><div class="line"><a name="l00048"></a><span class="lineno"> 48</span>&#160;</div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>&#160;<span class="comment">//----------------------</span></div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span>&#160;<span class="comment">// Execution plan</span></div><div class="line"><a name="l00051"></a><span class="lineno"> 51</span>&#160;<span class="comment">//----------------------</span></div><div class="line"><a name="l00052"></a><span class="lineno"> 52</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno"> 53</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> IndexExp, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType&gt;</div><div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html"> 54</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_1TakeGradExp.html">TakeGradExp</a>&lt;IndexExp, SrcExp, DType&gt;, DType&gt; {</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00056"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html#a92e512833bd483c3d066f43d6cf82b59"> 56</a></span>&#160; <span class="keyword">explicit</span> <a class="code" href="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html#a92e512833bd483c3d066f43d6cf82b59">Plan</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a> &amp;e)</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>&#160; : <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">index_</a>(<a class="code" href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">MakePlan</a>(e.<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">index_</a>)),</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>&#160; <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">src_</a>(<a class="code" href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">MakePlan</a>(e.<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">src_</a>)),</div><div class="line"><a name="l00059"></a><span class="lineno"> 59</span>&#160; batch_size_(<a class="code" href="structmshadow_1_1expr_1_1ShapeCheck.html">ShapeCheck</a>&lt;1, IndexExp&gt;::Check(e.<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">index_</a>)[0]) {</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;</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span>&#160; <span class="comment">// now return shape: in * out</span></div><div class="line"><a name="l00063"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html#a75350a31bb4c8dfa257e333fc0fc314d"> 63</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_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html#a75350a31bb4c8dfa257e333fc0fc314d">Eval</a>(<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> y, <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> x)<span class="keyword"> const </span>{</div><div class="line"><a name="l00064"></a><span class="lineno"> 64</span>&#160; DType ret = 0.f;</div><div class="line"><a name="l00065"></a><span class="lineno"> 65</span>&#160; <span class="keywordflow">for</span> (<a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> i = 0; i &lt; batch_size_; ++i) {</div><div class="line"><a name="l00066"></a><span class="lineno"> 66</span>&#160; <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> idx = <span class="keyword">static_cast&lt;</span><a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a><span class="keyword">&gt;</span>(<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">index_</a>.Eval(0, i));</div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>&#160; <span class="keywordflow">if</span> (idx == y) {</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span>&#160; ret += <span class="keyword">static_cast&lt;</span>DType<span class="keyword">&gt;</span>(<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">src_</a>.Eval(i, x));</div><div class="line"><a name="l00069"></a><span class="lineno"> 69</span>&#160; }</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>&#160; }</div><div class="line"><a name="l00071"></a><span class="lineno"> 71</span>&#160; <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>&#160; }</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; <span class="keyword">private</span>:</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>&#160; <a class="code" href="classmshadow_1_1expr_1_1Plan.html">expr::Plan&lt;IndexExp, DType&gt;</a> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">index_</a>;</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>&#160; <a class="code" href="classmshadow_1_1expr_1_1Plan.html">expr::Plan&lt;SrcExp, DType&gt;</a> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">src_</a>;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>&#160; <span class="keyword">const</span> <a class="code" href="namespacemshadow.html#adcbc2e1131386fccb1474b0bdf045926">index_t</a> batch_size_;</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>&#160;}; <span class="comment">// struct Plan</span></div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>&#160;</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>&#160;</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> IndexExp, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType&gt;</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>&#160;<span class="keyword">inline</span> <a class="code" href="classmshadow_1_1expr_1_1Plan.html">Plan&lt;TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a>, DType&gt;</div><div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="namespacemshadow_1_1expr.html#a7e34e599f5df93e96f20c4cb24f2251c"> 83</a></span>&#160;<a class="code" href="namespacemshadow_1_1expr.html#aefd008a0bf012dc8fb99d9bbcca7a078">MakePlan</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a> &amp;exp) {</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>&#160; <span class="keywordflow">return</span> <a class="code" href="classmshadow_1_1expr_1_1Plan.html">Plan&lt;TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a>, DType&gt;(exp);</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>&#160;}</div><div class="line"><a name="l00086"></a><span class="lineno"> 86</span>&#160;</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>&#160;<span class="keyword">template</span>&lt;<span class="keywordtype">int</span> dim, <span class="keyword">typename</span> IndexExp, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType&gt;</div><div class="line"><a name="l00088"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ShapeCheck_3_01dim_00_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html"> 88</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structmshadow_1_1expr_1_1ShapeCheck.html">ShapeCheck</a>&lt;dim, <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp</a>&lt;IndexExp, SrcExp, DType&gt; &gt; {</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>&#160; <span class="keyword">inline</span> <span class="keyword">static</span> <a class="code" href="structmshadow_1_1Shape.html">Shape&lt;dim&gt;</a></div><div class="line"><a name="l00090"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ShapeCheck_3_01dim_00_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html#a01832f8db3f82b89b62c994dbf12314d"> 90</a></span>&#160; <a class="code" href="structmshadow_1_1expr_1_1ShapeCheck_3_01dim_00_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html#a01832f8db3f82b89b62c994dbf12314d">Check</a>(<span class="keyword">const</span> <a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp&lt;IndexExp, SrcExp, DType&gt;</a> &amp;t) {</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>&#160; CHECK(dim == 2)</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>&#160; &lt;&lt; <span class="stringliteral">&quot;TakeGradExp only support 2D output&quot;</span>;</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>&#160; <span class="comment">// Shape&lt;1&gt; dshape = ShapeCheck&lt;1, IndexExp&gt;::Check(t.index_);</span></div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>&#160; <a class="code" href="structmshadow_1_1Shape.html">Shape&lt;2&gt;</a> gshape = <a class="code" href="structmshadow_1_1expr_1_1ShapeCheck.html#af44e6a3b97cf3b245bc1b7ad4cacb306">ShapeCheck&lt;2, SrcExp&gt;::Check</a>(t.<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">src_</a>);</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>&#160; <a class="code" href="structmshadow_1_1Shape.html">Shape&lt;dim&gt;</a> ret;</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>&#160; ret[0] = t.<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html#a73ea635cf5c185db47fb2260171bc7a9">input_dim_</a>;</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>&#160; ret[1] = gshape[1];</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span>&#160; <span class="keywordflow">return</span> ret;</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>&#160; }</div><div class="line"><a name="l00100"></a><span class="lineno"> 100</span>&#160;}; <span class="comment">// struct ShapeCheck</span></div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>&#160;<span class="keyword">template</span>&lt;<span class="keyword">typename</span> IndexExp, <span class="keyword">typename</span> SrcExp, <span class="keyword">typename</span> DType&gt;</div><div class="line"><a name="l00103"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ExpInfo_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html"> 103</a></span>&#160;<span class="keyword">struct </span><a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo</a>&lt;<a class="code" href="structmshadow_1_1expr_1_1TakeGradExp.html">TakeGradExp</a>&lt;IndexExp, SrcExp, DType&gt; &gt; {</div><div class="line"><a name="l00104"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ExpInfo_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html#a0c7677b7e5f8d3b7c9e948772b82803d"> 104</a></span>&#160; <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> kDim = 2;</div><div class="line"><a name="l00105"></a><span class="lineno"><a class="line" href="structmshadow_1_1expr_1_1ExpInfo_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html#a5d85e8234ca4674137fe3e3840a2cbf8"> 105</a></span>&#160; <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> kDevMask = <a class="code" href="structmshadow_1_1expr_1_1ExpInfo.html">ExpInfo&lt;IndexExp&gt;::kDevMask</a>;</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>&#160;};</div><div class="line"><a name="l00107"></a><span class="lineno"> 107</span>&#160;</div><div class="line"><a name="l00108"></a><span class="lineno"> 108</span>&#160;} <span class="comment">// namespace expr</span></div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>&#160;} <span class="comment">// namespace mshadow</span></div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>&#160;</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span>&#160;<span class="preprocessor">#endif // MSHADOW_EXTENSION_TAKE_GRAD_H_</span></div><div class="ttc" id="structmshadow_1_1expr_1_1TakeGradExp_html_a7107477e31e27194e99302908963cc14"><div class="ttname"><a href="structmshadow_1_1expr_1_1TakeGradExp.html#a7107477e31e27194e99302908963cc14">mshadow::expr::TakeGradExp::index_</a></div><div class="ttdeci">const IndexExp &amp; index_</div><div class="ttdoc">index oprand </div><div class="ttdef"><b>Definition:</b> take_grad.h:25</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:40</div></div>
<div class="ttc" id="structmshadow_1_1Shape_html"><div class="ttname"><a href="structmshadow_1_1Shape.html">mshadow::Shape&lt; dim &gt;</a></div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1TakeGradExp_html_adaed91b0d7a02931bf6d7346deae21c1"><div class="ttname"><a href="structmshadow_1_1expr_1_1TakeGradExp.html#adaed91b0d7a02931bf6d7346deae21c1">mshadow::expr::TakeGradExp::src_</a></div><div class="ttdeci">const SrcExp &amp; src_</div><div class="ttdoc">out gradient oprand </div><div class="ttdef"><b>Definition:</b> take_grad.h:27</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:204</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:244</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1ShapeCheck_3_01dim_00_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4_html_a01832f8db3f82b89b62c994dbf12314d"><div class="ttname"><a href="structmshadow_1_1expr_1_1ShapeCheck_3_01dim_00_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_01_4.html#a01832f8db3f82b89b62c994dbf12314d">mshadow::expr::ShapeCheck&lt; dim, TakeGradExp&lt; IndexExp, SrcExp, DType &gt; &gt;::Check</a></div><div class="ttdeci">static Shape&lt; dim &gt; Check(const TakeGradExp&lt; IndexExp, SrcExp, DType &gt; &amp;t)</div><div class="ttdef"><b>Definition:</b> take_grad.h:90</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:291</div></div>
<div class="ttc" id="namespacemshadow_1_1expr_html_ae2176ac0df38fd5655ef049c1ca6467e"><div class="ttname"><a href="namespacemshadow_1_1expr.html#ae2176ac0df38fd5655ef049c1ca6467e">mshadow::expr::take_grad</a></div><div class="ttdeci">TakeGradExp&lt; IndexExp, SrcExp, DType &gt; take_grad(const Exp&lt; IndexExp, DType, e1 &gt; &amp;index, const Exp&lt; SrcExp, DType, e2 &gt; &amp;src, const index_t input_dim)</div><div class="ttdef"><b>Definition:</b> take_grad.h:41</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1ShapeCheck_html"><div class="ttname"><a href="structmshadow_1_1expr_1_1ShapeCheck.html">mshadow::expr::ShapeCheck</a></div><div class="ttdoc">runtime shape checking template get the shape of an expression, report error if shape mismatch ...</div><div class="ttdef"><b>Definition:</b> expr_engine-inl.h:346</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1TakeGradExp_html"><div class="ttname"><a href="structmshadow_1_1expr_1_1TakeGradExp.html">mshadow::expr::TakeGradExp</a></div><div class="ttdoc">Calculate embedding gradient. </div><div class="ttdef"><b>Definition:</b> take_grad.h:22</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1TakeGradExp_html_a73ea635cf5c185db47fb2260171bc7a9"><div class="ttname"><a href="structmshadow_1_1expr_1_1TakeGradExp.html#a73ea635cf5c185db47fb2260171bc7a9">mshadow::expr::TakeGradExp::input_dim_</a></div><div class="ttdeci">const index_t input_dim_</div><div class="ttdoc">batch size </div><div class="ttdef"><b>Definition:</b> take_grad.h:29</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:61</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1Exp_html_a99e5454eca73df87ecf8b66d3b3470f5"><div class="ttname"><a href="structmshadow_1_1expr_1_1Exp.html#a99e5454eca73df87ecf8b66d3b3470f5">mshadow::expr::Exp::self</a></div><div class="ttdeci">const SubType &amp; self(void) const </div><div class="ttdef"><b>Definition:</b> expression.h:64</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:221</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1TakeGradExp_html_a30739e6bde0530de7a4d10c5d22890b3"><div class="ttname"><a href="structmshadow_1_1expr_1_1TakeGradExp.html#a30739e6bde0530de7a4d10c5d22890b3">mshadow::expr::TakeGradExp::TakeGradExp</a></div><div class="ttdeci">TakeGradExp(const IndexExp &amp;index, const SrcExp &amp;src, const index_t input_dim)</div><div class="ttdoc">constructor </div><div class="ttdef"><b>Definition:</b> take_grad.h:31</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4_html_a75350a31bb4c8dfa257e333fc0fc314d"><div class="ttname"><a href="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html#a75350a31bb4c8dfa257e333fc0fc314d">mshadow::expr::Plan&lt; TakeGradExp&lt; IndexExp, SrcExp, DType &gt;, DType &gt;::Eval</a></div><div class="ttdeci">MSHADOW_XINLINE DType Eval(index_t y, index_t x) const </div><div class="ttdef"><b>Definition:</b> take_grad.h:63</div></div>
<div class="ttc" id="namespacemshadow_html"><div class="ttname"><a href="namespacemshadow.html">mshadow</a></div><div class="ttdoc">namespace for mshadow </div><div class="ttdef"><b>Definition:</b> base.h:282</div></div>
<div class="ttc" id="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4_html_a92e512833bd483c3d066f43d6cf82b59"><div class="ttname"><a href="structmshadow_1_1expr_1_1Plan_3_01TakeGradExp_3_01IndexExp_00_01SrcExp_00_01DType_01_4_00_01DType_01_4.html#a92e512833bd483c3d066f43d6cf82b59">mshadow::expr::Plan&lt; TakeGradExp&lt; IndexExp, SrcExp, DType &gt;, DType &gt;::Plan</a></div><div class="ttdeci">Plan(const TakeGradExp&lt; IndexExp, SrcExp, DType &gt; &amp;e)</div><div class="ttdef"><b>Definition:</b> take_grad.h:56</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Mar 28 2020 00:52:29 for mxnet by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>