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

builtins: Support batched initialize_function #2176

Merged
merged 2 commits into from
Sep 8, 2023
Merged

Conversation

FabioLuporini
Copy link
Contributor

No description provided.

@FabioLuporini FabioLuporini added the API api (symbolics, types, ...) label Aug 1, 2023
@FabioLuporini FabioLuporini requested a review from mloubout August 1, 2023 09:20
@codecov
Copy link

codecov bot commented Aug 1, 2023

Codecov Report

Merging #2176 (4f62b4d) into master (40975d2) will increase coverage by 0.01%.
The diff coverage is 93.47%.

@@            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     
Files Changed Coverage Δ
devito/builtins/initializers.py 92.45% <90.90%> (+1.54%) ⬆️
devito/operations/interpolators.py 98.02% <100.00%> (ø)
devito/types/basic.py 92.07% <100.00%> (-0.10%) ⬇️
tests/test_builtins.py 100.00% <100.00%> (ø)
tests/test_symbolics.py 100.00% <100.00%> (ø)

... 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`")
Copy link
Contributor

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)

nbl, slices = nbl_to_padsize(nbl, function.ndim)
if isinstance(data, dv.Function):
function.data[slices] = data.data[:]
for f in functions:
Copy link
Contributor

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)


assign(lhs, rhs, options=options, name=name, **kwargs)
name = name or 'pad_%s' % '_'.join(f.name for f in functions)
Copy link
Contributor

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")
Copy link
Contributor

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?


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)
Copy link
Contributor

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

@mloubout mloubout force-pushed the builtin-batching branch 2 times, most recently from 9b7282a to 1637084 Compare September 7, 2023 18:19
@mloubout mloubout self-requested a review September 7, 2023 23:18
@FabioLuporini FabioLuporini merged commit a7c3446 into master Sep 8, 2023
32 checks passed
@FabioLuporini FabioLuporini deleted the builtin-batching branch September 8, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API api (symbolics, types, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants