Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dc14436
Does this should be optional?
Ig-dolci Feb 14, 2025
c838418
A hack before understand argument_slots
Ig-dolci Feb 14, 2025
e6d87f6
Checking argument_slots; Adding docs; testing actions results for pyt…
Ig-dolci Feb 17, 2025
ee001ce
More docs
Ig-dolci Feb 17, 2025
7278949
Fix docs
Ig-dolci Feb 17, 2025
8249bf4
Enable CI tests for optional installed packages
Ig-dolci Feb 18, 2025
96fc8e5
docs
Ig-dolci Feb 18, 2025
e48501c
docs
Ig-dolci Feb 18, 2025
09003f6
Test ufl Pablo's fixing
Ig-dolci Feb 19, 2025
df1ee6b
merge master
Ig-dolci Feb 19, 2025
3aa5939
More assert; Increase tolerance to reduce test runtime
Ig-dolci Feb 19, 2025
1469403
just a test
Ig-dolci Feb 19, 2025
aca9860
install jaxlib
Ig-dolci Feb 19, 2025
ef6e4d2
Test another jax install requirement for linux
Ig-dolci Feb 19, 2025
d52431c
wip
Ig-dolci Feb 19, 2025
a50cea8
wip
Ig-dolci Feb 19, 2025
a094d88
wip
Ig-dolci Feb 19, 2025
22be7c4
wip
Ig-dolci Feb 19, 2025
6d3b726
será?
Ig-dolci Feb 19, 2025
f11a99e
será?
Ig-dolci Feb 19, 2025
b5f7080
test
Ig-dolci Feb 20, 2025
24c757c
test
Ig-dolci Feb 20, 2025
fe649de
Use options={riesz_representation: None}
Ig-dolci Feb 20, 2025
65289a2
Jax install fixing
Ig-dolci Feb 20, 2025
2c4f227
Merge branch 'master' into dolci/jax_ml_operator
Ig-dolci Feb 20, 2025
fa4c380
Update scripts/firedrake-install
Ig-dolci Feb 20, 2025
8b50efd
Switch ufl branch
pbrubeck Feb 21, 2025
0e00379
review
Ig-dolci Feb 21, 2025
6c477d8
review
Ig-dolci Feb 21, 2025
d613eb2
review
Ig-dolci Feb 21, 2025
6762c85
Update .github/workflows/build.yml
pbrubeck Feb 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion firedrake/ml/jax/ml_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ def _pre_forward_callback(self, *operands: Union[Function, Cofunction], unsqueez

def _post_forward_callback(self, y_P: "jax.Array") -> Union[Function, Cofunction]:
"""Callback function to convert the JAX output of the ML model to a Firedrake function."""
space = self.ufl_function_space()
if isinstance(self._argument_slots[0], Cofunction):
space = self.ufl_operands[0].function_space().dual()
else:
space = self.ufl_function_space()
return from_jax(y_P, space)

# -- JAX routines for computing AD-based quantities -- #
Expand Down
6 changes: 5 additions & 1 deletion firedrake/ml/pytorch/ml_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ def _pre_forward_callback(self, *operands, unsqueeze=False):

def _post_forward_callback(self, y_P):
"""Callback function to convert the PyTorch output of the ML model to a Firedrake function."""
space = self.ufl_function_space()
from firedrake import Cofunction
if isinstance(self._argument_slots[0], Cofunction):
space = self.ufl_function_space().dual()
else:
space = self.ufl_function_space()
return from_torch(y_P, space)

# -- PyTorch routines for computing AD based quantities via `torch.autograd.functional` -- #
Expand Down
Loading