Skip to content

Commit

Permalink
Update GradientTape.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
HamletTanyavong committed Nov 8, 2023
1 parent c29e05e commit 030907c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Mathematics.NET/AutoDiff/GradientTape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ static void CheckForCancellation(CancellationToken cancellationToken)
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
public void ReverseAccumulation(out ReadOnlySpan<Real> gradients, double seed = 1.0)
{
if (_variableCount == 0)
{
throw new Exception("Gradient tape contains no nodes");
}

ReadOnlySpan<Node> nodesAsSpan = CollectionsMarshal.AsSpan(_nodes);
ref var start = ref MemoryMarshal.GetReference(nodesAsSpan);

Expand Down

0 comments on commit 030907c

Please sign in to comment.