Skip to content

Commit

Permalink
Fix memory leak when not consuming output of the reversible block
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinBruegger committed Sep 15, 2019
1 parent c1a8577 commit 2b6417d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion revtorch/revtorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def forward(ctx, x, reversible_blocks):
for block in reversible_blocks:
assert (isinstance(block, ReversibleBlock))
x = block(x)
ctx.y = x #not using ctx.save_for_backward(x) saves us memory by beeing able to free ctx.y earlier in the backward pass
ctx.y = x.detach() #not using ctx.save_for_backward(x) saves us memory by beeing able to free ctx.y earlier in the backward pass
ctx.reversible_blocks = reversible_blocks
return x

Expand Down

0 comments on commit 2b6417d

Please sign in to comment.