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.
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
Pytorch coupling #2804
Pytorch coupling #2804
Changes from 56 commits
6535f0a
754f5d6
f1e37fd
ce9ac31
a72a06e
cd5f11d
f388b88
422b1d5
0288d0a
e01fec5
22f654c
6c2072b
0fa8738
0772a41
d5eca47
a0e3ea8
da5b052
e819524
76e7f89
2dfb9b8
0f511d7
ad7a008
2e6c230
625ef3c
b57e6b3
369c070
8764522
8bde10b
d520c28
89ba376
97d1001
125cff9
06ea7f4
8d75d6d
1dd095c
01627ec
d139c5a
cf6dc5a
aef4c11
b19eaae
a417a39
1ef3919
d51158a
e5876c4
6bf1e2f
a465d93
19b7b65
d3448bd
b4d7f48
9304bf5
9fdcd1a
7791fb5
4e4d6aa
ef5b67b
78bdd89
ec74361
c0a7dcd
8d04288
ce8a99b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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's rather restrictive to wrap only reduced functionals. Do you plan to extend this to arbitrary Firedrake programs?
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.
Despite the name, which is historic, ReducedFunctional can return any overloaded type. This means that this does enable wrapping of arbitrary Firedrake code. ReducedFunctional is simply the mechanism for expressing a Firedrake calculation as a function of controls, which is what you need if you're going to differentiate through 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.
I see. So it's possible to send a function that returns the result of
solve(F == 0, u, bcs=bcs)
to ReducedFunctional? I was confused with the test in this PR that uses a function namedsolve_poisson
but returnsassemble(u ** 2 * dx)
instead of just returningu
:firedrake/tests/regression/test_pytorch_coupling.py
Lines 86 to 95 in f05d119
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, you can. The output doesn't need to be scalar-valued as illustrated in the other test (
poisson_residual
):firedrake/tests/regression/test_pytorch_coupling.py
Lines 78 to 82 in f05d119