Skip to content

Why jax choose jaxpr instead of python ast ? #7013

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

You must be logged in to vote

This is an interesting question: I think the main reason is that the Python AST is far too general: JAX does not implement everything that Python implements: for example, transformable JAX programs are linear and functional: JAX variables cannot be modified in-place, and JAX does not have general control flow like if/else statements or loops! For that reason, the Python AST is not a great fit for representing the set of programs that JAX is able to transform and compile, and a more limited JAX-specific IR is a better choice. Does that answer your question?

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@edimetia3d
Comment options

@jakevdp
Comment options

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