<p>When implementing sparse autoencoder by FNN, I find out there are some copy could be eliminated, I think the first one should be deal with is the Forward function.</p>

<pre><code>template&lt;size_t I = 0, typename DataType, typename... Tp&gt;
void Forward(const DataType&amp; input, std::tuple&lt;Tp...&gt;&amp; t)
{
  std::get&lt;I&gt;(t).InputParameter() = input;    
  //.......
}
</code></pre>

<p>The input data could be quite big(several MB or GB), it would be better if we could eliminate this copy. If there are another api like</p>

<pre><code>std::get&lt;I&gt;(t).InputParameter(input);
</code></pre>

<p>Then it is possible to use a pointer point to the input if we know the input would not modified, but this would <br>
1 : add one more api to the layers<br>
2 : part of the layers may need another template parameter to determine the input parameter is const or not(I am not sure about this part).</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/451#issuecomment-164124569">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFMhWsx5Ilhn6BIVId71EonTdpCKuks5pO82HgaJpZM4GAqt4.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/mlpack/mlpack/pull/451#issuecomment-164124569"></link>
  <meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>