Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: Fix gpu-fit for multiple tensors #2286

Merged
merged 1 commit into from
Dec 19, 2023
Merged
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
3 changes: 2 additions & 1 deletion devito/core/gpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ def _normalize_kwargs(cls, **kwargs):
def _normalize_gpu_fit(cls, oo, **kwargs):
try:
gfit = as_tuple(oo.pop('gpu-fit'))
gfit = set().union([f.values() if f.is_AbstractTensor else f for f in gfit])
gfit = set().union(*[f.values() if f.is_AbstractTensor else [f]
for f in gfit])
return tuple(gfit)
except KeyError:
if any(i in kwargs['mode'] for i in ['tasking', 'streaming']):
Expand Down
9 changes: 9 additions & 0 deletions tests/test_gpu_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,13 +1428,22 @@ def test_gpu_fit_w_tensor_functions(self):

u = TensorTimeFunction(name='u', grid=grid)
usave = TensorTimeFunction(name="usave", grid=grid, save=10)
usave2 = TensorTimeFunction(name="usave2", grid=grid, save=10)

eqns = [Eq(u.forward, u + 1),
Eq(usave, u.forward)]

op = Operator(eqns, opt=('noop', {'gpu-fit': usave}))
assert set(op._options['gpu-fit']) - set(usave.values()) == set()

eqns = [Eq(u.forward, u + 1),
Eq(usave, u.forward),
Eq(usave2, u.forward)]

op = Operator(eqns, opt=('noop', {'gpu-fit': [usave, usave2]}))
vals = set().union(usave.values(), usave2.values())
assert set(op._options['gpu-fit']) - vals == set()


class TestMisc(object):

Expand Down
Loading