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

A function that appears in a ConditionalDimension, but not in the Operator input is not always being added to the parameters of the Operator. #1298

Closed
georgebisbas opened this issue May 19, 2020 · 0 comments · Fixed by #1421
Assignees

Comments

@georgebisbas
Copy link
Contributor

georgebisbas commented May 19, 2020

A function that appears in a ConditionalDimension, but not in the Operator input is not always beeing added to the parameters of the Operator. May need to run a few times to reproduce.

MFE:

import numpy as np
from devito import ConditionalDimension, Function, Eq, Operator, Dimension
from devito.types import Lt

shape = (8, 8)
x = Dimension(name='x')
y = Dimension(name='y')
g = Function(name='g', shape=shape, dimensions=(x, y), dtype=np.float32)
cond = Lt(g, 2)
ci = ConditionalDimension(name='ci', parent=y, condition=cond)
f = Function(name='f', shape=shape, dimensions=(x, ci))
eq1 = Eq(f, 5)
op = Operator([eq1])
print(op.ccode)
import pdb; pdb.set_trace()
op.apply()

Error log:

Traceback (most recent call last):
  File "tests/mfe_args.py", line 23, in <module>
    op.apply()
  File "/home/gbisbas/workspace/devito/devito/operator/operator.py", line 655, in apply
    args = self.arguments(**kwargs)
  File "/home/gbisbas/workspace/devito/devito/operator/operator.py", line 537, in arguments
    args = self._prepare_arguments(**kwargs)
  File "/home/gbisbas/workspace/devito/devito/operator/operator.py", line 482, in _prepare_arguments
    p._arg_check(args, self._dspace[p])
AttributeError: 'Symbol' object has no attribute '_arg_check'

Hook from @FabioLuporini :

I think I understand the issue above
we’re lacking a small piece of code that searches cd.condition
https://github.com/devitocodes/devito/blob/master/devito/ir/support/utils.py#L144

devito/ir/support/utils.py:144
        for j in candidates:

among candidates there could a ConditionalDimension. That must be searched inside its condition
actually we can make it even simpler a (lowered) expression knows its conditionals: https://github.com/devitocodes/devito/blob/master/devito/ir/equations/equation.py#L159

devito/ir/equations/equation.py:159
        expr._conditionals = tuple(conditionals)

so I think we just need to extend the roots here https://github.com/devitocodes/devito/blob/master/devito/ir/support/utils.py#L131 with the conditionals (if any, clearly; as you know, very often there are none)

devito/ir/support/utils.py:131
            roots.extend(list(i.lhs.indices))

try that, in a separate, self-contained PR, which includes patch + MFE. Thanks!

@georgebisbas georgebisbas changed the title A function that appears in a ConditionalDimension, but not in the Operator input is not always beeing added to the parameters of the Operator. A function that appears in a ConditionalDimension, but not in the Operator input is not always being added to the parameters of the Operator. May 19, 2020
mloubout added a commit that referenced this issue Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants