Skip to content

Commit

Permalink
Merge pull request #2169 from devitocodes/implicit-dim-no-eq
Browse files Browse the repository at this point in the history
compiler: prevent Eq dims to be lost if only implicit
  • Loading branch information
mloubout authored Jul 24, 2023
2 parents 0adb92e + 4759473 commit 65dc7d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion devito/ir/clusters/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def used_dimensions(self):
example, reduction or redundant (i.e., invariant) Dimensions won't
appear in an expression.
"""
return {i for i in self.free_symbols if i.is_Dimension}
idims = set.union(*[set(e.implicit_dims) for e in self.exprs])
return {i for i in self.free_symbols if i.is_Dimension} | idims

@cached_property
def scope(self):
Expand Down
13 changes: 13 additions & 0 deletions tests/test_dse.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,19 @@ def test_contracted(self, exprs, expected, visit):
for j in trees] == expected
assert "".join(mapper.get(i.dim.name, i.dim.name) for i in iters) == visit

def test_implicit_only(self):
grid = Grid(shape=(5, 5))
time = grid.time_dim
u = TimeFunction(name="u", grid=grid, time_order=1)
idimeq = Eq(Symbol('s'), 1, implicit_dims=time)

op = Operator([Eq(u.forward, u + 1.), idimeq])
trees = retrieve_iteration_tree(op)

assert len(trees) == 2
assert_structure(op, ['t,x,y', 't'], 'txy')
assert trees[1].dimensions == [time]


class TestAliases(object):

Expand Down

0 comments on commit 65dc7d8

Please sign in to comment.