-
Notifications
You must be signed in to change notification settings - Fork 230
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
Check legality of symbolic derivatives #1578
Comments
@FabioLuporini, as far as I understood the problem, we could just check |
We could check it in @property
def evaluate(self):
# Evaluate finite-difference.
# Note: evaluate and _eval_fd splitted for potential future different
# types of discretizations.
do = self.deriv_order
if isinstance(do,int): do = (do,)
for i, d in enumerate(self.dims):
expr_order = self.expr.time_order if d.is_Time else self.expr.space_order
if do[i] > expr_order:
raise ValueError("Expression order must be equal or greater than "
"Derivative order")
return self._eval_fd(self.expr) Here is the MFE I'm testing. If any of the functions have space or time order lower than derivative, the patch will get it. from devito import (Grid, TimeFunction, Eq, Operator)
grid = Grid(tuple([11]*2))
u = TimeFunction(name="u", grid=grid, space_order=2, time_order=2)
m = TimeFunction(name="m", grid=grid, space_order=1, time_order=1)
# op = Operator(Eq(u.forward,u.biharmonic(1/m)))
# op = Operator(Eq(u.forward,(u * m).dx2))
op = Operator(Eq(u.forward,(u * m).dt2))
op.apply(time=0) |
For example, if we do:
and
m
was not initialized with "sufficient" space order, then OOB accesses will be generated, and segfaults will happenhow to fix: make sure in the DSL layer we always check that we're not applying differential operators to arguments that would result in illegal code
The text was updated successfully, but these errors were encountered: