Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added pyadjoint/.DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions pyadjoint/block_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def __init__(self, output):
self.creation_timestep = -1
# The timestep during which this variable was last used as an input.
self.last_use = -1
# Whether this variable is adjoint dependency.
self.is_adjoint_dependency = False

def add_adj_output(self, val):
if self.adj_value is None:
Expand Down Expand Up @@ -82,6 +84,7 @@ def will_add_as_output(self):
if tape._eagerly_checkpoint_outputs:
self.save_output()
tape.add_to_adjoint_dependencies(self, self.last_use - 1)
self.is_adjoint_dependency = True

def __str__(self):
return str(self.output._ad_str)
Expand Down
2 changes: 1 addition & 1 deletion pyadjoint/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _(self, cp_action, progress_bar, functional=None, **kwargs):

# Handle the case for SingleMemoryStorageSchedule
if isinstance(self._schedule, SingleMemoryStorageSchedule):
if step > 1 and var not in self.tape.timesteps[step - 1].adjoint_dependencies:
if not var.is_adjoint_dependency:
var._checkpoint = None
continue

Expand Down