-
Notifications
You must be signed in to change notification settings - Fork 229
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
compiler: Nested indexification #1789
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1789 +/- ##
===========================================
- Coverage 89.54% 58.48% -31.07%
===========================================
Files 209 204 -5
Lines 34037 33504 -533
Branches 4417 4384 -33
===========================================
- Hits 30480 19594 -10886
- Misses 3062 13296 +10234
- Partials 495 614 +119
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In current master you can use directly
eq0 = Eq(u0[u1,y], 2*u0)
to get what you want.
instead of subs(x,u1).
But I like adding this as well.
8532296
to
fec2b3a
Compare
|
I definitely agree. Maybe we should add like a test or two with more complex Eq ? |
u0.data[:, :] = 2 | ||
u1.data[:, :] = 1 | ||
|
||
eq0 = Eq(u0._subs(x, u1), 2*u0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not subs
instead of _subs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh it does the same just quicker through our _subs
that bypass some sympy check and stuff, just habit can switch it.
devito/ir/equations/algorithms.py
Outdated
@@ -160,6 +160,10 @@ def lower_exprs(expressions, **kwargs): | |||
mapper.update(dimension_map) | |||
# Add the user-supplied substitutions | |||
mapper.update(subs) | |||
# Apply mapper to itself for nested indexing | |||
mapper = {k: uxreplace(v, mapper) if k.is_Function else v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this work for doubly (or arbitrarily) nested Functions?
should this not become (somewhat) a recursive call?
going through the whole mapper
here feels weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this not become (somewhat) a recursive call?
Yeah I think so this will only catch single recursion
e8f785b
to
bb9b307
Compare
24f4e0f
to
1b47f15
Compare
@@ -1078,11 +1078,9 @@ def indexify(self, indices=None, lshift=False, subs=None): | |||
subs = subs or {} | |||
subs = [{**{d.spacing: 1, -d.spacing: -1}, **subs} for d in self.dimensions] | |||
|
|||
# Add halo shift | |||
shift = self._size_nodomain.left if lshift else tuple([0]*len(self.dimensions)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh? 😮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested lower_expr takes care of it through the indexed part of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't it apply to subs
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No subs is needed because of sudomain dimension map in lower_expr
, because f.indexe
don't have a subdomain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a great change
does it improve or worsen the compilation speed? try with tti so=16?
5167ad5
to
362ec77
Compare
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
44ffa85
to
7197f81
Compare
…n only appear as index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM!
@@ -30,6 +30,7 @@ | |||
" import gempy as gp\n", | |||
"except ModuleNotFoundError:\n", | |||
" # Need to install these\n", | |||
" ! pip install aiohttp==3.7.1\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does that help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance you checked whether now, we can have working version without installing specific gempy and specific pyvista? @EdCaunt ?
Fxes bug that comes with the test (fails to compile on master since the functuion
u1
only appear as an index and is never lowered and indexified)