-
Is there a way to impose a maximum number of iterations in a I tried carrying on the iteration number and adding an "and" in the condition function, but I get an Abstract Tracer Value error. For instance
|
Beta Was this translation helpful? Give feedback.
Answered by
jakevdp
Oct 18, 2021
Replies: 1 comment 1 reply
-
You should use def loop_cond(args):
return (args[0] < 1000) & (args[1] < 1e6) The reason is that Python's |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
mberaha
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should use
&
instead ofand
:The reason is that Python's
and
eagerly casts its inputs to boolean, and this behavior cannot be overloaded. Thus JAX follows NumPy in using bitwise logical operators,&
,|
, etc. for doing element-wise logic on boolean arrays.