-
I am trying to catch errors in a function which looks something like this:
Running this on single values work but using
Where the latter raises the following error
What is the correct way to handle this? I should note that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
This issue is discussed here: How to Think in JAX: Tracing and static variables. In particular, when you apply a if not is_ok(x, -1., 1.):
raise ValueError("Bad value") is incompatible with The best course of action depends on what you're doing with the result. Can you say more about the application that this simple snippet is meant to represent? |
Beta Was this translation helpful? Give feedback.
This issue is discussed here: How to Think in JAX: Tracing and static variables.
In particular, when you apply a
vmap
transformation on code, the mapped variables are traced, and it is not possible to do control flow that depends on the values being mapped. So this statement:is incompatible with
vmap
whenx
is a mapped value. You cannot raise an error conditional on mapped values.The best course of action depends on what you're doing with the result. Can you say more about the application that this simple snippet is meant to represent?