Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file not shown.
14 changes: 12 additions & 2 deletions python/celerite2/pymc/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,18 @@
import pytensor
import pytensor.tensor as pt
from pytensor.graph import basic, op
from pytensor.link.jax.dispatch import jax_funcify

import celerite2.backprop as backprop
import celerite2.driver as driver

try:
from pytensor.link.jax.dispatch import jax_funcify
except ImportError: # pragma: no cover - jax is an optional dependency
# pytensor.link.jax.dispatch imports jax, which is not a required
# dependency of the PyMC backend. The conversion defined below is then
# simply not registered.
jax_funcify = None


def _resize_or_set(outputs, n, shape):
if outputs[n][0] is None:
Expand Down Expand Up @@ -160,7 +167,6 @@ def grad(self, inputs, gradients):


# JAX conversion for PyTensor JAX linker -------------------------------------
@jax_funcify.register(_CeleriteOp)
def _jax_funcify_celerite(op, node, **kwargs):
"""Map celerite2 PyTensor ops to their JAX counterparts."""

Expand Down Expand Up @@ -224,3 +230,7 @@ def general_matmul_upper_fwd(t1, t2, c, U, V, Y):
raise NotImplementedError(
f"No JAX conversion registered for {op.name}"
)


if jax_funcify is not None:
jax_funcify.register(_CeleriteOp)(_jax_funcify_celerite)
Loading