-
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
api: Add Hicks (sinc) interpolation api #2342
Conversation
77bd1b2
to
554aece
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2342 +/- ##
==========================================
- Coverage 86.66% 79.41% -7.26%
==========================================
Files 232 232
Lines 43445 43578 +133
Branches 8063 8072 +9
==========================================
- Hits 37653 34606 -3047
- Misses 5087 8215 +3128
- Partials 705 757 +52 ☔ View full report in Codecov by Sentry. |
f708213
to
0749d57
Compare
2010409
to
ef27943
Compare
|
||
def _arg_defaults(self, coords=None, sfunc=None): | ||
args = {} | ||
b = self._b_table[self.r] |
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 need a catch for r > 10
?
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.
It will just throw a key-error but can add a check (I doubt anyone will run it this high that's a 20x20x20 cube in 3d super expensive)
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.
agree to add a check. Users can be surprising...
82cced0
to
8172aab
Compare
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.
Can we also add an ABox test in PRO?
@@ -48,6 +48,11 @@ jobs: | |||
python3 scripts/clear_devito_cache.py | |||
python3 -m pytest --cov --cov-config=.coveragerc --cov-report=xml -m parallel tests/ | |||
|
|||
- name: Test examples |
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.
for uniformity, "Test examples with MPI" ?
def name(self): | ||
return self._name | ||
|
||
def _arg_defaults(self, **args): |
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.
if we want this method here it would be cleaner to have this class inhereting from ArgProvider.
Perhaps we move it into a subclass?
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, the interpolator isn't an arg provide, its sparse function is and is calling it only.
devito/operations/interpolators.py
Outdated
# Position only replacement, not radius dependent. | ||
# E.g src.inject(vp(x)*src) needs to use vp[posx] at all points | ||
# not vp[posx + rx] | ||
if pos_only is not None: |
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.
if you turn pos_only into pos_only=()
(instead of None) you don't need this if
I think?
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.
Convention throughout is None for kwargs default (for tuple/dict/...)
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, the convention is to use immutable objects only, and tuple in that sense is fine ; dict/list/set aren't instead obv
for example, I'm using =()
in ir/iet/nodes.py
alternatively, you may use as_tuple
|
||
_name = 'sinc' | ||
|
||
# Table 1 |
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.
What's Table 2? u mean Table 1 in the paper?
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.
Yes Table 1 in the paper
|
||
def _arg_defaults(self, coords=None, sfunc=None): | ||
args = {} | ||
b = self._b_table[self.r] |
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.
agree to add a check. Users can be surprising...
coords = coords / np.array(sfunc.grid.spacing) | ||
coords = coords - np.floor(coords) | ||
|
||
# Precompute sinc |
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.
I think this wants a NOTE: <comment about performance>
? if you measured it's slowish? or is it super quick since the loops are very short?
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.
I haven't seen any drastic slow compute since it's numpified so not sure want to force user to be like "hey here is a warning should I nitpick here"
devito/types/sparse.py
Outdated
if interp == 'sinc' and self._radius < 2: | ||
raise ValueError("The 'sinc' interpolator requires a radius of at least 2") | ||
|
||
# Set space ordert to `r` for safety |
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.
order
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.
but not sure why this comment ended up here
@@ -60,21 +60,26 @@ def run(shape=(50, 50, 50), spacing=(20.0, 20.0, 20.0), tn=1000.0, | |||
solver.jacobian(dm, autotune=autotune) | |||
info("Applying Gradient") | |||
solver.jacobian_adjoint(rec, u, autotune=autotune, checkpointing=checkpointing) | |||
return summary.gflopss, summary.oi, summary.timings, [rec, u.data] | |||
return summary.gflopss, summary.oi, summary.timings, [rec, u.data._local] |
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 will pick the (dirty) padding as well I think? why not just data or data_with_halo?
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.
for MPI debug the _local is a lot more useful
z = zfs.parent | ||
|
||
# Functions present in the stencil | ||
funcs = retrieve_functions(rhs) | ||
# Retrieve vertical derivatives |
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.
what's all these new additions?
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.
it does the same, except it only evaluates z
derivatives instead of everything since the rest isn't needed which is much cheaper especially for things like tti.
# Functions present in the stencil | ||
funcs = retrieve_functions(rhs) | ||
# Retrieve vertical derivatives | ||
Dz = {d for d in retrieve_derivatives(rhs) if z in d.dims} |
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.
dzs ?
25721fe
to
2705f26
Compare
devito/operations/interpolators.py
Outdated
# Position only replacement, not radius dependent. | ||
# E.g src.inject(vp(x)*src) needs to use vp[posx] at all points | ||
# not vp[posx + rx] | ||
if pos_only is not None: |
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, the convention is to use immutable objects only, and tuple in that sense is fine ; dict/list/set aren't instead obv
for example, I'm using =()
in ir/iet/nodes.py
alternatively, you may use as_tuple
- name: Test examples with MPI | ||
run: | | ||
docker run --rm -e DEVITO_SAFE_MATH=1 -e DEVITO_MPI=1 -e OMP_NUM_THREADS=1 --name examplerun devito_img mpiexec -n 2 pytest examples/seismic/acoustic |
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.
comment why safe-math needed
devito/operations/interpolators.py
Outdated
# List of indirection indices for all adjacent grid points | ||
idx_subs, temps = self._interp_idx(variables, implicit_dims=implicit_dims) | ||
idx_subs, temps = self._interp_idx(list(fields), implicit_dims=implicit_dims, |
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 does it need to be casted to a list? it was a tuple already, so it feels pretty odd
2705f26
to
353af4f
Compare
Add support for kaiser-windowed sinc interpolation
Fixes #595