Skip to content

Commit

Permalink
dsl: tweak reconstruction of sparse functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Aug 25, 2023
1 parent d7d2040 commit 2752814
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions devito/types/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ def __shape_setup__(cls, **kwargs):
shape = (glb_npoint[grid.distributor.myrank],)
return shape

def func(self, *args, **kwargs):
# Rebuild subfunctions first to avoid new data creation as we have to use `_data`
# as a reconstruction kwargs to avoid the circular dependency
# with the parent in SubFunction
# This is also necessary to avoid shaoe issue in the SubFunction with mpi
for s in self._sub_functions:
if getattr(self, s) is not None:
kwargs.update({s: getattr(self, s).func(*args, **kwargs)})
return super().func(*args, **kwargs)

def __fd_setup__(self):
"""
Dynamically add derivative short-cuts.
Expand Down
2 changes: 1 addition & 1 deletion requirements-optional.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
matplotlib
pandas
pyrevolve
pyrevolve==2.2.3
scipy
distributed

0 comments on commit 2752814

Please sign in to comment.