Skip to content

Commit

Permalink
Optimize memory usage for EltMulMulAdd operatior
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongkaifu committed Sep 20, 2023
1 parent caff84b commit 71e9372
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Seq2SeqSharp/Tools/ComputeGraphTensor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,26 @@ void backward()
m_backprop.Add(backward);

// These tensors' weights will be used during back-propogation, so we unbind them from the computing graph
m1.UnbindFromComputeGraph();
m2.UnbindFromComputeGraph();
m3.UnbindFromComputeGraph();
m4.UnbindFromComputeGraph();

if (m2.NeedGradient)
{
m1.UnbindFromComputeGraph();
}

if (m1.NeedGradient)
{
m2.UnbindFromComputeGraph();
}

if (m4.NeedGradient)
{
m3.UnbindFromComputeGraph();
}

if (m3.NeedGradient)
{
m4.UnbindFromComputeGraph();
}
}


Expand Down

0 comments on commit 71e9372

Please sign in to comment.