Stash computed form on tensor for re-assembly - #244
Merged
Conversation
When passing in a tensor to assemble, stash the form and computed kernels on the tensor such that if we reassemble the same form on the same tensor we save having to preprocess/split the form again.
Contributor
There was a problem hiding this comment.
Is this safe? I would have thought that we can use the same tensor to assemble a different form as long as the function spaces match. I think this means the following would fail:
v = TestFunction(V)
f = assemble(v*dx)
# do stuff with f
f = assemble(Constant(2)*v*dx, tensor=f)Now the second time f is v_dx, not 2_v*dx
Contributor
There was a problem hiding this comment.
You could check by:
if blah and form is tensor._form:
...I think
Contributor
Author
There was a problem hiding this comment.
Isn't that exactly what I'm doing? Note that the check in line 389 is identical to this:
if hasattr(tensor, "_form") and hasattr(tensor, "_kernels") and tensor._form is f
Contributor
|
Ah. I misread the first getattr as hasattr |
Contributor
Author
|
I've added the test you mentioned and another one assembling a bilinear form into a pre-existing tensor. |
Member
|
I think this can land. |
kynan
added a commit
that referenced
this pull request
Apr 9, 2014
…tensor Stash computed form on tensor for re-assembly
connorjward
added a commit
that referenced
this pull request
Dec 4, 2024
* Don't help loopy scheduling with priorities The API for accessing instructions changed and keeping this optimisation has been deemed unnecessary. API Change details: A Program is a collection of LoopKernels now where you specify which kernel's instructions you intend to query: So instead of program.instructions[0] it would be program["kernel_name"].instructions[0] * Save names of kernels that tsfc generates * Fix failing test due to API change * Use make_function to build loopy kernel * translate gem.Inverse to "inverse", not "inv" in loopy * set lang_version when generating loopy kernel * COFFEE kernelbuilder sets name * Testing: set loopy to correct branch. * Testing: Fix egg information of loopy? * Jenkins * Drop package branches. * Update docstring Co-authored-by: Lawrence Mitchell <lawrence@wence.uk> Co-authored-by: Connor Ward <c.ward20@imperial.ac.uk> Co-authored-by: Sophia Vorderwuelbecke <sv2518@ic.ac.uk>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When passing in a tensor to assemble, stash the form and computed kernels on
the tensor such that if we reassemble the same form on the same tensor we save
having to preprocess/split the form again.