Skip to content
Discussion options

You must be logged in to vote

Hi! This looks good, the only concerning thing I see is the use of in-place mutation in your class. For example, res.kill(0) will result in res being modified, but jax.jit(res.kill)(0) will not, because JAX requires pure functions.

As long as you don't write code that expects mutation side-effects to persist across transformation boundaries, it should be fine. For example, res.kill is impure and therefore problematic, but your body_fun as defined is non-problematic despite calling val.kill, because the mutations are reflected in the return value of the function.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@leviyevalex
Comment options

@jakevdp
Comment options

@leviyevalex
Comment options

Answer selected by leviyevalex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants