How to add new variables to a Jaxpr? #28976
Answered
by
dfm
huterguier
asked this question in
Q&A
-
I would like to modify a Jaxpr in a way that I need to add additional variables to it. What would be the correct way to create new unique ids for these variables? I have seen some people determining the maximum id in the Jaxpr and then incrementing but that feels a bit hacky to me to be honest. |
Beta Was this translation helpful? Give feedback.
Answered by
dfm
May 23, 2025
Replies: 1 comment 1 reply
-
YMMV because the Jaxpr data structure isn't really meant to be user-facing, but I don't believe you need to specify an id. Variables in a Jaxpr are new_var = Var("", ShapedArray((1, 5), jnp.float32)) should be fine for creating a new variable! |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
huterguier
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
YMMV because the Jaxpr data structure isn't really meant to be user-facing, but I don't believe you need to specify an id. Variables in a Jaxpr are
Var
objects and they only wrap aAbstractValue
:should be fine for creating a new variable!