blob: 25f25e27c6736b81889307156ddb5cd076b2021a [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: mxnet::Operator Class Reference</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="namespacemxnet.html">mxnet</a></li><li class="navelem"><a class="el" href="classmxnet_1_1Operator.html">Operator</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classmxnet_1_1Operator-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">mxnet::Operator Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div> </div>
</div><!--header-->
<div class="contents">
<p><a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a> interface. <a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a> defines basic operation unit of optimized computation graph in mxnet. This interface relies on pre-allocated memory in <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a>, the caller need to set the memory region in <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a> correctly before calling Forward and Backward.
<a href="classmxnet_1_1Operator.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="include_2mxnet_2operator_8h_source.html">operator.h</a>&gt;</code></p>
<div class="dynheader">
Collaboration diagram for mxnet::Operator:</div>
<div class="dyncontent">
<div class="center"><img src="classmxnet_1_1Operator__coll__graph.png" border="0" usemap="#mxnet_1_1Operator_coll__map" alt="Collaboration graph"/></div>
<map name="mxnet_1_1Operator_coll__map" id="mxnet_1_1Operator_coll__map">
</map>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a4d34cc792d7271bd8b5b60eaa0b55767"><td class="memItemLeft" align="right" valign="top">virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmxnet_1_1Operator.html#a4d34cc792d7271bd8b5b60eaa0b55767">~Operator</a> ()</td></tr>
<tr class="memdesc:a4d34cc792d7271bd8b5b60eaa0b55767"><td class="mdescLeft">&#160;</td><td class="mdescRight">destructor <a href="#a4d34cc792d7271bd8b5b60eaa0b55767">More...</a><br /></td></tr>
<tr class="separator:a4d34cc792d7271bd8b5b60eaa0b55767"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3dbe23d985df86da51eeb868439872dd"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmxnet_1_1Operator.html#a3dbe23d985df86da51eeb868439872dd">Forward</a> (const <a class="el" href="structmxnet_1_1OpContext.html">OpContext</a> &amp;ctx, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;in_data, const std::vector&lt; <a class="el" href="namespacemxnet.html#a7cd7094ef222e9ae1f520c3b6a214398">OpReqType</a> &gt; &amp;req, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;out_data, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;aux_states)=0</td></tr>
<tr class="memdesc:a3dbe23d985df86da51eeb868439872dd"><td class="mdescLeft">&#160;</td><td class="mdescRight">perform a forward operation of <a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a>, save the output to <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a>. <a href="#a3dbe23d985df86da51eeb868439872dd">More...</a><br /></td></tr>
<tr class="separator:a3dbe23d985df86da51eeb868439872dd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad32d74b9bf56caf920b5e6379d2bb259"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmxnet_1_1Operator.html#ad32d74b9bf56caf920b5e6379d2bb259">Backward</a> (const <a class="el" href="structmxnet_1_1OpContext.html">OpContext</a> &amp;ctx, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;out_grad, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;in_data, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;out_data, const std::vector&lt; <a class="el" href="namespacemxnet.html#a7cd7094ef222e9ae1f520c3b6a214398">OpReqType</a> &gt; &amp;req, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;in_grad, const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;aux_states)</td></tr>
<tr class="memdesc:ad32d74b9bf56caf920b5e6379d2bb259"><td class="mdescLeft">&#160;</td><td class="mdescRight">Perform a Backward Operation, write gradient to the in_grad. <a href="#ad32d74b9bf56caf920b5e6379d2bb259">More...</a><br /></td></tr>
<tr class="separator:ad32d74b9bf56caf920b5e6379d2bb259"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa6b4c247a914b4659c773965248019c7"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="namespacemxnet.html#ad7801fb2dd68294d4c7a9e289bc071ad">ExecType</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmxnet_1_1Operator.html#aa6b4c247a914b4659c773965248019c7">exec_type</a> () const final</td></tr>
<tr class="separator:aa6b4c247a914b4659c773965248019c7"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p><a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a> interface. <a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a> defines basic operation unit of optimized computation graph in mxnet. This interface relies on pre-allocated memory in <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a>, the caller need to set the memory region in <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a> correctly before calling Forward and Backward. </p>
<p><a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a> is generated by <a class="el" href="classmxnet_1_1OperatorProperty.html" title="OperatorProperty is a object that stores all information about Operator. It also contains method to g...">OperatorProperty</a>. To add new operator(aka. layers of neural nets) to mxnet, developer need to create a new <a class="el" href="classmxnet_1_1OperatorProperty.html" title="OperatorProperty is a object that stores all information about Operator. It also contains method to g...">OperatorProperty</a> and its corresponding <a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a>.</p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a>, <a class="el" href="classmxnet_1_1TShape.html" title="A Shape class that is used to represent shape of each tensor. ">mxnet::TShape</a>, <a class="el" href="classmxnet_1_1OperatorProperty.html" title="OperatorProperty is a object that stores all information about Operator. It also contains method to g...">OperatorProperty</a> </dd></dl>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a4d34cc792d7271bd8b5b60eaa0b55767"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4d34cc792d7271bd8b5b60eaa0b55767">&#9670;&nbsp;</a></span>~Operator()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual mxnet::Operator::~Operator </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>destructor </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="ad32d74b9bf56caf920b5e6379d2bb259"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad32d74b9bf56caf920b5e6379d2bb259">&#9670;&nbsp;</a></span>Backward()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void mxnet::Operator::Backward </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structmxnet_1_1OpContext.html">OpContext</a> &amp;&#160;</td>
<td class="paramname"><em>ctx</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>out_grad</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>in_data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>out_data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="namespacemxnet.html#a7cd7094ef222e9ae1f520c3b6a214398">OpReqType</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>req</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>in_grad</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>aux_states</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Perform a Backward Operation, write gradient to the in_grad. </p>
<dl class="section note"><dt>Note</dt><dd>Convention: out_grad.size() == <a class="el" href="classmxnet_1_1OperatorProperty.html#a006f0e2c9b3f934e1f73b242b7e8b062" title="get number of visible return values during Symbol creation. If NumVisibleOutputs() = k...">OperatorProperty.NumVisibleOutputs()</a> out_data.size() == <a class="el" href="classmxnet_1_1OperatorProperty.html#a9fc6e9f04f52b1c05f62fb7357bb95c4">OperatorProperty.NumOutputs()</a> out_data can contain additional invisible returns that remembers the state carried from the Forward pass. For example mask in the dropout. The gradients are passed from visible returns in this function.</dd></dl>
<dl class="section user"><dt></dt><dd>Not all the TBlobs in the arguments will be available if you override the DeclareBackwardDependency of corresponding <a class="el" href="classmxnet_1_1OperatorProperty.html" title="OperatorProperty is a object that stores all information about Operator. It also contains method to g...">OperatorProperty</a> class. Only the dependencies you declared will be available at corresponding position, the rest of the parameters are simply dummy where you will get a nullptr. You will be safe if you use the default DeclareBackwardDependency. But only declare what you need will give engine more chance for optimization.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>runtime context available to this call </td></tr>
<tr><td class="paramname">out_grad</td><td>the gradient value we get from of the <a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a>. </td></tr>
<tr><td class="paramname">in_data</td><td>the array of input data. </td></tr>
<tr><td class="paramname">out_data</td><td>the array of output data. </td></tr>
<tr><td class="paramname">req</td><td>request types of the saving operation, can be all types. </td></tr>
<tr><td class="paramname">in_grad</td><td>the array of gradient we need to write to. </td></tr>
<tr><td class="paramname">aux_states</td><td>Auxiliary states of operator. Normally operator doesn't need </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classmxnet_1_1OperatorProperty.html" title="OperatorProperty is a object that stores all information about Operator. It also contains method to g...">OperatorProperty</a>, <a class="el" href="namespacemxnet.html#a7cd7094ef222e9ae1f520c3b6a214398" title="operation request type to Forward and Backward ">OpReqType</a>, <a class="el" href="structmxnet_1_1OpContext.html" title="All the possible information needed by Operator.Forward and Backward This is the superset of RunConte...">OpContext</a> </dd></dl>
</div>
</div>
<a id="aa6b4c247a914b4659c773965248019c7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa6b4c247a914b4659c773965248019c7">&#9670;&nbsp;</a></span>exec_type()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual <a class="el" href="namespacemxnet.html#ad7801fb2dd68294d4c7a9e289bc071ad">ExecType</a> mxnet::Operator::exec_type </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">final</span><span class="mlabel">virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>[Deprecated] execution type of the operator </dd></dl>
</div>
</div>
<a id="a3dbe23d985df86da51eeb868439872dd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3dbe23d985df86da51eeb868439872dd">&#9670;&nbsp;</a></span>Forward()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">virtual void mxnet::Operator::Forward </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="structmxnet_1_1OpContext.html">OpContext</a> &amp;&#160;</td>
<td class="paramname"><em>ctx</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>in_data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="namespacemxnet.html#a7cd7094ef222e9ae1f520c3b6a214398">OpReqType</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>req</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>out_data</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::vector&lt; <a class="el" href="classmxnet_1_1TBlob.html">TBlob</a> &gt; &amp;&#160;</td>
<td class="paramname"><em>aux_states</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">pure virtual</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>perform a forward operation of <a class="el" href="classmxnet_1_1Operator.html" title="Operator interface. Operator defines basic operation unit of optimized computation graph in mxnet...">Operator</a>, save the output to <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">ctx</td><td>runtime context available to this call </td></tr>
<tr><td class="paramname">in_data</td><td>array of input data, it is const </td></tr>
<tr><td class="paramname">req</td><td>the request types of saving operation, can only be kWriteTo or kWriteInplace. </td></tr>
<tr><td class="paramname">out_data</td><td>array of output data, pointer is used to indicate that this is holder the space of <a class="el" href="classmxnet_1_1TBlob.html" title="tensor blob class that can be used to hold tensor of any dimension, any device and any data type...">TBlob</a> in out_data must be pre-allocated with InferShape </td></tr>
<tr><td class="paramname">aux_states</td><td>Auxiliary states of operator. Normally operator doesn't need, epecial case like Batch Norm requires. </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="namespacemxnet.html#a7cd7094ef222e9ae1f520c3b6a214398" title="operation request type to Forward and Backward ">OpReqType</a>, <a class="el" href="structmxnet_1_1OpContext.html" title="All the possible information needed by Operator.Forward and Backward This is the superset of RunConte...">OpContext</a> </dd></dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>/work/mxnet/include/mxnet/<a class="el" href="include_2mxnet_2operator_8h_source.html">operator.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Jan 5 2023 00:58:44 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>