Skip to content

Commit

Permalink
Revise the condition of ReleaseMatricesAfterForwardProp: only ValueSh…
Browse files Browse the repository at this point in the history
…arable

nodes can be released after forwardprop
  • Loading branch information
Yongqiang Wang committed Jan 12, 2016
1 parent 4b1f800 commit 0b8e30e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/ComputationNetworkLib/ComputationNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
void SetOutputNeededDuringBackprop(bool f) { m_outputNeededDuringBackprop = f; }
bool IsOutputNeededDuringBackprop() const
{
return !g_shareNodeValueMatrices || m_outputNeededDuringBackprop || !isValueSharable();
return !g_shareNodeValueMatrices || m_outputNeededDuringBackprop ;
}

const size_t GetNumInputs() const { return m_inputs.size(); }
Expand Down Expand Up @@ -912,7 +912,7 @@ namespace Microsoft { namespace MSR { namespace CNTK {
//don't release matrices that need to be used in the gradient computation
virtual void ReleaseMatricesAfterForwardProp(MatrixPool& matrixPool)
{
if (!IsOutputNeededDuringBackprop() && (m_value->GetMatrixType() != SPARSE))
if (!IsOutputNeededDuringBackprop() && (m_value->GetMatrixType() != SPARSE) && isValueSharable())
ReleaseMatrixToPool(m_value, matrixPool);
}

Expand Down

0 comments on commit 0b8e30e

Please sign in to comment.