From 321c6dd0eeaae95f45c71414e494a9769d67c5bf Mon Sep 17 00:00:00 2001 From: mloubout Date: Mon, 24 Jul 2023 08:35:26 -0400 Subject: [PATCH] compiler: prevent Eq dims to be lost if only implicit --- devito/ir/equations/equation.py | 4 ++++ tests/test_dse.py | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/devito/ir/equations/equation.py b/devito/ir/equations/equation.py index a360132c1be..df2210cf5bb 100644 --- a/devito/ir/equations/equation.py +++ b/devito/ir/equations/equation.py @@ -31,6 +31,10 @@ def ispace(self): def dimensions(self): return set(self.ispace.dimensions) + @cached_property + def free_symbols(self): + return super().free_symbols | set(self.implicit_dims) + @property def implicit_dims(self): return self._implicit_dims diff --git a/tests/test_dse.py b/tests/test_dse.py index eee0027896b..b1ed9394ec3 100644 --- a/tests/test_dse.py +++ b/tests/test_dse.py @@ -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):