Skip to content

Can You Use Impure Functions In Jax Programs? #14196

Answered by jakevdp
Logon27 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi - thanks for the question! You can use impure functions in JAX as long as you don't transform them (i.e. use jit, vmap, grad, pmap, etc.) or use them in control flow operations: (fori_loop, while_loop, scan, etc.). A typical pattern is to use impure functions as a sort of set-up step (e.g. loading data from disk) and then make the core parts of your algorithm pure.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Logon27
Comment options

Answer selected by Logon27
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