-
Hi, I am trying to code a body of a while loop with some conditions in its body function as folloiwng:
However, this returns TypeError: unhashable type: 'DeviceArray'. How should I fix this? Thanks, |
Beta Was this translation helpful? Give feedback.
Answered by
jakevdp
Apr 13, 2022
Replies: 1 comment 2 replies
-
The issue is you need to pass from functools import partial
lax.while_loop(cond_fun, partial(body_fun, y=y), init_val) |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
dui1234
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The issue is you need to pass
body_fun
to your while loop, rather than the result of evaluatingbody_fun
. Additionally, bothbody_fun
andcond_fun
must accept a single value as an argument. It sounds like what you want is to partially evaluatebody_fun
before passing it towhile_loop
, e.g.