-
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
builtins: Support batched initialize_function #2176
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2176 +/- ##
==========================================
+ Coverage 87.06% 87.08% +0.01%
==========================================
Files 228 228
Lines 40539 40579 +40
Branches 7412 7419 +7
==========================================
+ Hits 35295 35337 +42
Misses 4642 4642
+ Partials 602 600 -2
... and 1 file with indirect coverage changes 📢 Have feedback on the report? Share it here. |
if isinstance(function, dv.TimeFunction): | ||
if isinstance(function, (list, tuple)): | ||
if not isinstance(data, (list, tuple)): | ||
raise TypeError("Expected a list of `data`") |
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 we could support this case for init([f,g,h], data)
(ie all function initialized to smae data) with just data = [data]*len(function)
devito/builtins/initializers.py
Outdated
nbl, slices = nbl_to_padsize(nbl, function.ndim) | ||
if isinstance(data, dv.Function): | ||
function.data[slices] = data.data[:] | ||
for f in functions: |
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 (f, d) in zip(functions, datas)
devito/builtins/initializers.py
Outdated
|
||
assign(lhs, rhs, options=options, name=name, **kwargs) | ||
name = name or 'pad_%s' % '_'.join(f.name for f in functions) |
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.
would use "init" instead of pad as the generic case
(len(function), len(data))) | ||
|
||
if mapper is not None: | ||
raise NotImplementedError("Unsupported `mapper` with batching") |
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.
Not even one mapper per function?
tests/test_builtins.py
Outdated
|
||
f = Function(name='f', grid=grid, dtype=np.int32) | ||
g = Function(name='g', grid=grid, dtype=np.int32) | ||
h = Function(name='h', grid=grid, dtype=np.int32) |
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.
Would mix dtype to test "general" case
2bd0034
to
9b9edb5
Compare
9b7282a
to
1637084
Compare
1637084
to
4f62b4d
Compare
No description provided.