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

Make JIT compilation of Jacobian algorithm independent from body index #17

Merged
merged 1 commit into from
Sep 21, 2022

Conversation

diegoferigo
Copy link
Member

Before this PR, the computation of any link's Jacobian would trigger a JIT recompilation since the body_index argument had to be marked as static:

q: jnp.ndarray = ...
xfb: jnp.ndarray = ...
body_index: int = ...

J = jax.jit(algos.jacobian.jacobian, static_argnames="body_index")(
    q=q, body_index=body_index, xfb=xfb
)

The main reason was that the support body array $\kappa(i)$ has different length for different bodies (where $i$ is the body index).

This PR introduces a new way to compute the support body array $\kappa(i)$ passing through a boolean representation having fixed dimension. This update enables the Jacobian algorithm to be generic and its JIT compiled version remains valid for all link indices.

@diegoferigo diegoferigo self-assigned this Sep 21, 2022
@diegoferigo diegoferigo merged commit 119c228 into main Sep 21, 2022
@diegoferigo diegoferigo deleted the feature/optimize_jit_jacobian branch September 21, 2022 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants