<blockquote>
<p>I think that in this case, moving the calculation of scale outside of Forward() may not actually give any noticeable runtime improvement</p>
</blockquote>
<p>I have same opinion on this one</p>
<blockquote>
<p>creating the mask object is going to take some amount of memory</p>
</blockquote>
<p>This one I am not sure how good the optimization of armadillo can do, it would do things like</p>
<p>arma::mat randomMat;// build a random matrix<br>
mask = randomMat; //copy the data of randomMat to mask</p>
<p>or overwrite the data of mask directly since the mask already allocate the buffer?</p>
<p>I do a small test on this</p>
<pre><code>int main()
{
arma::mat temp;
while(1){
temp = arma::randu<arma::mat>(1000, 1000);
}
}
</code></pre>
<p>Then open the task manager on win8 and observe the usage of memory, it is always 8.3MB<br>
So I guess armadillo5.x(or the compiler) do smart enough to avoid memory allocation under this case.</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/mlpack/mlpack/pull/463#issuecomment-151359514">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AJ4bFMm8ndqmqe8JoBtHrrNi4Rs2JNlWks5o_uMmgaJpZM4GSg7s.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/463#issuecomment-151359514"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>